Skip to contentSkip to conversation

show_mem updates

PATCH Superseded Michal Hocko 8 participants 19 messages Jan 12, 2017 – Jan 14, 2017

Subsystems (13)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#8 lore raw

RFC PATCH 3/4 arch, mm: remove arch specific show_mem

In reply to Michal Hocko

From: Michal Hocko <[email protected]>

We have a generic implementation for quite some time already. If there is any arch specific information to be printed then we should add a callback called from the generic code rather than duplicate the whole show_mem. The current code has resulted in the code duplication and the output divergence which is both confusing and adds maintainance costs. Let's just get rid of this mess.

Cc Tony Luck <[email protected]>
Cc Fenghua Yu <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Chris Metcalf <[email protected]>
Cc Guan Xuetao <[email protected]>
---
 arch/ia64/mm/init.c      | 48 -----------------------------------------------
 arch/parisc/mm/init.c    | 49 ------------------------------------------------
 arch/sparc/mm/init_32.c  | 11 -----------
 arch/tile/mm/pgtable.c   | 45 --------------------------------------------
 arch/unicore32/mm/init.c | 44 -------------------------------------------
 5 files changed, 197 deletions(-)
arch/ia64/mm/init.c +0 -48
index 1841ef69183d..46afc8d5ebfc 100644
@@ -684,51 +684,3 @@ int arch_remove_memory(u64 start, u64 size)
 }
 #endif
 #endif
-
-/**
- * show_mem - give short summary of memory stats
- *
- * Shows a simple page count of reserved and used pages in the system.
- * For discontig machines, it does this on a per-pgdat basis.
- */
-void show_mem(unsigned int filter)
-{
-	int total_reserved = 0;
-	unsigned long total_present = 0;
-	pg_data_t *pgdat;
-
-	printk(KERN_INFO "Mem-info:\n");
-	show_free_areas(filter);
-	printk(KERN_INFO "Node memory in pages:\n");
-	for_each_online_pgdat(pgdat) {
-		unsigned long present;
-		unsigned long flags;
-		int reserved = 0;
-		int nid = pgdat->node_id;
-		int zoneid;
-
-		if (skip_free_areas_node(filter, nid))
-			continue;
-		pgdat_resize_lock(pgdat, &flags);
-
-		for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
-			struct zone *zone = &pgdat->node_zones[zoneid];
-			if (!populated_zone(zone))
-				continue;
-
-			reserved += zone->present_pages - zone->managed_pages;
-		}
-		present = pgdat->node_present_pages;
-
-		pgdat_resize_unlock(pgdat, &flags);
-		total_present += present;
-		total_reserved += reserved;
-		printk(KERN_INFO "Node %4d:  RAM: %11ld, rsvd: %8d, ",
-		       nid, present, reserved);
-	}
-	printk(KERN_INFO "%ld pages of RAM\n", total_present);
-	printk(KERN_INFO "%d reserved pages\n", total_reserved);
-	printk(KERN_INFO "Total of %ld pages in page table cache\n",
-	       quicklist_total_size());
-	printk(KERN_INFO "%ld free buffer pages\n", nr_free_buffer_pages());
-}
arch/parisc/mm/init.c +0 -49

55 lines not on this page · raw message

arch/sparc/mm/init_32.c +0 -11
index eb8287155279..c6afe98de4d9 100644
@@ -55,17 +55,6 @@ extern unsigned int sparc_ramdisk_size;
 
 unsigned long highstart_pfn, highend_pfn;
 
-void show_mem(unsigned int filter)
-{
-	printk("Mem-info:\n");
-	show_free_areas(filter);
-	printk("Free swap:       %6ldkB\n",
-	       get_nr_swap_pages() << (PAGE_SHIFT-10));
-	printk("%ld pages of RAM\n", totalram_pages);
-	printk("%ld free pages\n", nr_free_pages());
-}
-
-
 unsigned long last_valid_pfn;
 
 unsigned long calc_highpages(void)
arch/tile/mm/pgtable.c +0 -45

51 lines not on this page · raw message

arch/unicore32/mm/init.c +0 -44

50 lines not on this page · raw message

Signature · 1 line
2.11.0
#0 lore raw

cover show_mem updates

Hi,
this is a mixture of one bug fix (patch 1), an enhancement (patch 2) and cleanups (the rest of the series). First two patches should be really straightforward. Patch 3 removes some arch specific show_mem implementations because I think they are quite outdated and do not really serve any useful purpose anymore. I might be missing something which is why this patch is RFC. I think we should really strive to have a consistent show_mem output regardless of the architecture. If some architecture is really special and wants to dump something additional we should do that via an arch specific hook.
The last patch adds nodemask parameter so that we do not rely on the hardcoded mems_allowed of the current task when doing the node filtering. I consider this more a cleanup than a fix because basically all users use a nodemask which is a subset of mems_allowed. There is only one call path in the memory hotplug which doesn't comply with this but that is hardly something to worry about.

