linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm, slab: suppress out of memory warning unless debug is enabled
@ 2014-05-07 21:19 David Rientjes
  2014-05-07 21:29 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: David Rientjes @ 2014-05-07 21:19 UTC (permalink / raw)
  To: Andrew Morton, Pekka Enberg; +Cc: Christoph Lameter, linux-kernel, linux-mm

When the slab or slub allocators cannot allocate additional slab pages, they 
emit diagnostic information to the kernel log such as current number of slabs, 
number of objects, active objects, etc.  This is always coupled with a page 
allocation failure warning since it is controlled by !__GFP_NOWARN.

Suppress this out of memory warning if the allocator is configured without debug 
supported.  The page allocation failure warning will indicate it is a failed 
slab allocation, so this is only useful to diagnose allocator bugs.

Since CONFIG_SLUB_DEBUG is already enabled by default for the slub allocator, 
there is no functional change with this patch.  If debug is disabled, however, 
the warnings are now suppressed.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/slab.c | 10 ++++++++--
 mm/slub.c | 11 ++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1621,11 +1621,17 @@ __initcall(cpucache_init);
 static noinline void
 slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
 {
+#if DEBUG
 	struct kmem_cache_node *n;
 	struct page *page;
 	unsigned long flags;
 	int node;
 
+	if (gfpflags & __GFP_NOWARN)
+		return;
+	if (!printk_ratelimit())
+		return;
+
 	printk(KERN_WARNING
 		"SLAB: Unable to allocate memory on node %d (gfp=0x%x)\n",
 		nodeid, gfpflags);
@@ -1662,6 +1668,7 @@ slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
 			node, active_slabs, num_slabs, active_objs, num_objs,
 			free_objects);
 	}
+#endif
 }
 
 /*
@@ -1683,8 +1690,7 @@ static struct page *kmem_getpages(struct kmem_cache *cachep, gfp_t flags,
 
 	page = alloc_pages_exact_node(nodeid, flags | __GFP_NOTRACK, cachep->gfporder);
 	if (!page) {
-		if (!(flags & __GFP_NOWARN) && printk_ratelimit())
-			slab_out_of_memory(cachep, flags, nodeid);
+		slab_out_of_memory(cachep, flags, nodeid);
 		return NULL;
 	}
 
diff --git a/mm/slub.c b/mm/slub.c
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2152,8 +2152,14 @@ static inline unsigned long node_nr_objs(struct kmem_cache_node *n)
 static noinline void
 slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
 {
+#ifdef CONFIG_SLUB_DEBUG
 	int node;
 
+	if (gfpflags & __GFP_NOWARN)
+		return;
+	if (!printk_ratelimit())
+		return;
+
 	printk(KERN_WARNING
 		"SLUB: Unable to allocate memory on node %d (gfp=0x%x)\n",
 		nid, gfpflags);
@@ -2182,6 +2188,7 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
 			"  node %d: slabs: %ld, objs: %ld, free: %ld\n",
 			node, nr_slabs, nr_objs, nr_free);
 	}
+#endif
 }
 
 static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
@@ -2360,9 +2367,7 @@ new_slab:
 	freelist = new_slab_objects(s, gfpflags, node, &c);
 
 	if (unlikely(!freelist)) {
-		if (!(gfpflags & __GFP_NOWARN) && printk_ratelimit())
-			slab_out_of_memory(s, gfpflags, node);
-
+		slab_out_of_memory(s, gfpflags, node);
 		local_irq_restore(flags);
 		return NULL;
 	}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] mm, slab: suppress out of memory warning unless debug is enabled
  2014-05-07 21:19 [patch] mm, slab: suppress out of memory warning unless debug is enabled David Rientjes
@ 2014-05-07 21:29 ` Andrew Morton
  2014-05-07 21:36   ` David Rientjes
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2014-05-07 21:29 UTC (permalink / raw)
  To: David Rientjes; +Cc: Pekka Enberg, Christoph Lameter, linux-kernel, linux-mm

On Wed, 7 May 2014 14:19:19 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:

> When the slab or slub allocators cannot allocate additional slab pages, they 
> emit diagnostic information to the kernel log such as current number of slabs, 
> number of objects, active objects, etc.  This is always coupled with a page 
> allocation failure warning since it is controlled by !__GFP_NOWARN.
> 
> Suppress this out of memory warning if the allocator is configured without debug 
> supported.  The page allocation failure warning will indicate it is a failed 
> slab allocation, so this is only useful to diagnose allocator bugs.
> 
> Since CONFIG_SLUB_DEBUG is already enabled by default for the slub allocator, 
> there is no functional change with this patch.  If debug is disabled, however, 
> the warnings are now suppressed.
> 

I'm not seeing any reason for making this change.

> @@ -1621,11 +1621,17 @@ __initcall(cpucache_init);
>  static noinline void
>  slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
>  {
> +#if DEBUG
>  	struct kmem_cache_node *n;
>  	struct page *page;
>  	unsigned long flags;
>  	int node;
>  
> +	if (gfpflags & __GFP_NOWARN)
> +		return;
> +	if (!printk_ratelimit())
> +		return;

printk_ratelimit() is lame - it uses a single global state.  So if
random net driver is using printk_ratelimit(), that driver and slab
will interfere with each other.

We don't appear to presently have a handy macro to do this properly -
you might care to add one and switch printk_ratelimited() and
pr_debug_ratelimited() over to using it.  And various sites in
include/linux/device.h, I guess.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] mm, slab: suppress out of memory warning unless debug is enabled
  2014-05-07 21:29 ` Andrew Morton
@ 2014-05-07 21:36   ` David Rientjes
  2014-05-07 21:48     ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: David Rientjes @ 2014-05-07 21:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Pekka Enberg, Christoph Lameter, linux-kernel, linux-mm

On Wed, 7 May 2014, Andrew Morton wrote:

> > When the slab or slub allocators cannot allocate additional slab pages, they 
> > emit diagnostic information to the kernel log such as current number of slabs, 
> > number of objects, active objects, etc.  This is always coupled with a page 
> > allocation failure warning since it is controlled by !__GFP_NOWARN.
> > 
> > Suppress this out of memory warning if the allocator is configured without debug 
> > supported.  The page allocation failure warning will indicate it is a failed 
> > slab allocation, so this is only useful to diagnose allocator bugs.
> > 
> > Since CONFIG_SLUB_DEBUG is already enabled by default for the slub allocator, 
> > there is no functional change with this patch.  If debug is disabled, however, 
> > the warnings are now suppressed.
> > 
> 
> I'm not seeing any reason for making this change.
> 

You think the spam in http://marc.info/?l=linux-kernel&m=139927773010514 
is meaningful?  It also looks like two different errors when in reality it 
is a single allocation.

Unless you're debugging a slab issue, all the pertinent information is 
already available in the page allocation failure warning emitted by the 
page allocator: we already have the order and gfp mask.  We also know it's 
a slab allocation because of the __kmalloc in the call trace.

Does this user care about that there are 207 slabs on node 0 with 207 
objects?  Probably only if they are diagnosing a slab problem.

> > @@ -1621,11 +1621,17 @@ __initcall(cpucache_init);
> >  static noinline void
> >  slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
> >  {
> > +#if DEBUG
> >  	struct kmem_cache_node *n;
> >  	struct page *page;
> >  	unsigned long flags;
> >  	int node;
> >  
> > +	if (gfpflags & __GFP_NOWARN)
> > +		return;
> > +	if (!printk_ratelimit())
> > +		return;
> 
> printk_ratelimit() is lame - it uses a single global state.  So if
> random net driver is using printk_ratelimit(), that driver and slab
> will interfere with each other.
> 

Agreed, but it is a testiment to the uselessness of this information 
already.  The page allocation failure warnings are controlled by their own 
ratelimiter, nopage_rs, but that's local to the page allocator.  Do you 
prefer that all these ratelimiters be moved to the global namespace for 
generic use?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] mm, slab: suppress out of memory warning unless debug is enabled
  2014-05-07 21:36   ` David Rientjes
@ 2014-05-07 21:48     ` Andrew Morton
  2014-05-07 22:00       ` [patch v2] " David Rientjes
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2014-05-07 21:48 UTC (permalink / raw)
  To: David Rientjes; +Cc: Pekka Enberg, Christoph Lameter, linux-kernel, linux-mm

On Wed, 7 May 2014 14:36:34 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:

> On Wed, 7 May 2014, Andrew Morton wrote:
> 
> > > When the slab or slub allocators cannot allocate additional slab pages, they 
> > > emit diagnostic information to the kernel log such as current number of slabs, 
> > > number of objects, active objects, etc.  This is always coupled with a page 
> > > allocation failure warning since it is controlled by !__GFP_NOWARN.
> > > 
> > > Suppress this out of memory warning if the allocator is configured without debug 
> > > supported.  The page allocation failure warning will indicate it is a failed 
> > > slab allocation, so this is only useful to diagnose allocator bugs.
> > > 
> > > Since CONFIG_SLUB_DEBUG is already enabled by default for the slub allocator, 
> > > there is no functional change with this patch.  If debug is disabled, however, 
> > > the warnings are now suppressed.
> > > 
> > 
> > I'm not seeing any reason for making this change.
> > 
> 
> You think the spam in http://marc.info/?l=linux-kernel&m=139927773010514 
> is meaningful?  It also looks like two different errors when in reality it 
> is a single allocation.
> 
> Unless you're debugging a slab issue, all the pertinent information is 
> already available in the page allocation failure warning emitted by the 
> page allocator: we already have the order and gfp mask.  We also know it's 
> a slab allocation because of the __kmalloc in the call trace.
> 
> Does this user care about that there are 207 slabs on node 0 with 207 
> objects?  Probably only if they are diagnosing a slab problem.

I'd prefer something which can be added to the changelog to address
this omission over a series of rhetorical questions.

> > > @@ -1621,11 +1621,17 @@ __initcall(cpucache_init);
> > >  static noinline void
> > >  slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
> > >  {
> > > +#if DEBUG
> > >  	struct kmem_cache_node *n;
> > >  	struct page *page;
> > >  	unsigned long flags;
> > >  	int node;
> > >  
> > > +	if (gfpflags & __GFP_NOWARN)
> > > +		return;
> > > +	if (!printk_ratelimit())
> > > +		return;
> > 
> > printk_ratelimit() is lame - it uses a single global state.  So if
> > random net driver is using printk_ratelimit(), that driver and slab
> > will interfere with each other.
> > 
> 
> Agreed, but it is a testiment to the uselessness of this information 
> already.  The page allocation failure warnings are controlled by their own 
> ratelimiter, nopage_rs, but that's local to the page allocator.  Do you 
> prefer that all these ratelimiters be moved to the global namespace for 
> generic use?

As these messages are related then it probably makes sense for them to
use a common ratelimit_state, hopefully local to slab.c.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch v2] mm, slab: suppress out of memory warning unless debug is enabled
  2014-05-07 21:48     ` Andrew Morton
@ 2014-05-07 22:00       ` David Rientjes
  2014-05-08 13:54         ` Christoph Lameter
  0 siblings, 1 reply; 6+ messages in thread
From: David Rientjes @ 2014-05-07 22:00 UTC (permalink / raw)
  To: Andrew Morton, Pekka Enberg; +Cc: Christoph Lameter, linux-kernel, linux-mm

When the slab or slub allocators cannot allocate additional slab pages, they 
emit diagnostic information to the kernel log such as current number of slabs, 
number of objects, active objects, etc.  This is always coupled with a page 
allocation failure warning since it is controlled by !__GFP_NOWARN.

Suppress this out of memory warning if the allocator is configured without debug 
supported.  The page allocation failure warning will indicate it is a failed 
slab allocation, the order, and the gfp mask, so this is only useful to diagnose 
allocator issues.

Since CONFIG_SLUB_DEBUG is already enabled by default for the slub allocator, 
there is no functional change with this patch.  If debug is disabled, however, 
the warnings are now suppressed.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 v2: added ratelimit state for slab out of memory warnings per Andrew
     added gfp mask and order to changelog per Andrew

 mm/slab.c | 10 ++++++++--
 mm/slub.c | 11 ++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1621,10 +1621,16 @@ __initcall(cpucache_init);
 static noinline void
 slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
 {
+#if DEBUG
 	struct kmem_cache_node *n;
 	struct page *page;
 	unsigned long flags;
 	int node;
+	static DEFINE_RATELIMIT_STATE(slab_oom_rs, DEFAULT_RATELIMIT_INTERVAL,
+				      DEFAULT_RATELIMIT_BURST);
+
+	if ((gfpflags & __GFP_NOWARN) || !__ratelimit(&slab_oom_rs))
+		return;
 
 	printk(KERN_WARNING
 		"SLAB: Unable to allocate memory on node %d (gfp=0x%x)\n",
@@ -1662,6 +1668,7 @@ slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
 			node, active_slabs, num_slabs, active_objs, num_objs,
 			free_objects);
 	}
+#endif
 }
 
 /*
@@ -1683,8 +1690,7 @@ static struct page *kmem_getpages(struct kmem_cache *cachep, gfp_t flags,
 
 	page = alloc_pages_exact_node(nodeid, flags | __GFP_NOTRACK, cachep->gfporder);
 	if (!page) {
-		if (!(flags & __GFP_NOWARN) && printk_ratelimit())
-			slab_out_of_memory(cachep, flags, nodeid);
+		slab_out_of_memory(cachep, flags, nodeid);
 		return NULL;
 	}
 
diff --git a/mm/slub.c b/mm/slub.c
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2152,8 +2152,14 @@ static inline unsigned long node_nr_objs(struct kmem_cache_node *n)
 static noinline void
 slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
 {
+#ifdef CONFIG_SLUB_DEBUG
+	static DEFINE_RATELIMIT_STATE(slub_oom_rs, DEFAULT_RATELIMIT_INTERVAL,
+				      DEFAULT_RATELIMIT_BURST);
 	int node;
 
+	if ((gfpflags & __GFP_NOWARN) || !__ratelimit(&slub_oom_rs))
+		return;
+
 	printk(KERN_WARNING
 		"SLUB: Unable to allocate memory on node %d (gfp=0x%x)\n",
 		nid, gfpflags);
@@ -2182,6 +2188,7 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
 			"  node %d: slabs: %ld, objs: %ld, free: %ld\n",
 			node, nr_slabs, nr_objs, nr_free);
 	}
+#endif
 }
 
 static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
@@ -2360,9 +2367,7 @@ new_slab:
 	freelist = new_slab_objects(s, gfpflags, node, &c);
 
 	if (unlikely(!freelist)) {
-		if (!(gfpflags & __GFP_NOWARN) && printk_ratelimit())
-			slab_out_of_memory(s, gfpflags, node);
-
+		slab_out_of_memory(s, gfpflags, node);
 		local_irq_restore(flags);
 		return NULL;
 	}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch v2] mm, slab: suppress out of memory warning unless debug is enabled
  2014-05-07 22:00       ` [patch v2] " David Rientjes
@ 2014-05-08 13:54         ` Christoph Lameter
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2014-05-08 13:54 UTC (permalink / raw)
  To: David Rientjes; +Cc: Andrew Morton, Pekka Enberg, linux-kernel, linux-mm

On Wed, 7 May 2014, David Rientjes wrote:

> Suppress this out of memory warning if the allocator is configured without debug
> supported.  The page allocation failure warning will indicate it is a failed
> slab allocation, the order, and the gfp mask, so this is only useful to diagnose
> allocator issues.

Acked-by: Christoph Lameter <cl@linux.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-05-08 13:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07 21:19 [patch] mm, slab: suppress out of memory warning unless debug is enabled David Rientjes
2014-05-07 21:29 ` Andrew Morton
2014-05-07 21:36   ` David Rientjes
2014-05-07 21:48     ` Andrew Morton
2014-05-07 22:00       ` [patch v2] " David Rientjes
2014-05-08 13:54         ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).