Skip to contentSkip to conversation

mm: Export definition of 'zone_names' array through mmzone.h

PATCH In review Anshuman Khandual 6 participants 20 messages Sep 6, 2016 – Oct 13, 2016

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 mm: Export definition of 'zone_names' array through mmzone.h

zone_names[] is used to identify any zone given it's index which can be used in many other places. So exporting the definition through include/linux/mmzone.h header for it's broader access.

---
Changes in V2:
- Removed the static and declared in mmzone.h per Andrew

 include/linux/mmzone.h | 1 +
 mm/page_alloc.c        | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
include/linux/mmzone.h +1 -0
index 7f2ae99..9943204 100644
@@ -341,6 +341,7 @@ enum zone_type {
 
 };
 
+extern char * const zone_names[];
 #ifndef __GENERATING_BOUNDS_H
 
 struct zone {
mm/page_alloc.c +1 -1
index a2214c6..cb46bf8 100644
@@ -207,7 +207,7 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
 
 EXPORT_SYMBOL(totalram_pages);
 
-static char * const zone_names[MAX_NR_ZONES] = {
+char * const zone_names[MAX_NR_ZONES] = {
 #ifdef CONFIG_ZONE_DMA
 	 "DMA",
 #endif
Signature · 1 line
2.1.0
#1 lore raw

PATCH v2 2/2 mm: Add sysfs interface to dump each node's zonelist information

Each individual node in the system has a ZONELIST_FALLBACK zonelist and a ZONELIST_NOFALLBACK zonelist. These zonelists decide fallback order of zones during memory allocations. Sometimes it helps to dump these zonelists to see the priority order of various zones in them.

Particularly platforms which support memory hotplug into previously non existing zones (at boot), this interface helps in visualizing which all zonelists of the system at what priority level, the new hot added memory ends up in. POWER is such a platform where all the memory detected during boot time remains with ZONE_DMA for good but then hot plug process can actually get new memory into ZONE_MOVABLE. So having a way to get the snapshot of the zonelists on the system after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

Example zonelist information from a KVM guest.

[NODE (0)]

        ZONELIST_FALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
        (1) (node 1) (zone DMA c000000100000000)
        (2) (node 2) (zone DMA c000000200000000)
        (3) (node 3) (zone DMA c000000300000000)
        ZONELIST_NOFALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
[NODE (1)]
        ZONELIST_FALLBACK
        (0) (node 1) (zone DMA c000000100000000)
        (1) (node 2) (zone DMA c000000200000000)
        (2) (node 3) (zone DMA c000000300000000)
        (3) (node 0) (zone DMA c00000000140c000)
        ZONELIST_NOFALLBACK
        (0) (node 1) (zone DMA c000000100000000)
[NODE (2)]
        ZONELIST_FALLBACK
        (0) (node 2) (zone DMA c000000200000000)
        (1) (node 3) (zone DMA c000000300000000)
        (2) (node 0) (zone DMA c00000000140c000)
        (3) (node 1) (zone DMA c000000100000000)
        ZONELIST_NOFALLBACK
        (0) (node 2) (zone DMA c000000200000000)
[NODE (3)]
        ZONELIST_FALLBACK
        (0) (node 3) (zone DMA c000000300000000)
        (1) (node 0) (zone DMA c00000000140c000)
        (2) (node 1) (zone DMA c000000100000000)
        (3) (node 2) (zone DMA c000000200000000)
        ZONELIST_NOFALLBACK
        (0) (node 3) (zone DMA c000000300000000)

---
Changes in V2:
- Added more details into the commit message
- Added sysfs interface file details into the commit message
- Added ../ABI/testing/sysfs-system-zone-details file

 .../ABI/testing/sysfs-system-zone-details          |  9 +++++
 drivers/base/memory.c                              | 46 ++++++++++++++++++++++
 2 files changed, 55 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-system-zone-details
Documentation/ABI/testing/sysfs-system-zone-details new file +9 -0
new file mode 100644
index 0000000..9c13b2e
@@ -0,0 +1,9 @@
+What:		/sys/devices/system/memory/system_zone_details
+Date:		Sep 2016
+KernelVersion:	4.8
+Contact:	[email protected]
+Description:
+		This read only file dumps the zonelist and it's constituent
+		zones information for both ZONELIST_FALLBACK and ZONELIST_
+		NOFALLBACK zonelists for each online node of the system at
+		any given point of time.
drivers/base/memory.c +46 -0

59 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

Re: [PATCH V2 2/2] mm: Add sysfs interface to dump each node's zonelist information

reproduce:

Hi Anshuman,

[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.8-rc5 next-20160905]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-Export-definition-of-zone_names-array-through-mmzone-h/20160906-133749
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: x86_64-randconfig-x013-201636 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/base/memory.c: In function 'dump_zonelists':

>> drivers/base/memory.c:474:20: error: 'ZONELIST_NOFALLBACK' undeclared (first use in this function)
        node_zonelists[ZONELIST_NOFALLBACK]);
                       ^~~~~~~~~~~~~~~~~~~

drivers/base/memory.c:474:20: note: each undeclared identifier is reported only once for each function it appears in

vim +/ZONELIST_NOFALLBACK +474 drivers/base/memory.c

468 node_zonelists[ZONELIST_FALLBACK]);
469 count += sprintf(buf + count, "[NODE (%d)]\n", node);
470 count += sprintf(buf + count, "\tZONELIST_FALLBACK\n");
471 count += dump_zonelist(buf + count, zonelist);
472
473 zonelist = &(NODE_DATA(node)->

 > 474					node_zonelists[ZONELIST_NOFALLBACK]);

475 count += sprintf(buf + count, "\tZONELIST_NOFALLBACK\n");
476 count += dump_zonelist(buf + count, zonelist);
477 }

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