Thoughts, comments?

Michal Hocko (4):
mm, page_alloc: do not report all nodes in show_mem mm, page_alloc: warn_alloc print nodemask
arch, mm: remove arch specific show_mem lib/show_mem.c: teach show_mem to work with the given nodemask

 arch/ia64/mm/init.c                 | 48 ------------------------------------
 arch/parisc/mm/init.c               | 49 -------------------------------------
 arch/powerpc/xmon/xmon.c            |  2 +-
 arch/sparc/kernel/setup_32.c        |  2 +-
 arch/sparc/mm/init_32.c             | 11 ---------
 arch/tile/mm/pgtable.c              | 45 ----------------------------------
 arch/unicore32/mm/init.c            | 44 ---------------------------------
 drivers/net/ethernet/sgi/ioc3-eth.c |  2 +-
 drivers/tty/sysrq.c                 |  2 +-
 drivers/tty/vt/keyboard.c           |  2 +-
 include/linux/mm.h                  |  9 +++----
 lib/show_mem.c                      |  4 +--
 mm/nommu.c                          |  6 ++---
 mm/oom_kill.c                       |  2 +-
 mm/page_alloc.c                     | 48 +++++++++++++++++++-----------------
 mm/vmalloc.c                        |  4 +--
 16 files changed, 43 insertions(+), 237 deletions(-)

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

#1 lore raw

PATCH 1/4 mm, page_alloc: do not report all nodes in show_mem

From: Michal Hocko <[email protected]>

599d0c954f91 ("mm, vmscan: move LRU lists to node") has added per numa node statistics to show_mem but it forgot to add skip_free_areas_node to fileter out nodes which are outside of the allocating task numa policy. Add this check to not pollute the output with the pointless information.

---
 mm/page_alloc.c | 3 +++
 1 file changed, 3 insertions(+)
mm/page_alloc.c +3 -0
index 8ff25883c172..8f4f306d804c 100644
@@ -4345,6 +4345,9 @@ void show_free_areas(unsigned int filter)
 		global_page_state(NR_FREE_CMA_PAGES));
 
 	for_each_online_pgdat(pgdat) {
+		if (skip_free_areas_node(filter, pgdat->node_id))
+			continue;
+
 		printk("Node %d"
 			" active_anon:%lukB"
 			" inactive_anon:%lukB"
Signature · 7 lines
2.11.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>
#4 lore raw

PATCH 2/4 mm, page_alloc: warn_alloc print nodemask

In reply to Michal Hocko

From: Michal Hocko <[email protected]>

warn_alloc is currently used for to report an allocation failure or an allocation stall. We print some details of the allocation request like the gfp mask and the request order. We do not print the allocation nodemask which is important when debugging the reason for the allocation failure as well. We alreaddy print the nodemask in the OOM report.

Add nodemask to warn_alloc and print it in warn_alloc as well.

---
 include/linux/mm.h | 4 ++--
 mm/page_alloc.c    | 9 +++++----
 mm/vmalloc.c       | 4 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)
include/linux/mm.h +2 -2
index 57dc3c3b53c1..3e35eb04a28a 100644
@@ -1912,8 +1912,8 @@ extern void si_meminfo_node(struct sysinfo *val, int nid);
 extern unsigned long arch_reserved_kernel_pages(void);
 #endif
 
-extern __printf(2, 3)
-void warn_alloc(gfp_t gfp_mask, const char *fmt, ...);
+extern __printf(3, 4)
+void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...);
 
 extern void setup_per_cpu_pageset(void);
 
mm/page_alloc.c +5 -4
index 8f4f306d804c..0a9805a696bb 100644
@@ -3031,12 +3031,13 @@ static void warn_alloc_show_mem(gfp_t gfp_mask)
 	show_mem(filter);
 }
 
-void warn_alloc(gfp_t gfp_mask, const char *fmt, ...)
+void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
 	static DEFINE_RATELIMIT_STATE(nopage_rs, DEFAULT_RATELIMIT_INTERVAL,
 				      DEFAULT_RATELIMIT_BURST);
+	nodemask_t *nm = (nodemask) ? nodemask : &cpuset_current_mems_allowed;
 
 	if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs) ||
 	    debug_guardpage_minorder() > 0)
@@ -3050,7 +3051,7 @@ void warn_alloc(gfp_t gfp_mask, const char *fmt, ...)
 	pr_cont("%pV", &vaf);
 	va_end(args);
 
-	pr_cont(", mode:%#x(%pGg)\n", gfp_mask, &gfp_mask);
+	pr_cont(", mode:%#x(%pGg), nodemask=%*pbl\n", gfp_mask, &gfp_mask, nodemask_pr_args(nm));
 
 	dump_stack();
 	warn_alloc_show_mem(gfp_mask);
@@ -3709,7 +3710,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
 
 	/* Make sure we know about allocations which stall for too long */
 	if (time_after(jiffies, alloc_start + stall_timeout)) {
-		warn_alloc(gfp_mask,
+		warn_alloc(gfp_mask, ac->nodemask,
 			"page allocation stalls for %ums, order:%u",
 			jiffies_to_msecs(jiffies-alloc_start), order);
 		stall_timeout += 10 * HZ;
@@ -3743,7 +3744,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
 	}
 
 nopage:
-	warn_alloc(gfp_mask,
+	warn_alloc(gfp_mask, ac->nodemask,
 			"page allocation failure: order:%u", order);
 got_pg:
 	return page;
mm/vmalloc.c +2 -2
index b9999fc44aa6..0600bbbd1080 100644
@@ -1662,7 +1662,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 	return area->addr;
 
 fail:
-	warn_alloc(gfp_mask,
+	warn_alloc(gfp_mask, NULL,
 			  "vmalloc: allocation failure, allocated %ld of %ld bytes",
 			  (area->nr_pages*PAGE_SIZE), area->size);
 	vfree(area->addr);
@@ -1724,7 +1724,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
 	return addr;
 
 fail:
-	warn_alloc(gfp_mask,
+	warn_alloc(gfp_mask, NULL,
 			  "vmalloc: allocation failure: %lu bytes", real_size);
 	return NULL;
 }
Signature · 7 lines
2.11.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>
#14 lore raw

PATCH 4/4 lib/show_mem.c: teach show_mem to work with the given nodemask

In reply to Michal Hocko

From: Michal Hocko <[email protected]>

show_mem() allows to filter out node specific data which is irrelevant to the allocation request via SHOW_MEM_FILTER_NODES. The filtering is done in skip_free_areas_node which skips all nodes which are not in the mems_allowed of the current process. This works most of the time as expected because the nodemask shouldn't be outside of the allocating task but there are some exceptions. E.g. memory hotplug might want to request allocations from outside of the allowed nodes (see new_node_page).

Get rid of this hardcoded behavior and push the allocation mask down the show_mem path and use it instead of cpuset_current_mems_allowed. NULL nodemask is interpreted as cpuset_current_mems_allowed.

---
 arch/powerpc/xmon/xmon.c            |  2 +-
 arch/sparc/kernel/setup_32.c        |  2 +-
 drivers/net/ethernet/sgi/ioc3-eth.c |  2 +-
 drivers/tty/sysrq.c                 |  2 +-
 drivers/tty/vt/keyboard.c           |  2 +-
 include/linux/mm.h                  |  5 ++---
 lib/show_mem.c                      |  4 ++--
 mm/nommu.c                          |  6 +++---
 mm/oom_kill.c                       |  2 +-
 mm/page_alloc.c                     | 38 ++++++++++++++++++-------------------
 10 files changed, 32 insertions(+), 33 deletions(-)
arch/powerpc/xmon/xmon.c +1 -1
index 760545519a0b..e285a89a65ec 100644
@@ -913,7 +913,7 @@ cmds(struct pt_regs *excp)
 				memzcan();
 				break;
 			case 'i':
-				show_mem(0);
+				show_mem(0, NULL);
 				break;
 			default:
 				termch = cmd;
arch/sparc/kernel/setup_32.c +1 -1
index c4e65cb3280f..6f06058c5ae7 100644
@@ -82,7 +82,7 @@ static void prom_sync_me(void)
 			     "nop\n\t" : : "r" (&trapbase));
 
 	prom_printf("PROM SYNC COMMAND...\n");
-	show_free_areas(0);
+	show_free_areas(0, NULL);
 	if (!is_idle_task(current)) {
 		local_irq_enable();
 		sys_sync();
drivers/net/ethernet/sgi/ioc3-eth.c +1 -1
index 7a254da85dd7..231e96d8bd14 100644
@@ -914,7 +914,7 @@ static void ioc3_alloc_rings(struct net_device *dev)
 
 			skb = ioc3_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC);
 			if (!skb) {
-				show_free_areas(0);
+				show_free_areas(0, NULL);
 				continue;
 			}
 
drivers/tty/sysrq.c +1 -1
index 52bbd27e93ae..667fa3931161 100644
@@ -317,7 +317,7 @@ static struct sysrq_key_op sysrq_ftrace_dump_op = {
 
 static void sysrq_handle_showmem(int key)
 {
-	show_mem(0);
+	show_mem(0, NULL);
 }
 static struct sysrq_key_op sysrq_showmem_op = {
 	.handler	= sysrq_handle_showmem,
drivers/tty/vt/keyboard.c +1 -1
index 0f8caae4267d..09511a362ade 100644
@@ -572,7 +572,7 @@ static void fn_scroll_back(struct vc_data *vc)
 
 static void fn_show_mem(struct vc_data *vc)
 {
-	show_mem(0);
+	show_mem(0, NULL);
 }
 
 static void fn_show_state(struct vc_data *vc)
include/linux/mm.h +2 -3
index 3e35eb04a28a..95488f901c6f 100644
@@ -1124,8 +1124,7 @@ extern void pagefault_out_of_memory(void);
  */
 #define SHOW_MEM_FILTER_NODES		(0x0001u)	/* disallowed nodes */
 
-extern void show_free_areas(unsigned int flags);
-extern bool skip_free_areas_node(unsigned int flags, int nid);
+extern void show_free_areas(unsigned int flags, nodemask_t *nodemask);
 
 int shmem_zero_setup(struct vm_area_struct *);
 #ifdef CONFIG_SHMEM
@@ -1904,7 +1903,7 @@ extern void setup_per_zone_wmarks(void);
 extern int __meminit init_per_zone_wmark_min(void);
 extern void mem_init(void);
 extern void __init mmap_init(void);
-extern void show_mem(unsigned int flags);
+extern void show_mem(unsigned int flags, nodemask_t *nodemask);
 extern long si_mem_available(void);
 extern void si_meminfo(struct sysinfo * val);
 extern void si_meminfo_node(struct sysinfo *val, int nid);
lib/show_mem.c +2 -2
index 1feed6a2b12a..0beaa1d899aa 100644
@@ -9,13 +9,13 @@
 #include <linux/quicklist.h>
 #include <linux/cma.h>
 
-void show_mem(unsigned int filter)
+void show_mem(unsigned int filter, nodemask_t *nodemask)
 {
 	pg_data_t *pgdat;
 	unsigned long total = 0, reserved = 0, highmem = 0;
 
 	printk("Mem-Info:\n");
-	show_free_areas(filter);
+	show_free_areas(filter, nodemask);
 
 	for_each_online_pgdat(pgdat) {
 		unsigned long flags;
mm/nommu.c +3 -3
index ca239988fb68..5bd401b7f9a9 100644
@@ -1191,7 +1191,7 @@ static int do_mmap_private(struct vm_area_struct *vma,
 enomem:
 	pr_err("Allocation of length %lu from process %d (%s) failed\n",
 	       len, current->pid, current->comm);
-	show_free_areas(0);
+	show_free_areas(0, NULL);
 	return -ENOMEM;
 }
 
@@ -1412,13 +1412,13 @@ unsigned long do_mmap(struct file *file,
 	kmem_cache_free(vm_region_jar, region);
 	pr_warn("Allocation of vma for %lu byte allocation from process %d failed\n",
 			len, current->pid);
-	show_free_areas(0);
+	show_free_areas(0, NULL);
 	return -ENOMEM;
 
 error_getting_region:
 	pr_warn("Allocation of vm region for %lu byte allocation from process %d failed\n",
 			len, current->pid);
-	show_free_areas(0);
+	show_free_areas(0, NULL);
 	return -ENOMEM;
 }
 
mm/oom_kill.c +1 -1
index ead093c6f2a6..7cf61b928ba8 100644
@@ -417,7 +417,7 @@ static void dump_header(struct oom_control *oc, struct task_struct *p)
 	if (oc->memcg)
 		mem_cgroup_print_oom_info(oc->memcg, p);
 	else
-		show_mem(SHOW_MEM_FILTER_NODES);
+		show_mem(SHOW_MEM_FILTER_NODES, nm);
 	if (sysctl_oom_dump_tasks)
 		dump_tasks(oc->memcg, oc->nodemask);
 }
mm/page_alloc.c +19 -19
index 0a9805a696bb..44ba8b27a2b1 100644
@@ -3008,7 +3008,7 @@ static inline bool should_suppress_show_mem(void)
 	return ret;
 }
 
-static void warn_alloc_show_mem(gfp_t gfp_mask)
+static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask)
 {
 	unsigned int filter = SHOW_MEM_FILTER_NODES;
 	static DEFINE_RATELIMIT_STATE(show_mem_rs, HZ, 1);
@@ -3028,7 +3028,7 @@ static void warn_alloc_show_mem(gfp_t gfp_mask)
 	if (in_interrupt() || !(gfp_mask & __GFP_DIRECT_RECLAIM))
 		filter &= ~SHOW_MEM_FILTER_NODES;
 
-	show_mem(filter);
+	show_mem(filter, nodemask);
 }
 
 void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
@@ -3054,7 +3054,7 @@ void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
 	pr_cont(", mode:%#x(%pGg), nodemask=%*pbl\n", gfp_mask, &gfp_mask, nodemask_pr_args(nm));
 
 	dump_stack();
-	warn_alloc_show_mem(gfp_mask);
+	warn_alloc_show_mem(gfp_mask, nm);
 }
 
 static inline struct page *
@@ -4250,20 +4250,20 @@ void si_meminfo_node(struct sysinfo *val, int nid)
  * Determine whether the node should be displayed or not, depending on whether
  * SHOW_MEM_FILTER_NODES was passed to show_free_areas().
  */
-bool skip_free_areas_node(unsigned int flags, int nid)
+static bool show_mem_node_skip(unsigned int flags, int nid, nodemask_t *nodemask)
 {
-	bool ret = false;
-	unsigned int cpuset_mems_cookie;
-
 	if (!(flags & SHOW_MEM_FILTER_NODES))
-		goto out;
+		return false;
 
-	do {
-		cpuset_mems_cookie = read_mems_allowed_begin();
-		ret = !node_isset(nid, cpuset_current_mems_allowed);
-	} while (read_mems_allowed_retry(cpuset_mems_cookie));
-out:
-	return ret;
+	/*
+	 * no node mask - aka implicit memory numa policy. Do not bother with the
+	 * synchronization - read_mems_allowed_begin - because we do not have to be
+	 * precise here.
+	 */
+	if (!nodemask)
+		nodemask = &cpuset_current_mems_allowed;
+
+	return !node_isset(nid, *nodemask);
 }
 
 #define K(x) ((x) << (PAGE_SHIFT-10))
@@ -4304,7 +4304,7 @@ static void show_migration_types(unsigned char type)
  * SHOW_MEM_FILTER_NODES: suppress nodes that are not allowed by current's
  *   cpuset.
  */
-void show_free_areas(unsigned int filter)
+void show_free_areas(unsigned int filter, nodemask_t *nodemask)
 {
 	unsigned long free_pcp = 0;
 	int cpu;
@@ -4312,7 +4312,7 @@ void show_free_areas(unsigned int filter)
 	pg_data_t *pgdat;
 
 	for_each_populated_zone(zone) {
-		if (skip_free_areas_node(filter, zone_to_nid(zone)))
+		if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask))
 			continue;
 
 		for_each_online_cpu(cpu)
@@ -4346,7 +4346,7 @@ void show_free_areas(unsigned int filter)
 		global_page_state(NR_FREE_CMA_PAGES));
 
 	for_each_online_pgdat(pgdat) {
-		if (skip_free_areas_node(filter, pgdat->node_id))
+		if (show_mem_node_skip(filter, pgdat->node_id, nodemask))
 			continue;
 
 		printk("Node %d"
@@ -4398,7 +4398,7 @@ void show_free_areas(unsigned int filter)
 	for_each_populated_zone(zone) {
 		int i;
 
-		if (skip_free_areas_node(filter, zone_to_nid(zone)))
+		if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask))
 			continue;
 
 		free_pcp = 0;
@@ -4463,7 +4463,7 @@ void show_free_areas(unsigned int filter)
 		unsigned long nr[MAX_ORDER], flags, total = 0;
 		unsigned char types[MAX_ORDER];
 
-		if (skip_free_areas_node(filter, zone_to_nid(zone)))
+		if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask))
 			continue;
 		show_node(zone);
 		printk(KERN_CONT "%s: ", zone->name);
