Skip to contentSkip to conversation

x86: make dump_pageframe_info() slightly more verbose for dying domains

PATCH Superseded Jan Beulich 2 participants 3 messages Sep 12, 2014 – Sep 22, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: make dump_pageframe_info() slightly more verbose for dying domains

Allowing more than just 10 pages to be printed in this case gives a better chance to fully understand eventual page reference leaks.

xen/arch/x86/domain.c +16 -1
@@ -151,15 +151,30 @@ void dump_pageframe_info(struct domain *
 
     printk("Memory pages belonging to domain %u:\n", d->domain_id);
 
-    if ( d->tot_pages >= 10 )
+    if ( d->tot_pages >= 10 && d->is_dying < DOMDYING_dead )
     {
         printk("    DomPage list too long to display\n");
     }
     else
     {
+        unsigned long total[PGT_type_mask
+                            / (PGT_type_mask & -PGT_type_mask) + 1] = {};
+
         spin_lock(&d->page_alloc_lock);
         page_list_for_each ( page, &d->page_list )
         {
+            unsigned int index = (page->u.inuse.type_info & PGT_type_mask)
+                                 / (PGT_type_mask & -PGT_type_mask);
+
+            if ( ++total[index] > 16 )
+            {
+                switch ( page->u.inuse.type_info & PGT_type_mask )
+                {
+                case PGT_none:
+                case PGT_writable_page:
+                    continue;
+                }
+            }
             printk("    DomPage %p: caf=%08lx, taf=%" PRtype_info "\n",
                    _p(page_to_mfn(page)),
                    page->count_info, page->u.inuse.type_info);

x86: make dump_pageframe_info() slightly more verbose for dying domains

Allowing more than just 10 pages to be printed in this case gives a better chance to fully understand eventual page reference leaks.

xen/arch/x86/domain.c +16 -1
@@ -151,15 +151,30 @@ void dump_pageframe_info(struct domain *
 
     printk("Memory pages belonging to domain %u:\n", d->domain_id);
 
-    if ( d->tot_pages >= 10 )
+    if ( d->tot_pages >= 10 && d->is_dying < DOMDYING_dead )
     {
         printk("    DomPage list too long to display\n");
     }
     else
     {
+        unsigned long total[PGT_type_mask
+                            / (PGT_type_mask & -PGT_type_mask) + 1] = {};
+
         spin_lock(&d->page_alloc_lock);
         page_list_for_each ( page, &d->page_list )
         {
+            unsigned int index = (page->u.inuse.type_info & PGT_type_mask)
+                                 / (PGT_type_mask & -PGT_type_mask);
+
+            if ( ++total[index] > 16 )
+            {
+                switch ( page->u.inuse.type_info & PGT_type_mask )
+                {
+                case PGT_none:
+                case PGT_writable_page:
+                    continue;
+                }
+            }
             printk("    DomPage %p: caf=%08lx, taf=%" PRtype_info "\n",
                    _p(page_to_mfn(page)),
                    page->count_info, page->u.inuse.type_info);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 10 lines · Jan Beulich

Allowing more than just 10 pages to be printed in this case gives a better chance to fully understand eventual page reference leaks.

xen/arch/x86/domain.c +0 -0
@@ -151,15 +151,30 @@ void dump_pageframe_info(struct domain *
 
     printk("Memory pages belonging to domain %u:\n", d->domain_id);

xen/arch/x86/domain.c void dump_pageframe_info(struct domain * · line 161

Quoted 10 lines
xen/arch/x86/domain.c +3 -1
 
-    if ( d->tot_pages >= 10 )
+    if ( d->tot_pages >= 10 && d->is_dying < DOMDYING_dead )
     {
         printk("    DomPage list too long to display\n");
     }
     else
     {
+        unsigned long total[PGT_type_mask
+                            / (PGT_type_mask & -PGT_type_mask) + 1] = {};

Is it possible to make use of something like:

#define LSB(x) ((x) & -(x))

for code clarity? (and perhaps for those whose bit manipulation knowledge is a tad rusty)

Furthermore, the divide needs brackets per Xen style. The current layout makes it easy to mistake the +1 as being part of the divisor.

Quoted 6 lines
xen/arch/x86/domain.c +3 -0
+
         spin_lock(&d->page_alloc_lock);
         page_list_for_each ( page, &d->page_list )
         {
+            unsigned int index = (page->u.inuse.type_info & PGT_type_mask)
+                                 / (PGT_type_mask & -PGT_type_mask);

xen/arch/x86/domain.c void dump_pageframe_info(struct domain * · line 177

Quoted 10 lines
xen/arch/x86/domain.c +10 -0
+
+            if ( ++total[index] > 16 )
+            {
+                switch ( page->u.inuse.type_info & PGT_type_mask )
+                {
+                case PGT_none:
+                case PGT_writable_page:
+                    continue;
+                }
+            }

So, the new behaviour is to print all non none or writable_page, and print the first 16 of each of those? This is probably fine for dying/dead domains only, but I feel it warrants a comment in the patch description.

~Andrew

#2 lore raw
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 22.09.14 at 12:31, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich

Allowing more than just 10 pages to be printed in this case gives a better chance to fully understand eventual page reference leaks.

xen/arch/x86/domain.c +0 -0
@@ -151,15 +151,30 @@ void dump_pageframe_info(struct domain *
 
     printk("Memory pages belonging to domain %u:\n", d->domain_id);

xen/arch/x86/domain.c void dump_pageframe_info(struct domain * · line 161

Quoted 10 lines
xen/arch/x86/domain.c +3 -1
 
-    if ( d->tot_pages >= 10 )
+    if ( d->tot_pages >= 10 && d->is_dying < DOMDYING_dead )
     {
         printk("    DomPage list too long to display\n");
     }
     else
     {
+        unsigned long total[PGT_type_mask
+                            / (PGT_type_mask & -PGT_type_mask) + 1] = {};

Is it possible to make use of something like:

Quoted 4 lines

#define LSB(x) ((x) & -(x))

for code clarity? (and perhaps for those whose bit manipulation knowledge is a tad rusty)

Actually I should make use of MASK_EXTR() here. It's just that the patch here significantly pre-dates the introduction of that and MASK_INSR().

Quoted 2 lines

Furthermore, the divide needs brackets per Xen style. The current layout makes it easy to mistake the +1 as being part of the divisor.

I don't think so - the C and mathematical meanings agree here.

Quoted 13 lines
Quoted 13 lines
xen/arch/x86/domain.c +10 -0
+
         spin_lock(&d->page_alloc_lock);
         page_list_for_each ( page, &d->page_list )
         {
+            unsigned int index = (page->u.inuse.type_info & PGT_type_mask)
+                                 / (PGT_type_mask & -PGT_type_mask);
+
+            if ( ++total[index] > 16 )
+            {
+                switch ( page->u.inuse.type_info & PGT_type_mask )
+                {
+                case PGT_none:
+                case PGT_writable_page:
Quoted 8 lines

xen/arch/x86/domain.c void dump_pageframe_info(struct domain * · line 177

Quoted 3 lines
xen/arch/x86/domain.c +3 -0
+                    continue;
+                }
+            }

So, the new behaviour is to print all non none or writable_page, and print the first 16 of each of those? This is probably fine for dying/dead domains only, but I feel it warrants a comment in the patch description.

Yeah, could do so. I actually further wonder whether the two thresholds shouldn't become command line controllable (and possibly get folded into one).

Jan