Re: [PATCH V2 2/2] mm: Add sysfs interface to dump each node's zonelist information

Quoted 26 lines · kbuild test robot

Hi Anshuman,

[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.8-rc5 next-20160905]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-Export-definition-of-zone_names-array-through-mmzone-h/20160906-133749
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: x86_64-randconfig-x013-201636 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/base/memory.c: In function 'dump_zonelists':

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/base/memory.c:474:20: error: 'ZONELIST_NOFALLBACK' undeclared (first use in this function)

        node_zonelists[ZONELIST_NOFALLBACK]);
                       ^~~~~~~~~~~~~~~~~~~

drivers/base/memory.c:474:20: note: each undeclared identifier is reported only once for each function it appears in

vim +/ZONELIST_NOFALLBACK +474 drivers/base/memory.c

Quoted 8 lines
   468					node_zonelists[ZONELIST_FALLBACK]);
   469			count += sprintf(buf + count, "[NODE (%d)]\n", node);
   470			count += sprintf(buf + count, "\tZONELIST_FALLBACK\n");
   471			count += dump_zonelist(buf + count, zonelist);
   472	
   473			zonelist = &(NODE_DATA(node)->
Quoted 1 line

474 node_zonelists[ZONELIST_NOFALLBACK]);

475 count += sprintf(buf + count, "\tZONELIST_NOFALLBACK\n");

Missed the fact that ZONELIST_NOFALLBACK is valid only on CONFIG_NUMA systems. Will fix and resend the patch.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw

PATCH v3 1/1 mm: Add sysfs interface to dump each node's zonelist information

In reply to Anshuman Khandual

Each individual node in the system has a ZONELIST_FALLBACK zonelist and a ZONELIST_NOFALLBACK zonelist. These zonelists decide fallback order of zones during memory allocations. Sometimes it helps to dump these zonelists to see the priority order of various zones in them.

Particularly platforms which support memory hotplug into previously non existing zones (at boot), this interface helps in visualizing which all zonelists of the system at what priority level, the new hot added memory ends up in. POWER is such a platform where all the memory detected during boot time remains with ZONE_DMA for good but then hot plug process can actually get new memory into ZONE_MOVABLE. So having a way to get the snapshot of the zonelists on the system after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

Example zonelist information from a KVM guest.

[NODE (0)]

        ZONELIST_FALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
        (1) (node 1) (zone DMA c000000100000000)
        (2) (node 2) (zone DMA c000000200000000)
        (3) (node 3) (zone DMA c000000300000000)
        ZONELIST_NOFALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
