[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC] xen/vsprintf: Introduce %pd formatter for domains
This allows all system domids to be printed by name, rather than special casing the idle vcpus alone. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: George Dunlap <George.Dunlap@xxxxxxxxxxxxx> CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx> CC: Tim Deegan <tim@xxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> CC: Julien Grall <julien.grall@xxxxxxx> RFC, because this was proposed before but rejected at the time. I'm looking to try and turn errors like this: (XEN) mm.c:1023:d0v2 pg_owner d32754 l1e_owner d0, but real_pg_owner d0 (XEN) mm.c:1099:d0v2 Error getting mfn 810020 (pfn 59db1) from L1 entry 8000000810020227 for l1e_owner d0, pg_owner d32754 into the slightly more helpful: (XEN) mm.c:1022:d0v2 pg_owner dXEN l1e_owner d0, but real_pg_owner d0 (XEN) mm.c:1098:d0v2 Error getting mfn 810020 (pfn 59db1) from L1 entry 8000000810020227 for l1e_owner d0, pg_owner dXEN although even in this case, the former printk has an awkward corner case of a possibly NULL domain pointer, which can possibly only reasonably be fixed inside pointer() itself. # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Wed Aug 29 16:16:50 2018 +0000 # # On branch xen-pd # Your branch is ahead of 'origin/staging' by 1 commit. # (use "git push" to publish your local commits) # # Changes to be committed: # modified: ../docs/misc/printk-formats.txt # modified: common/vsprintf.c # # Untracked files: # System.map-after # System.map-before # dis-after # dis-before # headers-after # headers-before # include/asm-x86/asm-macros.h # wl-a # wl-b # xen-after # xen-before # xen-syms-after # xen-syms-before # --- docs/misc/printk-formats.txt | 3 +++ xen/common/vsprintf.c | 57 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/docs/misc/printk-formats.txt b/docs/misc/printk-formats.txt index 525108f..6d2c617 100644 --- a/docs/misc/printk-formats.txt +++ b/docs/misc/printk-formats.txt @@ -28,5 +28,8 @@ Symbol/Function pointers: Domain and vCPU information: + %pd Domain from a 'struct domain *d' (printed as d<domid>, but with + system domains represented by name, e.g. 'dIDLE') + %pv Domain and vCPU ID from a 'struct vcpu *' (printed as "d<domid>v<vcpuid>") diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c index f92fb67..918a39d 100644 --- a/xen/common/vsprintf.c +++ b/xen/common/vsprintf.c @@ -264,6 +264,41 @@ static char *string(char *str, char *end, const char *s, return str; } +/* Print a domain as d<num> or d<str> for system domains. */ +static char *print_domain(char *str, char *end, const struct domain *d) +{ + const char *name = NULL; + + if ( str < end ) + *str++ = 'd'; + + switch ( d->domain_id ) + { + case DOMID_SELF: name = "SELF"; break; + case DOMID_IO: name = "IO"; break; + case DOMID_XEN: name = "XEN"; break; + case DOMID_COW: name = "COW"; break; + case DOMID_INVALID: name = "INVALID"; break; + case DOMID_IDLE: name = "IDLE"; break; + } + + if ( name ) + return string(str, end, name, -1, -1, 0); + else + return number(str, end, d->domain_id, 10, -1, -1, 0); +} + +/* Print a vcpu as d<domain-id>v<vcpu-id> */ +static char *print_vcpu(char *str, char *end, const struct vcpu *v) +{ + str = print_domain(str, end, v->domain); + + if ( str < end ) + *str = 'v'; + + return number(str + 1, end, v->vcpu_id, 10, -1, -1, 0); +} + static char *pointer(char *str, char *end, const char **fmt_ptr, const void *arg, int field_width, int precision, int flags) @@ -273,6 +308,15 @@ static char *pointer(char *str, char *end, const char **fmt_ptr, /* Custom %p suffixes. See XEN_ROOT/docs/misc/printk-formats.txt */ switch ( fmt[1] ) { + case 'd': /* d<domain-id> from a struct domain */ + { + const struct domain *d = arg; + + ++*fmt_ptr; + + return print_domain(str, end, d); + } + case 'h': /* Raw buffer as hex string. */ { const uint8_t *hex_buffer = arg; @@ -374,17 +418,8 @@ static char *pointer(char *str, char *end, const char **fmt_ptr, const struct vcpu *v = arg; ++*fmt_ptr; - if ( unlikely(v->domain->domain_id == DOMID_IDLE) ) - str = string(str, end, "IDLE", -1, -1, 0); - else - { - if ( str < end ) - *str = 'd'; - str = number(str + 1, end, v->domain->domain_id, 10, -1, -1, 0); - } - if ( str < end ) - *str = 'v'; - return number(str + 1, end, v->vcpu_id, 10, -1, -1, 0); + + return print_vcpu(str, end, v); } } -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |