Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1560363 > unrolled thread

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

Started byMichal Hocko <mhocko@kernel.org>
First post2017-01-17 10:20 +0100
Last post2017-01-18 11:30 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/4] mm, page_alloc: warn_alloc print nodemask Michal Hocko <mhocko@kernel.org> - 2017-01-17 10:20 +0100
    Re: [PATCH 2/4] mm, page_alloc: warn_alloc print nodemask "Hillf Danton" <hillf.zj@alibaba-inc.com> - 2017-01-17 10:50 +0100
    Re: [PATCH 2/4] mm, page_alloc: warn_alloc print nodemask David Rientjes <rientjes@google.com> - 2017-01-18 00:10 +0100
      Re: [PATCH 2/4] mm, page_alloc: warn_alloc print nodemask Michal Hocko <mhocko@kernel.org> - 2017-01-18 11:30 +0100

#1560363 — [PATCH 2/4] mm, page_alloc: warn_alloc print nodemask

FromMichal Hocko <mhocko@kernel.org>
Date2017-01-17 10:20 +0100
Subject[PATCH 2/4] mm, page_alloc: warn_alloc print nodemask
Message-ID<t0y5Q-59Z-15@gated-at.bofh.it>
From: Michal Hocko <mhocko@suse.com>

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.

Changes since v1
- print cpusets as well - Vlastimil

Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
 include/linux/mm.h |  4 ++--
 mm/page_alloc.c    | 10 ++++++----
 mm/vmalloc.c       |  4 ++--
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 57dc3c3b53c1..3e35eb04a28a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -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);
 
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8f4f306d804c..7f9c0ee18ae0 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -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,8 @@ 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));
+	cpuset_print_current_mems_allowed();
 
 	dump_stack();
 	warn_alloc_show_mem(gfp_mask);
@@ -3709,7 +3711,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 +3745,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;
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index b9999fc44aa6..0600bbbd1080 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -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;
 }
-- 
2.11.0

[toc] | [next] | [standalone]


#1560404

From"Hillf Danton" <hillf.zj@alibaba-inc.com>
Date2017-01-17 10:50 +0100
Message-ID<t0yyS-5mX-9@gated-at.bofh.it>
In reply to#1560363
On Tuesday, January 17, 2017 5:16 PM Michal Hocko wrote: 
> 
> From: Michal Hocko <mhocko@suse.com>
> 
> 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.
> 
> Changes since v1
> - print cpusets as well - Vlastimil
> 
> Acked-by: Mel Gorman <mgorman@suse.de>
> Signed-off-by: Michal Hocko <mhocko@suse.com>
> ---
Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com> 

[toc] | [prev] | [next] | [standalone]


#1561088

FromDavid Rientjes <rientjes@google.com>
Date2017-01-18 00:10 +0100
Message-ID<t0L35-4Oi-53@gated-at.bofh.it>
In reply to#1560363
On Tue, 17 Jan 2017, Michal Hocko wrote:

> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 57dc3c3b53c1..3e35eb04a28a 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -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);
>  
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 8f4f306d804c..7f9c0ee18ae0 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -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;

Small nit: wouldn't it be helpful to know if ac->nodemask is actually NULL 
rather than setting it to cpuset_current_mems_allowed here?  We know the 
effective nodemask from cpuset_print_current_mems_allowed(), but we don't 
know if there's a bug in the page allocator which is failing to set 
ac->nodemask appropriately if we blindly set it here when cpusets are not 
enabled.

>  
>  	if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs) ||
>  	    debug_guardpage_minorder() > 0)
> @@ -3050,7 +3051,8 @@ 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));
> +	cpuset_print_current_mems_allowed();
>  
>  	dump_stack();
>  	warn_alloc_show_mem(gfp_mask);
> @@ -3709,7 +3711,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 +3745,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;
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index b9999fc44aa6..0600bbbd1080 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -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;
>  }

[toc] | [prev] | [next] | [standalone]


#1561456

FromMichal Hocko <mhocko@kernel.org>
Date2017-01-18 11:30 +0100
Message-ID<t0VF8-2KV-1@gated-at.bofh.it>
In reply to#1561088
On Tue 17-01-17 15:01:35, David Rientjes wrote:
> On Tue, 17 Jan 2017, Michal Hocko wrote:
> 
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index 57dc3c3b53c1..3e35eb04a28a 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -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);
> >  
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 8f4f306d804c..7f9c0ee18ae0 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -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;
> 
> Small nit: wouldn't it be helpful to know if ac->nodemask is actually NULL 
> rather than setting it to cpuset_current_mems_allowed here?  We know the 
> effective nodemask from cpuset_print_current_mems_allowed(), but we don't 
> know if there's a bug in the page allocator which is failing to set 
> ac->nodemask appropriately if we blindly set it here when cpusets are not 
> enabled.

You are right that games with the nodemask are dangerous and can
potentially lead to unexpected behavior. I wanted to make this code as
simple as possible though and printing mems_allowed for NULL nodemask
looked like the way. Feel free to post a patch to handle null nodemask
in the output if you think it is an improvement.

-- 
Michal Hocko
SUSE Labs

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web