Signature · 7 lines
2.11.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>
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] mm, page_alloc: do not report all nodes in show_mem

In reply to Michal Hocko
Quoted 9 lines · Michal Hocko

From: Michal Hocko <[email protected]>

599d0c954f91 ("mm, vmscan: move LRU lists to node") has added per numa node statistics to show_mem but it forgot to add skip_free_areas_node to fileter out nodes which are outside of the allocating task numa policy. Add this check to not pollute the output with the pointless information.

Signature · 8 lines
Mel Gorman
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>
Acked-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] mm, page_alloc: warn_alloc print nodemask

In reply to Michal Hocko
Quoted 11 lines · Michal Hocko

From: Michal Hocko <[email protected]>

warn_alloc is currently used for to report an allocation failure or an allocation stall. We print some details of the allocation request like the gfp mask and the request order. We do not print the allocation nodemask which is important when debugging the reason for the allocation failure as well. We alreaddy print the nodemask in the OOM report.

Add nodemask to warn_alloc and print it in warn_alloc as well.

Signature · 8 lines
Mel Gorman
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>
Acked-by on v1 3/4
#9 lore raw

Re: [RFC PATCH 3/4] arch, mm: remove arch specific show_mem

In reply to Michal Hocko
Quoted 9 lines · Michal Hocko

