All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: David Rientjes <rientjes@google.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>, Greg Thelen <gthelen@google.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Subject: Re: [RFC v2 1/4] mm: make alloc_pages_exact_node pass __GFP_THISNODE
Date: Fri, 24 Jul 2015 22:52:38 +0200	[thread overview]
Message-ID: <55B2A596.1010101@suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.10.1507241301400.5215@chino.kir.corp.google.com>

On 24.7.2015 22:08, David Rientjes wrote:
> On Fri, 24 Jul 2015, Vlastimil Babka wrote:
> 
>> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
>> index 15928f0..c50848e 100644
>> --- a/include/linux/gfp.h
>> +++ b/include/linux/gfp.h
>> @@ -300,6 +300,22 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
>>  	return __alloc_pages_nodemask(gfp_mask, order, zonelist, NULL);
>>  }
>>  
>> +/*
>> + * An optimized version of alloc_pages_node(), to be only used in places where
>> + * the overhead of the check for nid == -1 could matter.
> 
> We don't actually check for nid == -1, or nid == NUMA_NO_NODE, in any of 
> the functions.  I would just state that nid must be valid and possible to 
> allocate from when passed to this function.

OK

>> + */
>> +static inline struct page *
>> +__alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order)
>> +{
>> +	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES || !node_online(nid));
>> +
>> +	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
>> +}
>> +
>> +/*
>> + * Allocate pages, preferring the node given as nid. When nid equals -1,
>> + * prefer the current CPU's node.
>> + */
> 
> We've done quite a bit of work to refer only to NUMA_NO_NODE, so we'd like 
> to avoid hardcoded -1 anywhere we can.

OK

>>  static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
>>  						unsigned int order)
>>  {
>> @@ -310,11 +326,18 @@ static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
>>  	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
>>  }
>>  
>> +/*
>> + * Allocate pages, restricting the allocation to the node given as nid. The
>> + * node must be valid and online. This is achieved by adding __GFP_THISNODE
>> + * to gfp_mask.
> 
> Not sure we need to point out that __GPF_THISNODE does this, it stands out 
> pretty well in the function already :)

Right.

>> + */
>>  static inline struct page *alloc_pages_exact_node(int nid, gfp_t gfp_mask,
>>  						unsigned int order)
>>  {
>>  	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES || !node_online(nid));
>>  
>> +	gfp_mask |= __GFP_THISNODE;
>> +
>>  	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
>>  }
>>  
> [snip]
> 
> I assume you looked at the collapse_huge_page() case and decided that it 
> needs no modification since the gfp mask is used later for other calls?

Yeah. Not that the memcg charge parts would seem to care about __GFP_THISNODE,
though.

>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index f53838f..d139222 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -1554,10 +1554,8 @@ static struct page *alloc_misplaced_dst_page(struct page *page,
>>  	struct page *newpage;
>>  
>>  	newpage = alloc_pages_exact_node(nid,
>> -					 (GFP_HIGHUSER_MOVABLE |
>> -					  __GFP_THISNODE | __GFP_NOMEMALLOC |
>> -					  __GFP_NORETRY | __GFP_NOWARN) &
>> -					 ~GFP_IOFS, 0);
>> +				(GFP_HIGHUSER_MOVABLE | __GFP_NOMEMALLOC |
>> +				 __GFP_NORETRY | __GFP_NOWARN) & ~GFP_IOFS, 0);
>>  
>>  	return newpage;
>>  }
> [snip]
> 
> What about the alloc_pages_exact_node() in new_page_node()?

Oops, seems I missed that one. So the API seems ok otherwise?

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

WARNING: multiple messages have this Message-ID (diff)
From: Vlastimil Babka <vbabka@suse.cz>
To: David Rientjes <rientjes@google.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>, Greg Thelen <gthelen@google.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Subject: Re: [RFC v2 1/4] mm: make alloc_pages_exact_node pass __GFP_THISNODE
Date: Fri, 24 Jul 2015 22:52:38 +0200	[thread overview]
Message-ID: <55B2A596.1010101@suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.10.1507241301400.5215@chino.kir.corp.google.com>

On 24.7.2015 22:08, David Rientjes wrote:
> On Fri, 24 Jul 2015, Vlastimil Babka wrote:
> 
>> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
>> index 15928f0..c50848e 100644
>> --- a/include/linux/gfp.h
>> +++ b/include/linux/gfp.h
>> @@ -300,6 +300,22 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
>>  	return __alloc_pages_nodemask(gfp_mask, order, zonelist, NULL);
>>  }
>>  
>> +/*
>> + * An optimized version of alloc_pages_node(), to be only used in places where
>> + * the overhead of the check for nid == -1 could matter.
> 
> We don't actually check for nid == -1, or nid == NUMA_NO_NODE, in any of 
> the functions.  I would just state that nid must be valid and possible to 
> allocate from when passed to this function.

OK

>> + */
>> +static inline struct page *
>> +__alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order)
>> +{
>> +	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES || !node_online(nid));
>> +
>> +	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
>> +}
>> +
>> +/*
>> + * Allocate pages, preferring the node given as nid. When nid equals -1,
>> + * prefer the current CPU's node.
>> + */
> 
> We've done quite a bit of work to refer only to NUMA_NO_NODE, so we'd like 
> to avoid hardcoded -1 anywhere we can.

OK

>>  static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
>>  						unsigned int order)
>>  {
>> @@ -310,11 +326,18 @@ static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
>>  	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
>>  }
>>  
>> +/*
>> + * Allocate pages, restricting the allocation to the node given as nid. The
>> + * node must be valid and online. This is achieved by adding __GFP_THISNODE
>> + * to gfp_mask.
> 
> Not sure we need to point out that __GPF_THISNODE does this, it stands out 
> pretty well in the function already :)

Right.

>> + */
>>  static inline struct page *alloc_pages_exact_node(int nid, gfp_t gfp_mask,
>>  						unsigned int order)
>>  {
>>  	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES || !node_online(nid));
>>  
>> +	gfp_mask |= __GFP_THISNODE;
>> +
>>  	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
>>  }
>>  
> [snip]
> 
> I assume you looked at the collapse_huge_page() case and decided that it 
> needs no modification since the gfp mask is used later for other calls?

Yeah. Not that the memcg charge parts would seem to care about __GFP_THISNODE,
though.

>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index f53838f..d139222 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -1554,10 +1554,8 @@ static struct page *alloc_misplaced_dst_page(struct page *page,
>>  	struct page *newpage;
>>  
>>  	newpage = alloc_pages_exact_node(nid,
>> -					 (GFP_HIGHUSER_MOVABLE |
>> -					  __GFP_THISNODE | __GFP_NOMEMALLOC |
>> -					  __GFP_NORETRY | __GFP_NOWARN) &
>> -					 ~GFP_IOFS, 0);
>> +				(GFP_HIGHUSER_MOVABLE | __GFP_NOMEMALLOC |
>> +				 __GFP_NORETRY | __GFP_NOWARN) & ~GFP_IOFS, 0);
>>  
>>  	return newpage;
>>  }
> [snip]
> 
> What about the alloc_pages_exact_node() in new_page_node()?

Oops, seems I missed that one. So the API seems ok otherwise?


  reply	other threads:[~2015-07-24 20:52 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24 14:45 [RFC v2 1/4] mm: make alloc_pages_exact_node pass __GFP_THISNODE Vlastimil Babka
2015-07-24 14:45 ` Vlastimil Babka
2015-07-24 14:45 ` [RFC v2 2/4] mm: unify checks in alloc_pages_node family of functions Vlastimil Babka
2015-07-24 14:45   ` Vlastimil Babka
2015-07-24 20:09   ` David Rientjes
2015-07-24 20:09     ` David Rientjes
2015-07-24 14:45 ` [RFC v2 3/4] mm: use numa_mem_id in alloc_pages_node() Vlastimil Babka
2015-07-24 14:45   ` Vlastimil Babka
2015-07-24 20:09   ` David Rientjes
2015-07-24 20:09     ` David Rientjes
2015-07-29 13:31   ` Mel Gorman
2015-07-29 13:31     ` Mel Gorman
2015-07-24 14:45 ` [RFC v2 4/4] mm: fallback for offline nodes in alloc_pages_node Vlastimil Babka
2015-07-24 14:45   ` Vlastimil Babka
2015-07-24 15:48   ` Christoph Lameter
2015-07-24 15:48     ` Christoph Lameter
2015-07-24 19:54     ` David Rientjes
2015-07-24 19:54       ` David Rientjes
2015-07-24 20:39       ` Vlastimil Babka
2015-07-24 20:39         ` Vlastimil Babka
2015-07-24 23:06         ` David Rientjes
2015-07-24 23:06           ` David Rientjes
2015-07-27 11:29           ` Vlastimil Babka
2015-07-27 11:29             ` Vlastimil Babka
2015-07-24 20:08 ` [RFC v2 1/4] mm: make alloc_pages_exact_node pass __GFP_THISNODE David Rientjes
2015-07-24 20:08   ` David Rientjes
2015-07-24 20:52   ` Vlastimil Babka [this message]
2015-07-24 20:52     ` Vlastimil Babka
2015-07-24 23:09     ` David Rientjes
2015-07-24 23:09       ` David Rientjes
2015-07-27 15:39 ` Johannes Weiner
2015-07-27 15:39   ` Johannes Weiner
2015-07-27 15:47   ` Vlastimil Babka
2015-07-27 15:47     ` Vlastimil Babka
2015-07-29 13:30 ` Mel Gorman
2015-07-29 13:30   ` Mel Gorman
2015-07-30 14:33   ` Christoph Lameter
2015-07-30 14:33     ` Christoph Lameter
2015-07-30 15:14   ` Johannes Weiner
2015-07-30 15:14     ` Johannes Weiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55B2A596.1010101@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=cl@linux.com \
    --cc=gthelen@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.