* [PATCH] mm/oom_kill: fix stale comment in constrained_alloc()
@ 2026-08-13 3:06 Ye Liu
2026-08-13 8:43 ` Michal Hocko
0 siblings, 1 reply; 3+ messages in thread
From: Ye Liu @ 2026-08-13 3:06 UTC (permalink / raw)
To: Michal Hocko, Andrew Morton
Cc: Ye Liu, David Rientjes, Shakeel Butt, linux-mm, linux-kernel
From: Ye Liu <liuye@kylinos.cn>
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.
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
mm/oom_kill.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 5f372f6e26fa..4b5c70aaece4 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -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;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/oom_kill: fix stale comment in constrained_alloc()
2026-08-13 3:06 [PATCH] mm/oom_kill: fix stale comment in constrained_alloc() Ye Liu
@ 2026-08-13 8:43 ` Michal Hocko
2026-08-13 9:50 ` Ye Liu
0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2026-08-13 8:43 UTC (permalink / raw)
To: Ye Liu
Cc: Andrew Morton, Ye Liu, David Rientjes, Shakeel Butt, linux-mm,
linux-kernel
On Thu 13-08-26 11:06:54, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> 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.
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
> mm/oom_kill.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 5f372f6e26fa..4b5c70aaece4 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -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;
> --
> 2.25.1
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/oom_kill: fix stale comment in constrained_alloc()
2026-08-13 8:43 ` Michal Hocko
@ 2026-08-13 9:50 ` Ye Liu
0 siblings, 0 replies; 3+ messages in thread
From: Ye Liu @ 2026-08-13 9:50 UTC (permalink / raw)
To: Michal Hocko
Cc: Andrew Morton, Ye Liu, David Rientjes, Shakeel Butt, linux-mm,
linux-kernel
在 2026/8/13 16:43, Michal Hocko 写道:
> On Thu 13-08-26 11:06:54, Ye Liu wrote:
>> From: Ye Liu <liuye@kylinos.cn>
>>
>> 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.
>
I directly deleted the invalid code and sent v2.
>> Signed-off-by: Ye Liu <liuye@kylinos.cn>
>> ---
>> mm/oom_kill.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
>> index 5f372f6e26fa..4b5c70aaece4 100644
>> --- a/mm/oom_kill.c
>> +++ b/mm/oom_kill.c
>> @@ -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;
>> --
>> 2.25.1
>
--
Thanks,
Ye Liu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-13 9:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 3:06 [PATCH] mm/oom_kill: fix stale comment in constrained_alloc() Ye Liu
2026-08-13 8:43 ` Michal Hocko
2026-08-13 9:50 ` Ye Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox