Add CONFIG_DISCONTIGMEM support to kdbm_memmap.

Updated the kdbm_memmap() 'memmap' command routine so that
it now works when CONFIG_DISCONTIGMEM is enabled.

When CONFIG_DISCONTIGMEM is enabled this routine outputs
information for all pages in the system unless a 'node id'
parameter is specifed, in which case the information for
just that node's pages is output.

Also changed this routine so that it can handle pages
count values of -1.  This was causing it to blow up,
even when CONFIG_DISCONTIGMEM was disabled.

Author: John Blackwood <[EMAIL PROTECTED]>
Signed-off-by: Joe Korty <[EMAIL PROTECTED]>

Index: 2.6.26-rc9/kdb/modules/kdbm_pg.c
===================================================================
--- 2.6.26-rc9.orig/kdb/modules/kdbm_pg.c       2008-07-10 12:14:15.000000000 
-0400
+++ 2.6.26-rc9/kdb/modules/kdbm_pg.c    2008-07-10 13:34:55.000000000 -0400
@@ -557,18 +557,43 @@
        int slab_count = 0;
        int dirty_count = 0;
        int locked_count = 0;
-       int page_counts[9];
+       int page_counts[10];    /* [8] = large counts, [9] = -1 counts */
        int buffered_count = 0;
 #ifdef buffer_delay
        int delay_count = 0;
 #endif
        int diag;
        unsigned long addr;
+#ifdef CONFIG_DISCONTIGMEM
+       int node_id = -1, found_node = 0;
+       int tot_page_count = 0;
+       unsigned long unode_id;
+       pg_data_t *pgdat;
+
+       if (argc == 1) {                /* node_id was specified */
+           diag = kdbgetularg(argv[argc], &unode_id);
+           if (diag)
+               return diag;
+           node_id = (int)unode_id;
+       }
+       else if (argc)
+           return KDB_ARGCOUNT;
+
+       tot_page_count = 0;
+       memset(page_counts, 0, sizeof(page_counts));
 
+       for_each_online_pgdat(pgdat) {
+           if ((node_id != -1) && (pgdat->node_id != node_id))
+               continue;
+           found_node = 1;
+           addr = (unsigned long)pgdat->node_mem_map;
+           page_count = pgdat->node_spanned_pages;
+           tot_page_count += page_count;
+#else
        addr = (unsigned long)mem_map;
        page_count = max_mapnr;
        memset(page_counts, 0, sizeof(page_counts));
-
+#endif
        for (i = 0; i < page_count; i++) {
                if ((diag = kdb_getarea(page, addr)))
                        return(diag);
@@ -580,7 +605,9 @@
                        dirty_count++;
                if (PageLocked(&page))
                        locked_count++;
-               if (page._count.counter < 8)
+               if (page._count.counter == -1)
+                        page_counts[9]++;
+               else if (page._count.counter < 8)
                        page_counts[page._count.counter]++;
                else
                        page_counts[8]++;
@@ -591,9 +618,18 @@
                                delay_count++;
 #endif
                }
-
        }
-
+#ifdef CONFIG_DISCONTIGMEM
+       }
+       page_count = tot_page_count;
+       if (node_id != -1) {
+           if (!found_node) {
+               kdb_printf("Node %d does not exist.\n", node_id);
+               return 0;
+           }
+           kdb_printf("Node %d pages:\n", node_id);
+       }
+#endif
        kdb_printf("  Total pages:      %6d\n", page_count);
        kdb_printf("  Slab pages:       %6d\n", slab_count);
        kdb_printf("  Dirty pages:      %6d\n", dirty_count);
@@ -602,6 +638,7 @@
 #ifdef buffer_delay
        kdb_printf("  Delalloc pages:   %6d\n", delay_count);
 #endif
+       kdb_printf(" -1 page count:     %6d\n", page_counts[9]);
        for (i = 0; i < 8; i++) {
                kdb_printf("  %d page count:     %6d\n",
                        i, page_counts[i]);
---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.

Reply via email to