[NODE (1)]
        ZONELIST_FALLBACK
        (0) (node 1) (zone DMA c000000100000000)
        (1) (node 2) (zone DMA c000000200000000)
        (2) (node 3) (zone DMA c000000300000000)
        (3) (node 0) (zone DMA c00000000140c000)
        ZONELIST_NOFALLBACK
        (0) (node 1) (zone DMA c000000100000000)
[NODE (2)]
        ZONELIST_FALLBACK
        (0) (node 2) (zone DMA c000000200000000)
        (1) (node 3) (zone DMA c000000300000000)
        (2) (node 0) (zone DMA c00000000140c000)
        (3) (node 1) (zone DMA c000000100000000)
        ZONELIST_NOFALLBACK
        (0) (node 2) (zone DMA c000000200000000)
[NODE (3)]
        ZONELIST_FALLBACK
        (0) (node 3) (zone DMA c000000300000000)
        (1) (node 0) (zone DMA c00000000140c000)
        (2) (node 1) (zone DMA c000000100000000)
        (3) (node 2) (zone DMA c000000200000000)
        ZONELIST_NOFALLBACK
        (0) (node 3) (zone DMA c000000300000000)

---
Changes in V3:
- Moved all these new sysfs code inside CONFIG_NUMA

Changes in V2:
- Added more details into the commit message
- Added sysfs interface file details into the commit message
- Added ../ABI/testing/sysfs-system-zone-details file

 .../ABI/testing/sysfs-system-zone-details          |  9 ++++
 drivers/base/memory.c                              | 52 ++++++++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-system-zone-details
Documentation/ABI/testing/sysfs-system-zone-details new file +9 -0
new file mode 100644
index 0000000..9c13b2e
@@ -0,0 +1,9 @@
+What:		/sys/devices/system/memory/system_zone_details
+Date:		Sep 2016
+KernelVersion:	4.8
+Contact:	[email protected]
+Description:
+		This read only file dumps the zonelist and it's constituent
+		zones information for both ZONELIST_FALLBACK and ZONELIST_
+		NOFALLBACK zonelists for each online node of the system at
+		any given point of time.
drivers/base/memory.c +52 -0

65 lines not on this page · raw message

Signature · 7 lines
2.1.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw

Re: [PATCH V3] mm: Add sysfs interface to dump each node's zonelist information

url: https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-Add-sysfs-interface-to-dump-each-node-s-zonelist-information/20160906-163752 config: x86_64-randconfig-x019-201636 (attached as…

Hi Anshuman,

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on v4.8-rc5 next-20160906]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-Add-sysfs-interface-to-dump-each-node-s-zonelist-information/20160906-163752
config: x86_64-randconfig-x019-201636 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/base/memory.c: In function 'dump_zonelist':

>> drivers/base/memory.c:455:4: error: 'zone_names' undeclared (first use in this function)
       zone_names[zonelist->_zonerefs[i].zone_idx],
       ^~~~~~~~~~

drivers/base/memory.c:455:4: note: each undeclared identifier is reported only once for each function it appears in

vim +/zone_names +455 drivers/base/memory.c

449 ssize_t count = 0;
450
451 for (i = 0; zonelist->_zonerefs[i].zone; i++) {
452 count += sprintf(buf + count,
453 "\t\t(%d) (node %d) (%-10s %lx)\n", i,
454 zonelist->_zonerefs[i].zone->zone_pgdat->node_id,

 > 455				zone_names[zonelist->_zonerefs[i].zone_idx],

456 (unsigned long) zonelist->_zonerefs[i].zone);
457 }
458 return count;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#6 lore raw

Re: [PATCH V3] mm: Add sysfs interface to dump each node's zonelist information

Quoted 8 lines · kbuild test robot

Hi Anshuman,

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on v4.8-rc5 next-20160906]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

Quoted 6 lines

url: https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-Add-sysfs-interface-to-dump-each-node-s-zonelist-information/20160906-163752
config: x86_64-randconfig-x019-201636 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

I am not able to reproduce this build failure with Fedora 24 and gcc (GCC) 6.1.1 20160621 on a x86 laptop. Maybe adding mmzone.h into page_alloc.c will be enough to just take care any issues.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw

Re: [PATCH V3] mm: Add sysfs interface to dump each node's zonelist information

In reply to Anshuman Khandual
Quoted 8 lines · Anshuman Khandual

[NODE (0)]

        ZONELIST_FALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
        (1) (node 1) (zone DMA c000000100000000)
        (2) (node 2) (zone DMA c000000200000000)
        (3) (node 3) (zone DMA c000000300000000)
        ZONELIST_NOFALLBACK
        (0) (node 0) (zone DMA c00000000140c000)

Don't we have some prohibition on dumping out kernel addresses like this so that attackers can't trivially defeat kernel layout randomization?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw

Re: [PATCH V3] mm: Add sysfs interface to dump each node's zonelist information

Quoted 10 lines · Dave Hansen
Quoted 8 lines · Anshuman Khandual

[NODE (0)]

        ZONELIST_FALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
        (1) (node 1) (zone DMA c000000100000000)
        (2) (node 2) (zone DMA c000000200000000)
        (3) (node 3) (zone DMA c000000300000000)
        ZONELIST_NOFALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
Quoted 2 lines

Don't we have some prohibition on dumping out kernel addresses like this so that attackers can't trivially defeat kernel layout randomization?

Anything printing memory addresses should be using %pK (not %lx as done here).

-Kees

Signature · 8 lines
Kees Cook
Nexus Security

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#9 lore raw

Re: [PATCH V3] mm: Add sysfs interface to dump each node's zonelist information

Quoted 11 lines · Kees Cook
Quoted 10 lines · Dave Hansen
Quoted 8 lines · Anshuman Khandual

[NODE (0)]

        ZONELIST_FALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
        (1) (node 1) (zone DMA c000000100000000)
        (2) (node 2) (zone DMA c000000200000000)
        (3) (node 3) (zone DMA c000000300000000)
        ZONELIST_NOFALLBACK
        (0) (node 0) (zone DMA c00000000140c000)
Quoted 4 lines
Quoted 2 lines

Don't we have some prohibition on dumping out kernel addresses like this so that attackers can't trivially defeat kernel layout randomization?

Anything printing memory addresses should be using %pK (not %lx as done here).

Learned about the significance of %pK coupled with kptr_restrict interface. Will change this. Thanks for pointing out.

#10 lore raw

PATCH v4 1/1 mm: Add sysfs interface to dump each node's zonelist information

In reply to Anshuman Khandual

Each individual node in the system has a ZONELIST_FALLBACK zonelist and a ZONELIST_NOFALLBACK zonelist. These zonelists decide fallback order of zones during memory allocations. Sometimes it helps to dump these zonelists to see the priority order of various zones in them.

Particularly platforms which support memory hotplug into previously non existing zones (at boot), this interface helps in visualizing which all zonelists of the system at what priority level, the new hot added memory ends up in. POWER is such a platform where all the memory detected during boot time remains with ZONE_DMA for good but then hot plug process can actually get new memory into ZONE_MOVABLE. So having a way to get the snapshot of the zonelists on the system after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

Example zonelist information from a KVM guest.

[NODE (0)]

        ZONELIST_FALLBACK
                (0) (node 0) (DMA     0xc0000000ffff6300)
                (1) (node 1) (DMA     0xc0000001ffff6300)
                (2) (node 2) (DMA     0xc0000002ffff6300)
                (3) (node 3) (DMA     0xc0000003ffdba300)
        ZONELIST_NOFALLBACK
                (0) (node 0) (DMA     0xc0000000ffff6300)
[NODE (1)]
        ZONELIST_FALLBACK
                (0) (node 1) (DMA     0xc0000001ffff6300)
                (1) (node 2) (DMA     0xc0000002ffff6300)
                (2) (node 3) (DMA     0xc0000003ffdba300)
                (3) (node 0) (DMA     0xc0000000ffff6300)
        ZONELIST_NOFALLBACK
                (0) (node 1) (DMA     0xc0000001ffff6300)
[NODE (2)]
        ZONELIST_FALLBACK
                (0) (node 2) (DMA     0xc0000002ffff6300)
                (1) (node 3) (DMA     0xc0000003ffdba300)
                (2) (node 0) (DMA     0xc0000000ffff6300)
                (3) (node 1) (DMA     0xc0000001ffff6300)
        ZONELIST_NOFALLBACK
                (0) (node 2) (DMA     0xc0000002ffff6300)