From: Michal Hocko <[email protected]>

We have a generic implementation for quite some time already. If there is any arch specific information to be printed then we should add a callback called from the generic code rather than duplicate the whole show_mem. The current code has resulted in the code duplication and the output divergence which is both confusing and adds maintainance costs. Let's just get rid of this mess.

Quoted 10 lines
Cc Tony Luck <[email protected]>
Cc Fenghua Yu <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Chris Metcalf <[email protected]>
Cc Guan Xuetao <[email protected]>

This is overdue. The last time it was brought up, no one objected to arch-specific information from show_mem but maybe they weren't looking that carefully. For me;

Signature · 2 lines
Mel Gorman
SUSE Labs
Acked-by on v1 4/4
#15 lore raw

Re: [PATCH 4/4] lib/show_mem.c: teach show_mem to work with the given nodemask

In reply to Michal Hocko
Quoted 11 lines · Michal Hocko

From: Michal Hocko <[email protected]>

show_mem() allows to filter out node specific data which is irrelevant to the allocation request via SHOW_MEM_FILTER_NODES. The filtering is done in skip_free_areas_node which skips all nodes which are not in the mems_allowed of the current process. This works most of the time as expected because the nodemask shouldn't be outside of the allocating task but there are some exceptions. E.g. memory hotplug might want to request allocations from outside of the allowed nodes (see new_node_page).

