From: Ben Widawsky <ben.widawsky@intel.com>
To: linux-mm <linux-mm@kvack.org>
Cc: Ben Widawsky <ben.widawsky@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Dan Williams <dan.j.williams@intel.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Mel Gorman <mgorman@techsingularity.net>
Subject: [PATCH 09/18] mm: Finish handling MPOL_PREFERRED_MANY
Date: Fri, 19 Jun 2020 09:24:16 -0700 [thread overview]
Message-ID: <20200619162425.1052382-10-ben.widawsky@intel.com> (raw)
In-Reply-To: <20200619162425.1052382-1-ben.widawsky@intel.com>
Now that there is a function to generate the preferred zonelist given a
preferred mask, bindmask, and flags it is possible to support
MPOL_PREFERRED_MANY policy easily in more places.
This patch was developed on top of Dave's original work. When Dave wrote
his patches there was no clean way to implement MPOL_PREFERRED_MANY. Now
that the other bits are in place, this is easy to drop on top.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
---
include/linux/mmzone.h | 3 +++
mm/mempolicy.c | 20 ++++++++++++++++++--
mm/page_alloc.c | 5 ++---
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index c4c37fd12104..6b62ee98bb96 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1001,6 +1001,9 @@ struct zoneref *__next_zones_zonelist(struct zoneref *z,
enum zone_type highest_zoneidx,
nodemask_t *nodes);
+struct zonelist *preferred_zonelist(gfp_t gfp_mask, const nodemask_t *prefmask,
+ const nodemask_t *bindmask);
+
/**
* next_zones_zonelist - Returns the next zone at or below highest_zoneidx within the allowed nodemask using a cursor within a zonelist as a starting point
* @z - The cursor used as a starting point for the search
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index bfc4ef2af90d..90bc9c93b1b9 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1995,7 +1995,6 @@ unsigned int mempolicy_slab_node(void)
return node;
switch (policy->mode) {
- case MPOL_PREFERRED_MANY:
case MPOL_PREFERRED:
/*
* handled MPOL_F_LOCAL above
@@ -2020,6 +2019,18 @@ unsigned int mempolicy_slab_node(void)
return z->zone ? zone_to_nid(z->zone) : node;
}
+ case MPOL_PREFERRED_MANY: {
+ struct zoneref *z;
+ struct zonelist *zonelist;
+ enum zone_type highest_zoneidx = gfp_zone(GFP_KERNEL);
+
+ zonelist = preferred_zonelist(GFP_KERNEL,
+ &policy->v.preferred_nodes, NULL);
+ z = first_zones_zonelist(zonelist, highest_zoneidx,
+ &policy->v.nodes);
+ return z->zone ? zone_to_nid(z->zone) : node;
+ }
+
default:
BUG();
}
@@ -2585,7 +2596,12 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long
polnid = zone_to_nid(z->zone);
break;
- /* case MPOL_PREFERRED_MANY: */
+ case MPOL_PREFERRED_MANY:
+ z = first_zones_zonelist(preferred_zonelist(GFP_HIGHUSER,
+ &pol->v.preferred_nodes, NULL),
+ gfp_zone(GFP_HIGHUSER), &pol->v.preferred_nodes);
+ polnid = zone_to_nid(z->zone);
+ break;
default:
BUG();
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3cf44b6c31ae..c6f8f112a5d4 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4861,9 +4861,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
* NB: That zonelist will have *all* zones in the fallback case, and not all of
* those zones will belong to preferred nodes.
*/
-static struct zonelist *preferred_zonelist(gfp_t gfp_mask,
- const nodemask_t *prefmask,
- const nodemask_t *bindmask)
+struct zonelist *preferred_zonelist(gfp_t gfp_mask, const nodemask_t *prefmask,
+ const nodemask_t *bindmask)
{
nodemask_t pref;
int nid, local_node = numa_mem_id();
--
2.27.0
next prev parent reply other threads:[~2020-06-19 16:24 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-19 16:24 [PATCH 00/18] multiple preferred nodes Ben Widawsky
2020-06-19 16:24 ` [PATCH 01/18] mm/mempolicy: Add comment for missing LOCAL Ben Widawsky
2020-06-24 7:55 ` Michal Hocko
2020-06-19 16:24 ` [PATCH 02/18] mm/mempolicy: Use node_mem_id() instead of node_id() Ben Widawsky
2020-06-24 8:25 ` Michal Hocko
2020-06-24 16:48 ` Ben Widawsky
2020-06-26 12:30 ` Michal Hocko
2020-06-19 16:24 ` [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 ` Ben Widawsky [this message]
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 ` [PATCH 13/18] mm: kill __alloc_pages Ben Widawsky
2020-06-19 16:24 ` [PATCH 14/18] mm/mempolicy: Introduce policy_preferred_nodes() Ben Widawsky
2020-06-19 16:24 ` [PATCH 15/18] mm: convert callers of __alloc_pages_nodemask to pmask Ben Widawsky
2020-06-19 16:24 ` [PATCH 16/18] alloc_pages_nodemask: turn preferred nid into a nodemask Ben Widawsky
2020-06-19 16:24 ` [PATCH 17/18] mm: Use less stack for page allocations Ben Widawsky
2020-06-19 16:24 ` [PATCH 18/18] mm/mempolicy: Advertise new MPOL_PREFERRED_MANY Ben Widawsky
2020-06-22 7:09 ` [PATCH 00/18] multiple preferred nodes Michal Hocko
2020-06-23 11:20 ` Michal Hocko
2020-06-23 16:12 ` Ben Widawsky
2020-06-24 7:52 ` Michal Hocko
2020-06-24 16:16 ` Ben Widawsky
2020-06-24 18:39 ` Michal Hocko
2020-06-24 19:37 ` Ben Widawsky
2020-06-24 19:51 ` Michal Hocko
2020-06-24 20:01 ` Ben Widawsky
2020-06-24 20:07 ` Michal Hocko
2020-06-24 20:23 ` Ben Widawsky
2020-06-24 20:42 ` Michal Hocko
2020-06-24 20:55 ` Ben Widawsky
2020-06-25 6:28 ` Michal Hocko
2020-06-26 21:39 ` Ben Widawsky
2020-06-29 10:16 ` Michal Hocko
2020-06-22 20:54 ` Andi Kleen
2020-06-22 21:02 ` Ben Widawsky
2020-06-22 21:07 ` Dave Hansen
2020-06-22 22:02 ` Andi Kleen
-- strict thread matches above, loose matches on Subject: below --
2020-06-19 16:23 Ben Widawsky
2020-06-19 16:24 ` [PATCH 09/18] mm: Finish handling MPOL_PREFERRED_MANY 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=20200619162425.1052382-10-ben.widawsky@intel.com \
--to=ben.widawsky@intel.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
/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).