[NODE (3)]
        ZONELIST_FALLBACK
                (0) (node 3) (DMA     0xc0000003ffdba300)
                (1) (node 0) (DMA     0xc0000000ffff6300)
                (2) (node 1) (DMA     0xc0000001ffff6300)
                (3) (node 2) (DMA     0xc0000002ffff6300)
        ZONELIST_NOFALLBACK
                (0) (node 3) (DMA     0xc0000003ffdba300)

---
Changes in V4:
- Explicitly included mmzone.h header inside page_alloc.c
- Changed the kernel address printing from %lx to %pK

Changes in V3:
- Moved all these new sysfs code inside CONFIG_NUMA

Changes in V2:
- Added more details into the commit message
- Added sysfs interface file details into the commit message
- Added ../ABI/testing/sysfs-system-zone-details file

 .../ABI/testing/sysfs-system-zone-details          |  9 ++++
 drivers/base/memory.c                              | 52 ++++++++++++++++++++++
 mm/page_alloc.c                                    |  1 +
 3 files changed, 62 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-system-zone-details
Documentation/ABI/testing/sysfs-system-zone-details new file +9 -0
new file mode 100644
index 0000000..9c13b2e
@@ -0,0 +1,9 @@
+What:		/sys/devices/system/memory/system_zone_details
+Date:		Sep 2016
+KernelVersion:	4.8
+Contact:	[email protected]
+Description:
+		This read only file dumps the zonelist and it's constituent
+		zones information for both ZONELIST_FALLBACK and ZONELIST_
+		NOFALLBACK zonelists for each online node of the system at
+		any given point of time.
drivers/base/memory.c +52 -0

65 lines not on this page · raw message

mm/page_alloc.c +1 -0
index a2214c6..d3da022 100644
@@ -64,6 +64,7 @@
 #include <linux/page_owner.h>
 #include <linux/kthread.h>
 #include <linux/memcontrol.h>
+#include <linux/mmzone.h>
 
 #include <asm/sections.h>
 #include <asm/tlbflush.h>
Signature · 7 lines
2.1.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#11 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

url: https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-Add-sysfs-interface-to-dump-each-node-s-zonelist-information/20160908-104922 config: x86_64-lkp (attached as .config) compiler…

Hi Anshuman,

