[RFC v1 03/19] mm, oom_kill: use for_each_node in constrained_alloc()

From: Pengfei Li
Date: Thu Nov 21 2019 - 10:20:10 EST


In constrained_alloc(), we want to traverse node instead of zone, so
use for_each_node instead of for_each_zone.

Signed-off-by: Pengfei Li <fly@xxxxxxxxxxx>
---
mm/oom_kill.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index f44c79db0cd6..db509d5e4db3 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -254,7 +254,6 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
enum zone_type high_zoneidx = gfp_zone(oc->gfp_mask);
bool cpuset_limited = false;
struct nlist_traverser t;
- struct zone *zone;
int nid;

if (is_memcg_oom(oc)) {
@@ -292,10 +291,13 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
}

/* Check this allocation failure is caused by cpuset's wall function */
- for_each_zone_nlist_nodemask(zone, &t, oc->nodelist,
- high_zoneidx, oc->nodemask)
- if (!cpuset_zone_allowed(zone, oc->gfp_mask))
+ for_each_node_nlist_nodemask(nid, &t, oc->nodelist,
+ high_zoneidx, oc->nodemask) {
+ if (!cpuset_node_allowed(nid, oc->gfp_mask)) {
cpuset_limited = true;
+ break;
+ }
+ }

if (cpuset_limited) {
oc->totalpages = total_swap_pages;
--
2.23.0