From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2B8F226CF7 for ; Mon, 5 Jan 2026 21:34:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767648860; cv=none; b=iRoCLmB5xqbUALnoelX0jWck5U2XbIRl1LFTLqCi32bgwgRL3E9n6kqikKGmseviQEwt9QgWBMxaIRjSCUTHgxEHhx4d0zyS2+TtAC6g2mzgjzHN0CJQC8dTCr5ryoAqvF/ZjcV6s7d8LBxhRyIuvx8Pki83XlsWpMar+W5HdVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767648860; c=relaxed/simple; bh=N+H/IYCytCmutkTzoo8ai0zjgOK0uD+Nm2V9f0FC6/k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=frDxKKeCBFVYehQwuVj0Npl6b2K6qyyBopcRKtZyTd1azeQ8Bmj1GCwb1vN3GKagvJuaV8Wxie+ybLjnhrKXGDFRttjvLzxdzRdpzKKSaFZjXq8otseyW625fPFZ1G/q6N4lKvuntrSzwMg0M8Z28VyTDs4XtCzef9fn+svuNf0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=gtPO5ovt; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gtPO5ovt" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2a35ae38bdfso13545ad.1 for ; Mon, 05 Jan 2026 13:34:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767648858; x=1768253658; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=iSWfb6WbMa4GK6t36QHV/UhaSlBkhsogc7OHaBLtTbE=; b=gtPO5ovtiFfdGucp8k4+aSTBcJGTc7Nh9q1M2vFXL9tLnfNTJiC+IVH5wtZZgrfx1h z9DaM8vjYXOUkdq7BUFN0NA3MXiW5kXRWzCsxXGimvr+/FSPh3rSDL1i/nYZFZdp24SZ Tjgfy36FwquxT94Qg0gHjocLEnOAmOuUfcCtDnj5FPe5v2Kl9ggCCK6UO/bSBexPJvU7 UCeQyfBvfabFbIxodI0VLgmBmZqxYnZX0Rh703w7pq5JUqPhZlrPV5CIJCWd6KJDZHr+ mGVh70ia/onjimACLtt6oic5jDkZ0eIlb+xBm7qELz5S4pwwyxPyQAYgCZ+xOt1SRj4F 4u1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767648858; x=1768253658; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iSWfb6WbMa4GK6t36QHV/UhaSlBkhsogc7OHaBLtTbE=; b=cy+wKJzXJ+Wols46dIlSM4RLgB/dQRJIf7/ER9rXBZvcE+wlHK2FyTH3rVTtCL4DSA EMSI+tevbKbnAwvq9MtMIxQ4X3iQBBRHHUhQALcS2Le6SkirPKMvLfYWGl2whN3KslxZ xyBWhaRI6KkHFIF2ZXL8r0S84eqNeFWSXP2jVwoErdJ+QL/dQ/6ySVW7y6vowjo3OKp/ Fv3LxGgoYwWku2jYWMbFu1glSG3IvuSF7mhdRdDZvwSP7BXL+S7uIN4NuPQ5ZZL3hdcs LgUsFb6pCXBmsXV+YmrJgR4Uh7joTumyh4KhVpE1sWQwnUhMu6lJTA7ECinvSA3EHX4T b+CQ== X-Forwarded-Encrypted: i=1; AJvYcCXoixrYw/VqGiaLbGOZT458wlsN6QD/VGpvWXhUdvbFe83r9CwAhbyNer2WIhOb9CJlNXfXgsJoRrDssmo=@vger.kernel.org X-Gm-Message-State: AOJu0YzfGUaadW/kmT7FhCskAeAhl3WtGNXsEjqG1oaGodwMlsB5ayLK c0+esyL+Z9Zfy1mTX8MUEnOft4tfO+6izwCkmRcYqsyfE8dnIAI/m8G5KdakBthmfA== X-Gm-Gg: AY/fxX6r0a+tCVTM+9XOuGRvsQTs/eTs2K7gcHLUVuIepz/349t235SOPVZaelWAcyi UaqjPubH+Q6Fzgc4Qr8QBopwF85FZjvYFGZggVP/oTzFx+CHdaiaRH09Im3d1Udc3AH5yMONtXp BWNImL/dneJ0LGLJR0NzgUWCSUPIONnnNu9U/yaZtIg9X0HC34QiKGXFYEhsW8272LudQGzzZt8 H30cQ6vrUTCDhKDxK31iVLfDwxPHYLo26KGLQRUcp+uwY2/OPKRqdYYI9AQi+Aznz4sZl1E74wy OXd21ojJ21uLDcbEKj6JFIAAudlML1zxgPWwcoRwtTwDy2xrBdXUofi+8tz499K7Rr3u+CT3EeI VaiU+m9nyqWRi8IuaChXc5jf1G5zx7vz6+QRTGsRb55NuJ5JT/M6tzjE2DEekYWThrsZGw+2K2k Si3Zr0JrmBH0RpMET5T7kwhR5PyIsVESsUtKJtLFroSB2J0IK8OknW X-Google-Smtp-Source: AGHT+IE/9wbqXZpR+eCiNUPQoW/brnPaSVUSFMiUwvWM0JW5+HuqfmdEFWty6+NS58ihX3xiYnJu2A== X-Received: by 2002:a17:902:d4cd:b0:2a3:ccfa:c41f with SMTP id d9443c01a7336-2a3e42564ecmr148435ad.1.1767648857501; Mon, 05 Jan 2026 13:34:17 -0800 (PST) Received: from google.com (248.132.125.34.bc.googleusercontent.com. [34.125.132.248]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c4cc02ecfaasm300231a12.14.2026.01.05.13.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 13:34:16 -0800 (PST) Date: Mon, 5 Jan 2026 21:34:11 +0000 From: Bing Jiao To: Gregory Price Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, longman@redhat.com, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, tj@kernel.org, mkoutny@suse.com, david@kernel.org, zhengqi.arch@bytedance.com, lorenzo.stoakes@oracle.com, axelrasmussen@google.com, chenridong@huaweicloud.com, yuanchu@google.com, weixugc@google.com, cgroups@vger.kernel.org Subject: Re: [PATCH v5] mm/vmscan: fix demotion targets checks in reclaim/demotion Message-ID: References: <20260104085439.4076810-1-bingjiao@google.com> <20260105050203.328095-1-bingjiao@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Jan 05, 2026 at 10:54:05AM -0500, Gregory Price wrote: > On Mon, Jan 05, 2026 at 05:01:52AM +0000, Bing Jiao wrote: > ... snip ... > > +/** > > + * cpuset_nodes_allowed - return mems_allowed mask from a cgroup cpuset. > > + * @cgroup: pointer to struct cgroup. > > + * @mask: pointer to struct nodemask_t to be returned. > > + * > > + * Returns mems_allowed mask from a cgroup cpuset if it is cgroup v2 and > > + * has cpuset subsys. Otherwise, returns node_states[N_MEMORY]. > > + * > > + * Returned @mask may be empty, and nodes in @mask are not guaranteed > > + * to be online. > > + **/ > > +void cpuset_nodes_allowed(struct cgroup *cgroup, nodemask_t *mask) > > +void cpuset_nodes_allowed(struct cgroup *cgroup, nodemask_t *mask) > > { > ... snip ... > > /* > > * Normally, accessing effective_mems would require the cpuset_mutex > > - * or callback_lock - but node_isset is atomic and the reference > > + * or callback_lock - but not doing so is acceptable and the reference > > > "node_isset is atomic" is an argument that not taking cpuset_mutex is > acceptable since it's a singular operation against a nodemask (one bit > it checked) - and therefore for a moment in time the node is either > allowed or not (and we make no absolute guarantee of corrected when this > race occurs, we just note that we're corrected). > > nodes_copy is not atomic, and in fact this can result in returning an > empty nodemask if cs->effective_mems is being recalculated at the time > this copy occurs. > > Rather than just saying "not doing so is acceptable" - can you please > change this comment to explain the implications of not acquiring the > mutex a little more clearly? > > Example: > ``` > We do not acquire cpuset_mutex during this check because the correctness > of this information is stale immediately after the query anyway - this > saves lock contention in exchange for racing against mems_allowed rebinds. > > As a result, @mask may be empty because cs->effective_mems can be rebound > during this call. Callers must check the mask for validity on return. > ``` > > The rest of the comments in the function explains a about this, but I > think with this update the comments need a little more rework. > > ~Gregory Thanks for the suggestions. I will reword the comment in V6. Best, Bing