linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm, slab: only set __GFP_RECLAIMABLE once
@ 2017-10-17 22:30 David Rientjes
  2017-10-18 12:54 ` Vlastimil Babka
  2017-10-18 14:13 ` Mel Gorman
  0 siblings, 2 replies; 3+ messages in thread
From: David Rientjes @ 2017-10-17 22:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Christoph Lameter, Joonsoo Kim, linux-kernel, linux-mm

SLAB_RECLAIM_ACCOUNT is a permanent attribute of a slab cache.  Set 
__GFP_RECLAIMABLE as part of its ->allocflags rather than check the cachep 
flag on every page allocation.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/slab.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1409,8 +1409,6 @@ static struct page *kmem_getpages(struct kmem_cache *cachep, gfp_t flags,
 	int nr_pages;
 
 	flags |= cachep->allocflags;
-	if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
-		flags |= __GFP_RECLAIMABLE;
 
 	page = __alloc_pages_node(nodeid, flags | __GFP_NOTRACK, cachep->gfporder);
 	if (!page) {
@@ -2143,6 +2141,8 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
 	cachep->allocflags = __GFP_COMP;
 	if (flags & SLAB_CACHE_DMA)
 		cachep->allocflags |= GFP_DMA;
+	if (flags & SLAB_RECLAIM_ACCOUNT)
+		cachep->allocflags |= __GFP_RECLAIMABLE;
 	cachep->size = size;
 	cachep->reciprocal_buffer_size = reciprocal_value(size);
 

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

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

* Re: [patch] mm, slab: only set __GFP_RECLAIMABLE once
  2017-10-17 22:30 [patch] mm, slab: only set __GFP_RECLAIMABLE once David Rientjes
@ 2017-10-18 12:54 ` Vlastimil Babka
  2017-10-18 14:13 ` Mel Gorman
  1 sibling, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2017-10-18 12:54 UTC (permalink / raw)
  To: David Rientjes, Andrew Morton
  Cc: Christoph Lameter, Joonsoo Kim, linux-kernel, linux-mm, Mel Gorman

+CC Mel who added that code (long time ago though :) in case he
remembers some catch.

On 10/18/2017 12:30 AM, David Rientjes wrote:
> SLAB_RECLAIM_ACCOUNT is a permanent attribute of a slab cache.  Set 
> __GFP_RECLAIMABLE as part of its ->allocflags rather than check the cachep 
> flag on every page allocation.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>

Seems correct to me, and SLUB does that this way too, since the beginning.

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  mm/slab.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -1409,8 +1409,6 @@ static struct page *kmem_getpages(struct kmem_cache *cachep, gfp_t flags,
>  	int nr_pages;
>  
>  	flags |= cachep->allocflags;
> -	if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
> -		flags |= __GFP_RECLAIMABLE;
>  
>  	page = __alloc_pages_node(nodeid, flags | __GFP_NOTRACK, cachep->gfporder);
>  	if (!page) {
> @@ -2143,6 +2141,8 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
>  	cachep->allocflags = __GFP_COMP;
>  	if (flags & SLAB_CACHE_DMA)
>  		cachep->allocflags |= GFP_DMA;
> +	if (flags & SLAB_RECLAIM_ACCOUNT)
> +		cachep->allocflags |= __GFP_RECLAIMABLE;
>  	cachep->size = size;
>  	cachep->reciprocal_buffer_size = reciprocal_value(size);
>  
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
> 

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

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

* Re: [patch] mm, slab: only set __GFP_RECLAIMABLE once
  2017-10-17 22:30 [patch] mm, slab: only set __GFP_RECLAIMABLE once David Rientjes
  2017-10-18 12:54 ` Vlastimil Babka
@ 2017-10-18 14:13 ` Mel Gorman
  1 sibling, 0 replies; 3+ messages in thread
From: Mel Gorman @ 2017-10-18 14:13 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Christoph Lameter, Joonsoo Kim, linux-kernel, linux-mm

On Tue, Oct 17, 2017 at 03:30:01PM -0700, David Rientjes wrote:
> SLAB_RECLAIM_ACCOUNT is a permanent attribute of a slab cache.  Set 
> __GFP_RECLAIMABLE as part of its ->allocflags rather than check the cachep 
> flag on every page allocation.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>

Acked-by: Mel Gorman <mgorman@techsingularity.net>

-- 
Mel Gorman
SUSE Labs

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

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

end of thread, other threads:[~2017-10-18 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-17 22:30 [patch] mm, slab: only set __GFP_RECLAIMABLE once David Rientjes
2017-10-18 12:54 ` Vlastimil Babka
2017-10-18 14:13 ` Mel Gorman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox