]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
tools/xenstore: add accounting trace support
authorJuergen Gross <jgross@suse.com>
Tue, 30 May 2023 08:24:18 +0000 (10:24 +0200)
committerJulien Grall <jgrall@amazon.com>
Wed, 7 Jun 2023 11:10:31 +0000 (12:10 +0100)
Add a new trace switch "acc" and the related trace calls.

The "acc" switch is off per default.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
tools/xenstore/xenstored_core.c
tools/xenstore/xenstored_core.h
tools/xenstore/xenstored_domain.c

index 43b8772cb32e11c3716ed4cb07180a863b1f4e93..eb916b06475f78e5b48e83a276a70b109b14357d 100644 (file)
@@ -2756,7 +2756,7 @@ static void set_quota(const char *arg, bool soft)
 
 /* Sorted by bit values of TRACE_* flags. Flag is (1u << index). */
 const char *const trace_switches[] = {
-       "obj", "io", "wrl",
+       "obj", "io", "wrl", "acc",
        NULL
 };
 
index 1f811f38cb037476c2316ce4800c451f9ef513f8..3e0734a6c6e423b3f2adb759c499d68dd1a7a730 100644 (file)
@@ -302,6 +302,7 @@ extern unsigned int trace_flags;
 #define TRACE_OBJ      0x00000001
 #define TRACE_IO       0x00000002
 #define TRACE_WRL      0x00000004
+#define TRACE_ACC      0x00000008
 extern const char *const trace_switches[];
 int set_trace_switch(const char *arg);
 
index 5b897df0ba0e31a30d28203e47af55d9e653bd7d..6523c3a830048caf255cdab5439914c81a0d225a 100644 (file)
@@ -537,6 +537,12 @@ static struct domain *find_domain_by_domid(unsigned int domid)
        return (d && d->introduced) ? d : NULL;
 }
 
+#define trace_acc(...)                         \
+do {                                           \
+       if (trace_flags & TRACE_ACC)            \
+               trace("acc: " __VA_ARGS__);     \
+} while (0)
+
 int acc_fix_domains(struct list_head *head, bool chk_quota, bool update)
 {
        struct changed_domain *cd;
@@ -600,6 +606,8 @@ static int acc_add_changed_dom(const void *ctx, struct list_head *head,
                return 0;
 
        errno = 0;
+       trace_acc("local change domid %u: what=%u %d add %d\n", domid, what,
+                 cd->acc[what], val);
        cd->acc[what] += val;
 
        return cd->acc[what];
@@ -1111,6 +1119,8 @@ static int domain_acc_add(struct connection *conn, unsigned int domid,
                return domain_acc_add_valid(d, what, ret);
        }
 
+       trace_acc("global change domid %u: what=%u %u add %d\n", domid, what,
+                 d->acc[what], add);
        d->acc[what] = domain_acc_add_valid(d, what, add);
 
        return d->acc[what];