linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Gang Li <gang.li@linux.dev>
To: Michal Hocko <mhocko@suse.com>, Waiman Long <longman@redhat.com>
Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, rientjes@google.com,
	Zefan Li <lizefan.x@bytedance.com>,
	linux-kernel@vger.kernel.org, gang.li@linux.dev
Subject: Re: [PATCH v4] mm: oom: introduce cpuset oom
Date: Tue, 22 Aug 2023 14:31:41 +0800	[thread overview]
Message-ID: <3ac6b49e-f605-6f8f-ba22-a411269cb818@linux.dev> (raw)
In-Reply-To: <9ba0de31-b9b8-fb10-011e-b24e9dba5ccd@linux.dev>

Hi,

On 2023/8/17 16:40, Gang Li wrote:
> On 2023/4/11 22:36, Michal Hocko wrote:
>> I believe it still wouldn't hurt to be more specific here.
>> CONSTRAINT_CPUSET is rather obscure. Looking at this just makes my head
>> spin.
>>          /* Check this allocation failure is caused by cpuset's wall 
>> function */
>>          for_each_zone_zonelist_nodemask(zone, z, oc->zonelist,
>>                          highest_zoneidx, oc->nodemask)
>>                  if (!cpuset_zone_allowed(zone, oc->gfp_mask))
>>                          cpuset_limited = true;
>> > Does this even work properly and why? prepare_alloc_pages sets
>> oc->nodemask to current->mems_allowed but the above gives us
>> cpuset_limited only if there is at least one zone/node that is not
>> oc->nodemask compatible. So it seems like this wouldn't ever get set
>> unless oc->nodemask got reset somewhere. This is a maze indeed.Is there
> 
> In __alloc_pages:
> ```
> /*
>   * Restore the original nodemask if it was potentially replaced with
>   * &cpuset_current_mems_allowed to optimize the fast-path attempt.
>   */
> ac.nodemask = nodemask;
> page = __alloc_pages_slowpath(alloc_gfp, order, &ac);
> 
> ```
> 
> __alloc_pages set ac.nodemask back to mempolicy before call
> __alloc_pages_slowpath.
> 
> 
>> any reason why we cannot rely on __GFP_HARWALL here? Or should we
> 
> In prepare_alloc_pages:
> ```
> if (cpusets_enabled()) {
>      *alloc_gfp |= __GFP_HARDWALL;
>      ...
> }
> ```
> 
> Since __GFP_HARDWALL is set as long as cpuset is enabled, I think we can
> use it to determine if we are under the constraint of CPUSET.
> 

We have two nodemasks: one from the parameters of __alloc_pages and
another from cpuset. If the node allowed by the parameters of
__alloc_pages is not allowed by cpuset, it means that this page
allocation is constrained by cpuset, and thus CONSTRAINT_CPUSET can be
returned.

I guess this piece of code is reasonable and we can keep the
code as it is.

Thanks,
Gang Li.


      parent reply	other threads:[~2023-08-22  6:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11  6:58 [PATCH v4] mm: oom: introduce cpuset oom Gang Li
2023-04-11 12:23 ` Michal Koutný
2023-04-11 13:04   ` Gang Li
2023-04-11 13:12     ` Michal Hocko
2023-04-11 13:17       ` Gang Li
2023-04-11 15:08       ` Michal Koutný
2023-04-11 14:36 ` Michal Hocko
2023-08-17  8:40   ` Gang Li
2023-08-17 16:45     ` Waiman Long
2023-08-22  6:31     ` Gang Li [this message]

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=3ac6b49e-f605-6f8f-ba22-a411269cb818@linux.dev \
    --to=gang.li@linux.dev \
    --cc=cgroups@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan.x@bytedance.com \
    --cc=longman@redhat.com \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    /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).