[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on v4.8-rc5]
[cannot apply to next-20160908]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/Anshuman-Khandual/mm-Add-sysfs-interface-to-dump-each-node-s-zonelist-information/20160908-104922
config: x86_64-lkp (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/base/memory.c: In function 'dump_zonelist':

>> drivers/base/memory.c:455:4: error: 'zone_names' undeclared (first use in this function)
       zone_names[zonelist->_zonerefs[i].zone_idx],
       ^~~~~~~~~~

drivers/base/memory.c:455:4: note: each undeclared identifier is reported only once for each function it appears in

vim +/zone_names +455 drivers/base/memory.c

449 ssize_t count = 0;
450
451 for (i = 0; zonelist->_zonerefs[i].zone; i++) {
452 count += sprintf(buf + count,
453 "\t\t(%d) (node %d) (%-7s 0x%pK)\n", i,
454 zonelist->_zonerefs[i].zone->zone_pgdat->node_id,

 > 455				zone_names[zonelist->_zonerefs[i].zone_idx],

456 (void *) zonelist->_zonerefs[i].zone);
457 }
458 return count;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#12 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

In reply to Anshuman Khandual
Quoted 3 lines · Anshuman Khandual

after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

Doesn't this violate the "one value per file" sysfs rule? Does it belong in debugfs instead?

I also really question the need to dump kernel addresses out, filtered or not. What's the point?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#13 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

Quoted 6 lines · Dave Hansen
Quoted 3 lines · Anshuman Khandual
Quoted 3 lines

after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

Doesn't this violate the "one value per file" sysfs rule? Does it belong in debugfs instead?

Yeah sure. Will make it a debugfs interface.

Quoted 3 lines

I also really question the need to dump kernel addresses out, filtered or not. What's the point?

Hmm, thought it to be an additional information. But yes its additional and can be dropped.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#14 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

Quoted 8 lines · Anshuman Khandual
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

Doesn't this violate the "one value per file" sysfs rule? Does it belong in debugfs instead?

Yeah sure. Will make it a debugfs interface.

So the intended reader of this file is running as root?

Quoted 6 lines
Quoted 2 lines

I also really question the need to dump kernel addresses out, filtered or not. What's the point?

Hmm, thought it to be an additional information. But yes its additional and can be dropped.

I'm questioning if this information can be inferred from information already in /proc/zoneinfo and sysfs. We know the no-fallback zonelist is going to include the local node, and we know the other zonelists are either node ordered or zone ordered (or do we need to extend vm.numa_zonelist_order for default?). I may have missed what new knowledge this interface is imparting on us.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

Quoted 5 lines · David Rientjes
Quoted 3 lines · Anshuman Khandual
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Doesn't this violate the "one value per file" sysfs rule? Does it belong in debugfs instead?

Yeah sure. Will make it a debugfs interface.

So the intended reader of this file is running as root?

Yeah.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

I also really question the need to dump kernel addresses out, filtered or not. What's the point?

Hmm, thought it to be an additional information. But yes its additional and can be dropped.

Quoted 6 lines

I'm questioning if this information can be inferred from information already in /proc/zoneinfo and sysfs. We know the no-fallback zonelist is going to include the local node, and we know the other zonelists are either node ordered or zone ordered (or do we need to extend vm.numa_zonelist_order for default?). I may have missed what new knowledge this interface is imparting on us.

IIUC /proc/zoneinfo lists down zone internal state and statistics for all zones on the system at any given point of time. The no-fallback list contains the zones from the local node and fallback (which gets used more often than the no-fallback) list contains all zones either in node-ordered or zone-ordered manner. In most of the platforms the default being the node order but the sequence of present nodes in that order is determined by various factors like NUMA distance, load, presence of CPUs on the node etc. This order of nodes in the fallback list is the most important information derived out of this interface.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#16 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

Quoted 7 lines · Anshuman Khandual
Quoted 6 lines

I'm questioning if this information can be inferred from information already in /proc/zoneinfo and sysfs. We know the no-fallback zonelist is going to include the local node, and we know the other zonelists are either node ordered or zone ordered (or do we need to extend vm.numa_zonelist_order for default?). I may have missed what new knowledge this interface is imparting on us.

Quoted 10 lines

IIUC /proc/zoneinfo lists down zone internal state and statistics for all zones on the system at any given point of time. The no-fallback list contains the zones from the local node and fallback (which gets used more often than the no-fallback) list contains all zones either in node-ordered or zone-ordered manner. In most of the platforms the default being the node order but the sequence of present nodes in that order is determined by various factors like NUMA distance, load, presence of CPUs on the node etc. This order of nodes in the fallback list is the most important information derived out of this interface.

The point is that all of this can be inferred with information already provided, so the additional interface seems unnecessary. The only extension I think that is needed is to determine if the order is node or zone when vm.numa_zonelist_order == default and we shouldn't parse this from dmesg.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#17 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

Quoted 19 lines · David Rientjes
Quoted 7 lines · Anshuman Khandual
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

I'm questioning if this information can be inferred from information already in /proc/zoneinfo and sysfs. We know the no-fallback zonelist is going to include the local node, and we know the other zonelists are either node ordered or zone ordered (or do we need to extend vm.numa_zonelist_order for default?). I may have missed what new knowledge this interface is imparting on us.

Quoted 10 lines
Quoted 10 lines

IIUC /proc/zoneinfo lists down zone internal state and statistics for all zones on the system at any given point of time. The no-fallback list contains the zones from the local node and fallback (which gets used more often than the no-fallback) list contains all zones either in node-ordered or zone-ordered manner. In most of the platforms the default being the node order but the sequence of present nodes in that order is determined by various factors like NUMA distance, load, presence of CPUs on the node etc. This order of nodes in the fallback list is the most important information derived out of this interface.

Quoted 5 lines

The point is that all of this can be inferred with information already provided, so the additional interface seems unnecessary. The only extension I think that is needed is to determine if the order is node or zone when vm.numa_zonelist_order == default and we shouldn't parse this from dmesg.

Okay. Seems like the general view is that this interface is not necessary. Hence wont be posting the debugfs version for now.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#18 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

In reply to Anshuman Khandual
Quoted 5 lines · Anshuman Khandual

Each individual node in the system has a ZONELIST_FALLBACK zonelist and a ZONELIST_NOFALLBACK zonelist. These zonelists decide fallback order of zones during memory allocations. Sometimes it helps to dump these zonelists to see the priority order of various zones in them.

Quoted 10 lines

Particularly platforms which support memory hotplug into previously non existing zones (at boot), this interface helps in visualizing which all zonelists of the system at what priority level, the new hot added memory ends up in. POWER is such a platform where all the memory detected during boot time remains with ZONE_DMA for good but then hot plug process can actually get new memory into ZONE_MOVABLE. So having a way to get the snapshot of the zonelists on the system after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

I am still not sure I understand why this is helpful and who is the consumer for this interface and how it will benefit from the information. Dave (who doesn't seem to be on the CC list re-added) had another objection that this breaks one-value-per-file rule for sysfs files.

This all smells like a debugging feature to me and so it should go into debugfs.

Quoted 161 lines

Example zonelist information from a KVM guest.

[NODE (0)]

        ZONELIST_FALLBACK
                (0) (node 0) (DMA     0xc0000000ffff6300)
                (1) (node 1) (DMA     0xc0000001ffff6300)
                (2) (node 2) (DMA     0xc0000002ffff6300)
                (3) (node 3) (DMA     0xc0000003ffdba300)
        ZONELIST_NOFALLBACK
                (0) (node 0) (DMA     0xc0000000ffff6300)
[NODE (1)]
        ZONELIST_FALLBACK
                (0) (node 1) (DMA     0xc0000001ffff6300)
                (1) (node 2) (DMA     0xc0000002ffff6300)
                (2) (node 3) (DMA     0xc0000003ffdba300)
                (3) (node 0) (DMA     0xc0000000ffff6300)
        ZONELIST_NOFALLBACK
                (0) (node 1) (DMA     0xc0000001ffff6300)
[NODE (2)]
        ZONELIST_FALLBACK
                (0) (node 2) (DMA     0xc0000002ffff6300)
                (1) (node 3) (DMA     0xc0000003ffdba300)
                (2) (node 0) (DMA     0xc0000000ffff6300)
                (3) (node 1) (DMA     0xc0000001ffff6300)
        ZONELIST_NOFALLBACK
                (0) (node 2) (DMA     0xc0000002ffff6300)
[NODE (3)]
        ZONELIST_FALLBACK
                (0) (node 3) (DMA     0xc0000003ffdba300)
                (1) (node 0) (DMA     0xc0000000ffff6300)
                (2) (node 1) (DMA     0xc0000001ffff6300)
                (3) (node 2) (DMA     0xc0000002ffff6300)
        ZONELIST_NOFALLBACK
                (0) (node 3) (DMA     0xc0000003ffdba300)

---
Changes in V4:
- Explicitly included mmzone.h header inside page_alloc.c
- Changed the kernel address printing from %lx to %pK

Changes in V3:
- Moved all these new sysfs code inside CONFIG_NUMA

Changes in V2:
- Added more details into the commit message
- Added sysfs interface file details into the commit message
- Added ../ABI/testing/sysfs-system-zone-details file

 .../ABI/testing/sysfs-system-zone-details          |  9 ++++
 drivers/base/memory.c                              | 52 ++++++++++++++++++++++
 mm/page_alloc.c                                    |  1 +
 3 files changed, 62 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-system-zone-details
Documentation/ABI/testing/sysfs-system-zone-details new file +9 -0
new file mode 100644
index 0000000..9c13b2e
@@ -0,0 +1,9 @@
+What:		/sys/devices/system/memory/system_zone_details
+Date:		Sep 2016
+KernelVersion:	4.8
+Contact:	[email protected]
+Description:
+		This read only file dumps the zonelist and it's constituent
+		zones information for both ZONELIST_FALLBACK and ZONELIST_
+		NOFALLBACK zonelists for each online node of the system at
+		any given point of time.
drivers/base/memory.c +52 -0
index dc75de9..c7ab991 100644
@@ -442,7 +442,56 @@ print_block_size(struct device *dev, struct device_attribute *attr,
 	return sprintf(buf, "%lx\n", get_memory_block_size());
 }
 
+#ifdef CONFIG_NUMA
+static ssize_t dump_zonelist(char *buf, struct zonelist *zonelist)
+{
+	unsigned int i;
+	ssize_t count = 0;
+
+	for (i = 0; zonelist->_zonerefs[i].zone; i++) {
+		count += sprintf(buf + count,
+			"\t\t(%d) (node %d) (%-7s 0x%pK)\n", i,
+			zonelist->_zonerefs[i].zone->zone_pgdat->node_id,
+			zone_names[zonelist->_zonerefs[i].zone_idx],
+			(void *) zonelist->_zonerefs[i].zone);
+	}
+	return count;
+}
+
+static ssize_t dump_zonelists(char *buf)
+{
+	struct zonelist *zonelist;
+	unsigned int node;
+	ssize_t count = 0;
+
+	for_each_online_node(node) {
+		zonelist = &(NODE_DATA(node)->
+				node_zonelists[ZONELIST_FALLBACK]);
+		count += sprintf(buf + count, "[NODE (%d)]\n", node);
+		count += sprintf(buf + count, "\tZONELIST_FALLBACK\n");
+		count += dump_zonelist(buf + count, zonelist);
+
+		zonelist = &(NODE_DATA(node)->
+				node_zonelists[ZONELIST_NOFALLBACK]);
+		count += sprintf(buf + count, "\tZONELIST_NOFALLBACK\n");
+		count += dump_zonelist(buf + count, zonelist);
+	}
+	return count;
+}
+
+static ssize_t
+print_system_zone_details(struct device *dev, struct device_attribute *attr,
+		 char *buf)
+{
+	return dump_zonelists(buf);
+}
+#endif
+
+
 static DEVICE_ATTR(block_size_bytes, 0444, print_block_size, NULL);
+#ifdef CONFIG_NUMA
+static DEVICE_ATTR(system_zone_details, 0444, print_system_zone_details, NULL);
+#endif
 
 /*
  * Memory auto online policy.
@@ -783,6 +832,9 @@ static struct attribute *memory_root_attrs[] = {
 #endif
 
 	&dev_attr_block_size_bytes.attr,
+#ifdef CONFIG_NUMA
+	&dev_attr_system_zone_details.attr,
+#endif
 	&dev_attr_auto_online_blocks.attr,
 	NULL
 };
mm/page_alloc.c +1 -0
index a2214c6..d3da022 100644
@@ -64,6 +64,7 @@
 #include <linux/page_owner.h>
 #include <linux/kthread.h>
 #include <linux/memcontrol.h>
+#include <linux/mmzone.h>
 
 #include <asm/sections.h>
 #include <asm/tlbflush.h>
Signature · 7 lines
2.1.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#19 lore raw

Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

Quoted 16 lines · Michal Hocko
Quoted 5 lines · Anshuman Khandual
Quoted 5 lines

Each individual node in the system has a ZONELIST_FALLBACK zonelist and a ZONELIST_NOFALLBACK zonelist. These zonelists decide fallback order of zones during memory allocations. Sometimes it helps to dump these zonelists to see the priority order of various zones in them.

Quoted 10 lines
Quoted 10 lines

Particularly platforms which support memory hotplug into previously non existing zones (at boot), this interface helps in visualizing which all zonelists of the system at what priority level, the new hot added memory ends up in. POWER is such a platform where all the memory detected during boot time remains with ZONE_DMA for good but then hot plug process can actually get new memory into ZONE_MOVABLE. So having a way to get the snapshot of the zonelists on the system after memory or node hot[un]plug is desirable. This change adds one new sysfs interface (/sys/devices/system/memory/system_zone_details) which will fetch and dump this information.

Quoted 5 lines

I am still not sure I understand why this is helpful and who is the consumer for this interface and how it will benefit from the information. Dave (who doesn't seem to be on the CC list re-added) had another objection that this breaks one-value-per-file rule for sysfs files.

It helps in understanding the relative priority of each memory zone of the system during various allocation scenarios. Its particularly helpful after hotplug/unplug of additional memory into previously non existing zone on a node.

Quoted 3 lines

This all smells like a debugging feature to me and so it should go into debugfs.

Sure, will make it a debugfs interface.