Quoted 5 lines

Get rid of this hardcoded behavior and push the allocation mask down the show_mem path and use it instead of cpuset_current_mems_allowed. NULL nodemask is interpreted as cpuset_current_mems_allowed.

Fairly marginal but

Signature · 8 lines
Mel Gorman
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>
Acked-by on v1 3/4
#10 lore raw

Re: [RFC PATCH 3/4] arch, mm: remove arch specific show_mem

In reply to Michal Hocko
Quoted 19 lines · Michal Hocko

From: Michal Hocko<[email protected]>

We have a generic implementation for quite some time already. If there is any arch specific information to be printed then we should add a callback called from the generic code rather than duplicate the whole show_mem. The current code has resulted in the code duplication and the output divergence which is both confusing and adds maintainance costs. Let's just get rid of this mess.

Cc Tony Luck<[email protected]>
Cc Fenghua Yu<[email protected]>
Cc "James E.J. Bottomley"<[email protected]>
Cc Helge Deller<[email protected]>
Cc "David S. Miller"<[email protected]>
Cc Chris Metcalf<[email protected]>
Cc Guan Xuetao<[email protected]>
Quoted 7 lines
---
  arch/ia64/mm/init.c      | 48 -----------------------------------------------
  arch/parisc/mm/init.c    | 49 ------------------------------------------------
  arch/sparc/mm/init_32.c  | 11 -----------
  arch/tile/mm/pgtable.c   | 45 --------------------------------------------
  arch/unicore32/mm/init.c | 44 -------------------------------------------
  5 files changed, 197 deletions(-)
Signature · 2 lines
Chris Metcalf, Mellanox Technologies
http://www.mellanox.com
maintainer Acked-by on v1 3/4
#11 lore raw

Re: [RFC PATCH 3/4] arch, mm: remove arch specific show_mem

In reply to Michal Hocko
Quoted 19 lines · Michal Hocko

From: Michal Hocko <[email protected]>

We have a generic implementation for quite some time already. If there is any arch specific information to be printed then we should add a callback called from the generic code rather than duplicate the whole show_mem. The current code has resulted in the code duplication and the output divergence which is both confusing and adds maintainance costs. Let's just get rid of this mess.

