From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27E5E2BEC2E; Wed, 28 Jan 2026 11:27:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769599646; cv=none; b=NWsTtsX04/U2zALjV5ezaMpZz66BClMr4lOTaabYwWnGhusrg/6KPuc5yLKtk4HgjtoKWVlVolfvhYfPaZgkdr7y02XU9ttOLYdsOsVeWVTHX+WK6+DcUglo69mPnAoqnxu5mAfcOHCjSmiXPfPKg6fpKe5I1stOwxjgBQawyKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769599646; c=relaxed/simple; bh=5tl5UulReo9mfeinlsXovMEDngKOqoqnKHsMOgA3XXg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IOMp9txD46OE8nfqxADam9DeSxKS1+qJ3U/PyiGrHxN5x6llq5K3rV/Ez3Luto2XsNBpPeYDezBxHfKTbWlXuSj7TpVWd+En5U6mFMC7piFMadxF5r6MiEMUSidIbvzMmw0yPP3eFFlx/HXnv+zgL8eVPGCPJqelDt10PV7586o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mz3C0iEm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mz3C0iEm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E518C4CEF1; Wed, 28 Jan 2026 11:27:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769599645; bh=5tl5UulReo9mfeinlsXovMEDngKOqoqnKHsMOgA3XXg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mz3C0iEmV05LCiMxqUUPC533EAwv7WtBXo/e17SkoRbQxRl6PaujEVCoYs/2hjxld Rk7+xGr7CUVtQH4qnGr1qBw93vhwI/1w1f7KLWmfMjMzjjmYM5aD0RmCa5DG/p28+B YWbry/suM5VuO9bHjWh/Qz3LEpn8slbnOrPzoasYeOollKP8VyQ2bmXL/ZrU2lWNVU WHZrERuRiGcHUvO9u1yHv0hska3Jv63+efynKRaT//NMkDFfSZgfNBBzik7HMSXTF9 2KkIlAzlGUFQCOTdWtbPwX1bqJo/m6NEQ/fLxKKINz2jZmzHqIXGP6KWkqGr7wXJim bxRx2rrIFbokw== Date: Wed, 28 Jan 2026 12:27:22 +0100 From: Frederic Weisbecker To: Michal Hocko Cc: LKML , Michal =?iso-8859-1?Q?Koutn=FD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 03/33] memcg: Prepare to protect against concurrent isolated cpuset change Message-ID: References: <20260125224541.50226-1-frederic@kernel.org> <20260125224541.50226-4-frederic@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Le Wed, Jan 28, 2026 at 09:45:03AM +0100, Michal Hocko a écrit : > On Tue 27-01-26 13:45:06, Frederic Weisbecker wrote: > > Le Mon, Jan 26, 2026 at 05:41:38PM +0100, Michal Hocko a écrit : > > > On Sun 25-01-26 23:45:10, Frederic Weisbecker wrote: > > > > The HK_TYPE_DOMAIN housekeeping cpumask will soon be made modifiable at > > > > runtime. In order to synchronize against memcg workqueue to make sure > > > > that no asynchronous draining is pending or executing on a newly made > > > > isolated CPU, target and queue a drain work under the same RCU critical > > > > section. > > > > > > > > Whenever housekeeping will update the HK_TYPE_DOMAIN cpumask, a memcg > > > > workqueue flush will also be issued in a further change to make sure > > > > that no work remains pending after a CPU has been made isolated. > > > > > > > > Signed-off-by: Frederic Weisbecker > > > > --- > > > > mm/memcontrol.c | 21 +++++++++++++++++---- > > > > 1 file changed, 17 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > > > index be810c1fbfc3..2289a0299331 100644 > > > > --- a/mm/memcontrol.c > > > > +++ b/mm/memcontrol.c > > > > @@ -2003,6 +2003,19 @@ static bool is_memcg_drain_needed(struct memcg_stock_pcp *stock, > > > > return flush; > > > > } > > > > > > > > +static void schedule_drain_work(int cpu, struct work_struct *work) > > > > +{ > > > > + /* > > > > + * Protect housekeeping cpumask read and work enqueue together > > > > + * in the same RCU critical section so that later cpuset isolated > > > > + * partition update only need to wait for an RCU GP and flush the > > > > + * pending work on newly isolated CPUs. > > > > + */ > > > > + guard(rcu)(); > > > > + if (!cpu_is_isolated(cpu)) > > > > + schedule_work_on(cpu, work); > > > > > > Shouldn't this in the guarded rcu section? > > > > This is what guard(rcu)() does, right? > > Or am I missing something? > > I am probably misreading the patch. But I've had the following in mind > > scoped_guard(rcu) { > if (!cpu_is_isolated(cpu)) > schedule_work_on(cpu, work); > } guard(...)() protects everything that follows within the same block (here the whole function) whereas scoped_guard only applies to the following scope (here what is inside the {} in your example). So both work. Thanks. -- Frederic Weisbecker SUSE Labs