Skip to contentSkip to conversation

mm/oom_kill: fix stale comment in constrained_alloc()

PATCH In review Ye Liu 2 participants 3 messages Aug 13

Subsystems (2)
lore
Share & tools
lore

Ye Liu

author
#0 lore raw

PATCH 1/1 mm/oom_kill: fix stale comment in constrained_alloc()

From: Ye Liu <[email protected]>

The comment above the __GFP_THISNODE check in constrained_alloc() is stale and inaccurate: it references __GFP_NOFAIL (which is not checked here), claims the OOM killer does "random task kill" (it uses badness scores), and mentions CONSTRAINT_THISNODE (which was never added to the enum). Replace it with a description that matches the actual code behavior.

---
 mm/oom_kill.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/oom_kill.c +3 -3
index 5f372f6e26fa..4b5c70aaece4 100644
@@ -268,9 +268,9 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
 	if (!oc->zonelist)
 		return CONSTRAINT_NONE;
 	/*
-	 * Reach here only when __GFP_NOFAIL is used. So, we should avoid
-	 * to kill current.We have to random task kill in this case.
-	 * Hopefully, CONSTRAINT_THISNODE...but no way to handle it, now.
+	 * __GFP_THISNODE means the allocation is restricted to a single node.
+	 * There is no dedicated constraint type for this case, so return
+	 * CONSTRAINT_NONE and let the normal OOM handling proceed.
 	 */
 	if (oc->gfp_mask & __GFP_THISNODE)
 		return CONSTRAINT_NONE;
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · Ye Liu

From: Ye Liu <[email protected]>

The comment above the __GFP_THISNODE check in constrained_alloc() is stale and inaccurate: it references __GFP_NOFAIL (which is not checked here), claims the OOM killer does "random task kill" (it uses badness scores), and mentions CONSTRAINT_THISNODE (which was never added to the enum). Replace it with a description that matches the actual code behavior.

The comment is indeed confusing and stale. Your update unfortunatelly as well. This code is simply unreachable because we never trigger global OOM with __GFP_THISNODE (see __alloc_pages_may_oom) and for memcg OOM __GFP_THISNODE is immaterial.

Quoted 24 lines
---
 mm/oom_kill.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/oom_kill.c +3 -3
index 5f372f6e26fa..4b5c70aaece4 100644
@@ -268,9 +268,9 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
 	if (!oc->zonelist)
 		return CONSTRAINT_NONE;
 	/*
-	 * Reach here only when __GFP_NOFAIL is used. So, we should avoid
-	 * to kill current.We have to random task kill in this case.
-	 * Hopefully, CONSTRAINT_THISNODE...but no way to handle it, now.
+	 * __GFP_THISNODE means the allocation is restricted to a single node.
+	 * There is no dedicated constraint type for this case, so return
+	 * CONSTRAINT_NONE and let the normal OOM handling proceed.
 	 */
 	if (oc->gfp_mask & __GFP_THISNODE)
 		return CONSTRAINT_NONE;
Signature · 1 line
2.25.1
Signature · 2 lines
Michal Hocko
SUSE Labs
author
#2 lore raw
Quoted 10 lines · Michal Hocko
Quoted 8 lines · Ye Liu

From: Ye Liu <[email protected]>

The comment above the __GFP_THISNODE check in constrained_alloc() is stale and inaccurate: it references __GFP_NOFAIL (which is not checked here), claims the OOM killer does "random task kill" (it uses badness scores), and mentions CONSTRAINT_THISNODE (which was never added to the enum). Replace it with a description that matches the actual code behavior.

Quoted 5 lines

The comment is indeed confusing and stale. Your update unfortunatelly as well. This code is simply unreachable because we never trigger global OOM with __GFP_THISNODE (see __alloc_pages_may_oom) and for memcg OOM __GFP_THISNODE is immaterial.

I directly deleted the invalid code and sent v2.

Quoted 25 lines
Quoted 24 lines
---
 mm/oom_kill.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/oom_kill.c +3 -3
index 5f372f6e26fa..4b5c70aaece4 100644
@@ -268,9 +268,9 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc)
 	if (!oc->zonelist)
 		return CONSTRAINT_NONE;
 	/*
-	 * Reach here only when __GFP_NOFAIL is used. So, we should avoid
-	 * to kill current.We have to random task kill in this case.
-	 * Hopefully, CONSTRAINT_THISNODE...but no way to handle it, now.
+	 * __GFP_THISNODE means the allocation is restricted to a single node.
+	 * There is no dedicated constraint type for this case, so return
+	 * CONSTRAINT_NONE and let the normal OOM handling proceed.
 	 */
 	if (oc->gfp_mask & __GFP_THISNODE)
 		return CONSTRAINT_NONE;
Signature · 1 line
2.25.1
Signature · 2 lines
Thanks,
Ye Liu