Cc Tony Luck <[email protected]>
Cc Fenghua Yu <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Chris Metcalf <[email protected]>
Cc Guan Xuetao <[email protected]>
Quoted 7 lines
---
 arch/ia64/mm/init.c      | 48 -----------------------------------------------
 arch/parisc/mm/init.c    | 49 ------------------------------------------------
 arch/sparc/mm/init_32.c  | 11 -----------
 arch/tile/mm/pgtable.c   | 45 --------------------------------------------
 arch/unicore32/mm/init.c | 44 -------------------------------------------
 5 files changed, 197 deletions(-)

Thanks!

Acked-by on v1 3/4
#12 lore raw

Re: [RFC PATCH 3/4] arch, mm: remove arch specific show_mem

In reply to Michal Hocko
Quoted 19 lines

From: Michal Hocko <[email protected]>

We have a generic implementation for quite some time already. If there is any arch specific information to be printed then we should add a callback called from the generic code rather than duplicate the whole show_mem. The current code has resulted in the code duplication and the output divergence which is both confusing and adds maintainance costs. Let's just get rid of this mess.

Cc Tony Luck <[email protected]>
Cc Fenghua Yu <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Chris Metcalf <[email protected]>
Cc Guan Xuetao <[email protected]>
Quoted 10 lines
---
 arch/ia64/mm/init.c      | 48
-----------------------------------------------
 arch/parisc/mm/init.c    | 49
------------------------------------------------
 arch/sparc/mm/init_32.c  | 11 -----------
 arch/tile/mm/pgtable.c   | 45
--------------------------------------------
 arch/unicore32/mm/init.c | 44 -------------------------------------------
 5 files changed, 197 deletions(-)

For UniCore32:

Thanks.

#6 lore raw

Re: [PATCH 2/4] mm, page_alloc: warn_alloc print nodemask

In reply to Michal Hocko
Quoted 9 lines · Michal Hocko

From: Michal Hocko <[email protected]>

warn_alloc is currently used for to report an allocation failure or an allocation stall. We print some details of the allocation request like the gfp mask and the request order. We do not print the allocation nodemask which is important when debugging the reason for the allocation failure as well. We alreaddy print the nodemask in the OOM report.

Add nodemask to warn_alloc and print it in warn_alloc as well.

That's helpful, but still IMHO incomplete compared to oom killer, see below.

Quoted 4 lines
mm/page_alloc.c +0 -0
@@ -3031,12 +3031,13 @@ static void warn_alloc_show_mem(gfp_t gfp_mask)
 	show_mem(filter);

mm/page_alloc.c static void warn_alloc_show_mem(gfp_t gfp_mask) · line 3040

Quoted 10 lines
mm/page_alloc.c +2 -1
 }
 
-void warn_alloc(gfp_t gfp_mask, const char *fmt, ...)
+void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
 	static DEFINE_RATELIMIT_STATE(nopage_rs, DEFAULT_RATELIMIT_INTERVAL,
 				      DEFAULT_RATELIMIT_BURST);
+	nodemask_t *nm = (nodemask) ? nodemask : &cpuset_current_mems_allowed;

Yes that's same as oom's dump_header() does it. But what if there's both mempolicy nodemask and cpuset at play? From oom report you'll see that as it also calls cpuset_print_current_mems_allowed(). So could we do that here as well?

Thanks.

--
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 4/4] lib/show_mem.c: teach show_mem to work with the given nodemask

In reply to Michal Hocko
Quoted 10 lines · Michal Hocko

From: Michal Hocko <[email protected]>

show_mem() allows to filter out node specific data which is irrelevant to the allocation request via SHOW_MEM_FILTER_NODES. The filtering is done in skip_free_areas_node which skips all nodes which are not in the mems_allowed of the current process. This works most of the time as expected because the nodemask shouldn't be outside of the allocating task but there are some exceptions. E.g. memory hotplug might want to request allocations from outside of the allowed nodes (see new_node_page).

Hm AFAICS memory hotplug's new_node_page() is restricted both by cpusets (by using GFP_USER), and by the nodemask it constructs. That's probably a bug in itself, as it shouldn't matter which task is triggering the offline?

Which probably means that if show_mem() wants to be really precise, it would have to start from nodemask and intersect with cpuset when the allocation in question cannot escape it. But if we accept that it's ok when we print too many nodes (because we can filter them out when reading the output by having also nodemask and mems_allowed printed), and strive only to not miss any nodes, then this patch could really fix cases when we do miss (although new_node_page() currently isn't such example).

Or am I wrong?

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

maintainer
#7 lore raw

Re: [PATCH 2/4] mm, page_alloc: warn_alloc print nodemask

In reply to Vlastimil Babka
Quoted 19 lines · Vlastimil Babka
Quoted 9 lines · Michal Hocko

