Skip to contentSkip to conversation

xen/vsprintf: Introduce %pd formatter for domains

RFC PATCH Superseded Andrew Cooper 2 participants 3 messages Aug 30, 2018 – Sep 7, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 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.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>

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(-)
docs/misc/printk-formats.txt +3 -0
index 525108f..6d2c617 100644
@@ -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>")
xen/common/vsprintf.c +46 -11

75 lines not on this page · raw message

Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 30.08.18 at 15:06, <[email protected]> wrote:

This allows all system domids to be printed by name, rather than special casing the idle vcpus alone.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>

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

Quoted 8 lines

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.

Or in print_domain(), producing "NULL".

docs/misc/printk-formats.txt Symbol/Function pointers: · line 32

Quoted 8 lines
docs/misc/printk-formats.txt +2 -0
@@ -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')

This looks a little awkward - how about d<IDLE> etc?

xen/common/vsprintf.c static char *string(char *str, char *end, const char *s, · line 273

Quoted 13 lines
xen/common/vsprintf.c +7 -0
@@ -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';

I would guess you've copied this idiom from somewhere, and if so it would be good to know where we still have got such broken construct(s) left: The increment needs to happen outside of the if(), for snprintf() et al to return a large enough number. See e.g. string(). Perhaps best to do this like you do ...

xen/common/vsprintf.c static char *string(char *str, char *end, const char *s, · line 299

Quoted 8 lines
xen/common/vsprintf.c +8 -0
+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);

... here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 22 lines · Jan Beulich
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 30.08.18 at 15:06, <[email protected]> wrote:

This allows all system domids to be printed by name, rather than special casing the idle vcpus alone.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>

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:

Quoted 7 lines
Quoted 6 lines

(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.

Or in print_domain(), producing "NULL".

Sounds like a good plan.

Quoted 10 lines

docs/misc/printk-formats.txt Symbol/Function pointers: · line 32

Quoted 9 lines
docs/misc/printk-formats.txt +2 -0
@@ -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')

This looks a little awkward - how about d<IDLE> etc?

A sample looks like:

dIDLEv0 dIO dXEN dCOW
d<IDLE>v0 d<IO> d<XEN> d<COW>

Another alternative would be:

d[IDLE]v0 d[IO] d[XEN] d[COW]

Which I think I prefer to angle brackets.

Quoted 7 lines
Quoted 7 lines
xen/common/vsprintf.c +0 -0
@@ -264,6 +264,41 @@ static char *string(char *str, char *end, const char *s,
     return str;
 }
 
Quoted 10 lines

xen/common/vsprintf.c static char *string(char *str, char *end, const char *s, · line 273

Quoted 7 lines
xen/common/vsprintf.c +7 -0
+/* 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';

I would guess you've copied this idiom from somewhere, and if so it would be good to know where we still have got such broken construct(s) left:

No - serves me write from trying to code from memory.  Fixed.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel