linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ben Widawsky <ben.widawsky@intel.com>
To: linux-mm <linux-mm@kvack.org>
Subject: [PATCH 13/18] mm: kill __alloc_pages
Date: Fri, 19 Jun 2020 09:24:09 -0700	[thread overview]
Message-ID: <20200619162414.1052234-14-ben.widawsky@intel.com> (raw)
In-Reply-To: <20200619162414.1052234-1-ben.widawsky@intel.com>

IMPORTANT NOTE: It's unclear how safe it is to declare nodemask_t on the
stack, when nodemask_t can be relatively large in huge NUMA systems.
Upcoming patches will try to limit this.

The primary purpose of this patch is to clear up which interfaces should
be used for page allocation.

There are several attributes in page allocation after the obvious gfp
and order:
1. node mask: set of nodes to try to allocate from, fail if unavailable
2. preferred nid: a preferred node to try to allocate from, falling back
to node mask if unavailable
3. (soon) preferred mask: like preferred nid, but multiple nodes.

Here's a summary of the existing interfaces, and which they cover
*alloc_pages: 		()
*alloc_pages_node:	(2)
__alloc_pages_nodemask: (1,2,3)

I am instead proposing instead the following interfaces as a reasonable
set. Generally node binding isn't used by kernel code, it's only used
for mempolicy. On the other hand, the kernel does have preferred nodes
(today it's only one), and that is why those interfaces exist while an
interface to specify binding does not.

alloc_pages: () I don't care, give me pages.
alloc_pages_node: (2) I want pages from this particular node first
alloc_pages_nodes: (3) I want pages from *these* nodes first
__alloc_pages_nodemask: (1,2,3) I'm picky about my pages

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
---
 include/linux/gfp.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 67a0774e080b..9ab5c07579bd 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -504,9 +504,10 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,
 							nodemask_t *nodemask);
 
 static inline struct page *
-__alloc_pages(gfp_t gfp_mask, unsigned int order, int preferred_nid)
+__alloc_pages_nodes(nodemask_t *nodes, gfp_t gfp_mask, unsigned int order)
 {
-	return __alloc_pages_nodemask(gfp_mask, order, preferred_nid, NULL);
+	return __alloc_pages_nodemask(gfp_mask, order, first_node(*nodes),
+				      NULL);
 }
 
 /*
@@ -516,10 +517,12 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, int preferred_nid)
 static inline struct page *
 __alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order)
 {
+	nodemask_t tmp;
 	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
 	VM_WARN_ON((gfp_mask & __GFP_THISNODE) && !node_online(nid));
 
-	return __alloc_pages(gfp_mask, order, nid);
+	tmp = nodemask_of_node(nid);
+	return __alloc_pages_nodes(&tmp, gfp_mask, order);
 }
 
 /*
-- 
2.27.0



  parent reply	other threads:[~2020-06-19 16:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-19 16:23 [PATCH 00/18] multiple preferred nodes Ben Widawsky
2020-06-19 16:23 ` [PATCH 01/18] mm/mempolicy: Add comment for missing LOCAL Ben Widawsky
2020-06-19 16:23 ` [PATCH 02/18] mm/mempolicy: Use node_mem_id() instead of node_id() Ben Widawsky
2020-06-19 16:23 ` [PATCH 03/18] mm/page_alloc: start plumbing multi preferred node Ben Widawsky
2020-06-19 16:24 ` [PATCH 04/18] mm/page_alloc: add preferred pass to page allocation Ben Widawsky
2020-06-19 16:24 ` [PATCH 05/18] mm/mempolicy: convert single preferred_node to full nodemask Ben Widawsky
2020-06-19 16:24 ` [PATCH 06/18] mm/mempolicy: Add MPOL_PREFERRED_MANY for multiple preferred nodes Ben Widawsky
2020-06-19 16:24 ` [PATCH 07/18] mm/mempolicy: allow preferred code to take a nodemask Ben Widawsky
2020-06-19 16:24 ` [PATCH 08/18] mm/mempolicy: refactor rebind code for PREFERRED_MANY Ben Widawsky
2020-06-19 16:24 ` [PATCH 09/18] mm: Finish handling MPOL_PREFERRED_MANY Ben Widawsky
2020-06-19 16:24 ` [PATCH 10/18] mm: clean up alloc_pages_vma (thp) Ben Widawsky
2020-06-19 16:24 ` [PATCH 11/18] mm: Extract THP hugepage allocation Ben Widawsky
2020-06-19 16:24 ` [PATCH 12/18] mm/mempolicy: Use __alloc_page_node for interleaved Ben Widawsky
2020-06-19 16:24 ` Ben Widawsky [this message]
2020-06-19 16:25 ` [PATCH 00/18] multiple preferred nodes Ben Widawsky
2020-06-19 16:24 Ben Widawsky
2020-06-19 16:24 ` [PATCH 13/18] mm: kill __alloc_pages Ben Widawsky

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=20200619162414.1052234-14-ben.widawsky@intel.com \
    --to=ben.widawsky@intel.com \
    --cc=linux-mm@kvack.org \
    /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 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).