From: Michal Hocko <[email protected]>

warn_alloc is currently used for to report an allocation failure or an allocation stall. We print some details of the allocation request like the gfp mask and the request order. We do not print the allocation nodemask which is important when debugging the reason for the allocation failure as well. We alreaddy print the nodemask in the OOM report.

Add nodemask to warn_alloc and print it in warn_alloc as well.

That's helpful, but still IMHO incomplete compared to oom killer, see below.

Quoted 6 lines
mm/page_alloc.c +0 -0
@@ -3031,12 +3031,13 @@ static void warn_alloc_show_mem(gfp_t gfp_mask)
 	show_mem(filter);
 }
 
Quoted 13 lines

mm/page_alloc.c static void warn_alloc_show_mem(gfp_t gfp_mask) · line 3040

Quoted 8 lines
mm/page_alloc.c +2 -1
-void warn_alloc(gfp_t gfp_mask, const char *fmt, ...)
+void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
 	static DEFINE_RATELIMIT_STATE(nopage_rs, DEFAULT_RATELIMIT_INTERVAL,
 				      DEFAULT_RATELIMIT_BURST);
+	nodemask_t *nm = (nodemask) ? nodemask : &cpuset_current_mems_allowed;

Yes that's same as oom's dump_header() does it. But what if there's both mempolicy nodemask and cpuset at play? From oom report you'll see that as it also calls cpuset_print_current_mems_allowed(). So could we do that here as well?

OK, I will add it. It cannot be harmful.

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>
maintainer
#17 lore raw

Re: [PATCH 4/4] lib/show_mem.c: teach show_mem to work with the given nodemask

In reply to Vlastimil Babka
Quoted 12 lines · Vlastimil Babka
Quoted 10 lines · Michal Hocko

From: Michal Hocko <[email protected]>

show_mem() allows to filter out node specific data which is irrelevant to the allocation request via SHOW_MEM_FILTER_NODES. The filtering is done in skip_free_areas_node which skips all nodes which are not in the mems_allowed of the current process. This works most of the time as expected because the nodemask shouldn't be outside of the allocating task but there are some exceptions. E.g. memory hotplug might want to request allocations from outside of the allowed nodes (see new_node_page).

Quoted 3 lines

Hm AFAICS memory hotplug's new_node_page() is restricted both by cpusets (by using GFP_USER), and by the nodemask it constructs. That's probably a bug in itself, as it shouldn't matter which task is triggering the offline?

yes that is true. A task bound to a node which is offlined would be funny...

Quoted 7 lines

Which probably means that if show_mem() wants to be really precise, it would have to start from nodemask and intersect with cpuset when the allocation in question cannot escape it. But if we accept that it's ok when we print too many nodes (because we can filter them out when reading the output by having also nodemask and mems_allowed printed), and strive only to not miss any nodes, then this patch could really fix cases when we do miss (although new_node_page() currently isn't such example).

I guess it should be sufficient to add cpuset_print_current_mems_allowed() in warn_alloc. This should give us the full picture without doing too much twiddling. What do you think?

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>
#18 lore raw

Re: [PATCH 4/4] lib/show_mem.c: teach show_mem to work with the given nodemask

Quoted 3 lines · Michal Hocko

I guess it should be sufficient to add cpuset_print_current_mems_allowed() in warn_alloc. This should give us the full picture without doing too much twiddling. What do you think?

Agree!

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

reviewer Acked-by on v1 1/4
#3 lore raw

Re: [PATCH 1/4] mm, page_alloc: do not report all nodes in show_mem

In reply to Michal Hocko
Quoted 9 lines · Michal Hocko

From: Michal Hocko <[email protected]>

599d0c954f91 ("mm, vmscan: move LRU lists to node") has added per numa node statistics to show_mem but it forgot to add skip_free_areas_node to fileter out nodes which are outside of the allocating task numa policy. Add this check to not pollute the output with the pointless information.

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

reviewer Acked-by on v1 3/4
#13 lore raw

Re: [RFC PATCH 3/4] arch, mm: remove arch specific show_mem

In reply to Michal Hocko
Quoted 9 lines · Michal Hocko

From: Michal Hocko <[email protected]>

We have a generic implementation for quite some time already. If there is any arch specific information to be printed then we should add a callback called from the generic code rather than duplicate the whole show_mem. The current code has resulted in the code duplication and the output divergence which is both confusing and adds maintainance costs. Let's just get rid of this mess.

Quoted 10 lines
Cc Tony Luck <[email protected]>
Cc Fenghua Yu <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Chris Metcalf <[email protected]>
Cc Guan Xuetao <[email protected]>