linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <llong@redhat.com>
To: Gregory Price <gourry@gourry.net>, Shakeel Butt <shakeel.butt@linux.dev>
Cc: Waiman Long <llong@redhat.com>,
	linux-mm@kvack.org, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-team@meta.com,
	hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev,
	muchun.song@linux.dev, tj@kernel.org, mkoutny@suse.com,
	akpm@linux-foundation.org
Subject: Re: [PATCH v3 2/2] vmscan,cgroup: apply mems_effective to reclaim
Date: Mon, 21 Apr 2025 20:35:15 -0400	[thread overview]
Message-ID: <6e7806a7-9ffd-4c7c-b247-934b206088c7@redhat.com> (raw)
In-Reply-To: <aAbbtNhnuleBZdPK@gourry-fedora-PF4VCD3F>

On 4/21/25 7:58 PM, Gregory Price wrote:
> On Mon, Apr 21, 2025 at 04:15:49PM -0700, Shakeel Butt wrote:
>> On Mon, Apr 21, 2025 at 06:59:20PM -0400, Gregory Price wrote:
>>> On Mon, Apr 21, 2025 at 10:39:58AM -0700, Shakeel Butt wrote:
>>>> On Sat, Apr 19, 2025 at 08:14:29PM -0400, Waiman Long wrote:
>>>>> On 4/19/25 2:48 PM, Shakeel Butt wrote:
>>>>>> On Sat, Apr 19, 2025 at 01:38:24AM -0400, Gregory Price wrote:
>>>>>>> +bool cpuset_node_allowed(struct cgroup *cgroup, int nid)
>>>>>>> +{
>>>>>>> +	struct cgroup_subsys_state *css;
>>>>>>> +	unsigned long flags;
>>>>>>> +	struct cpuset *cs;
>>>>>>> +	bool allowed;
>>>>>>> +
>>>>>>> +	css = cgroup_get_e_css(cgroup, &cpuset_cgrp_subsys);
>>>>>>> +	if (!css)
>>>>>>> +		return true;
>>>>>>> +
>>>>>>> +	cs = container_of(css, struct cpuset, css);
>>>>>>> +	spin_lock_irqsave(&callback_lock, flags);
>>>>>> Do we really need callback_lock here? We are not modifying and I am
>>>>>> wondering if simple rcu read lock is enough here (similar to
>>>>>> update_nodemasks_hier() where parent's effective_mems is accessed within
>>>>>> rcu read lock).
>>>>> The callback_lock is required to ensure the stability of the effective_mems
>>>>> which may be in the process of being changed if not taken.
>>>> Stability in what sense? effective_mems will not get freed under us
>>>> here or is there a chance for corrupted read here? node_isset() and
>>>> nodes_empty() seems atomic. What's the worst that can happen without
>>>> callback_lock?
>>> Fairly sure nodes_empty is not atomic, it's a bitmap search.
>> For bitmaps smaller than 64 bits, it seems atomic and MAX_NUMNODES seems
>> smaller than 64 in all the archs.
> Unfortunately, it's config-defined on (NODES_SHIFT) and the max is 1024.
Actually, it is nr_node_ids that control how many reads are needed to 
scan the complete node mask, not CONFIG_NODE_SHIFT.
>
> Is there an argument here for ignoring v1 and just doing the bit-check
> without the lock?  Is there an easy ifdef way for us to just return true
> if it's v1?

Your current patch is ignoring v1 as css will be NULL. It only works for 
v2 with a unified hierarchy unless some users explicitly force cpuset 
and memcg v1 to be in the same hierarchy. You can certainly ignore v1 by 
using cpuset_v2() check.

Cheers,
Longman

~Gregory



  parent reply	other threads:[~2025-04-22  0:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-19  5:38 [PATCH v3 0/2] vmscan: enforce mems_effective during demotion Gregory Price
2025-04-19  5:38 ` [PATCH v3 1/2] cpuset: rename cpuset_node_allowed to cpuset_current_node_allowed Gregory Price
2025-04-19 18:37   ` Shakeel Butt
2025-04-19  5:38 ` [PATCH v3 2/2] vmscan,cgroup: apply mems_effective to reclaim Gregory Price
2025-04-19 18:48   ` Shakeel Butt
2025-04-20  0:14     ` Waiman Long
2025-04-21 17:39       ` Shakeel Butt
2025-04-21 22:59         ` Gregory Price
2025-04-21 23:15           ` Shakeel Butt
2025-04-21 23:58             ` Gregory Price
2025-04-22  0:10               ` Shakeel Butt
2025-04-22  0:39                 ` Waiman Long
2025-04-22  0:35               ` Waiman Long [this message]
2025-04-22  1:00                 ` Gregory Price
2025-04-22  0:10             ` Waiman Long
2025-04-22  0:16               ` Shakeel Butt
2025-04-20  0:31   ` Waiman Long
2025-04-20 23:59     ` Gregory Price
2025-04-21 23:37   ` Shakeel Butt
2025-04-19 17:21 ` [PATCH v3 0/2] vmscan: enforce mems_effective during demotion Tejun Heo

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=6e7806a7-9ffd-4c7c-b247-934b206088c7@redhat.com \
    --to=llong@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=tj@kernel.org \
    /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