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 236ED3EC2C5 for ; Tue, 24 Mar 2026 11:34:43 +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=1774352084; cv=none; b=NqpwQ0b3rseho16qtd7/Q+uC/Nu/DUnMQRWSP5U+SMjdksM9L8rIqzbRpvGbO8M8I2AeTZvCLdQw984zF7m+0iqQGRC9R3U6OspJbKmXeqMOBH1NHavYoUH3F0BmWEQUCEOXo9hrx1E+VAOG/TpwwL+oL2TuFl435XUz0Bn3yTc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774352084; c=relaxed/simple; bh=0zzhO0uLOjCsBTpsyzUIZ1Vry9zombxb0uEB5AAAy+Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FuDaCJpspTju9mNCfCMHZC2FyQbOGpMh/3rn0pJJWgnH02pglti7gtdIC0hcr2MrOnSi56/1hHSr70jKxTdK7XNlxXTueAIfO9f/odTrYm9xwpeeLZlDirfQr7SKmzmi2wyXFa/xh+RkuC5lZ1Bv6Cht8Mn+Mywnn2YNEXbiN/g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aOGsAJsc; 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="aOGsAJsc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CDF9C2BCB1; Tue, 24 Mar 2026 11:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774352083; bh=0zzhO0uLOjCsBTpsyzUIZ1Vry9zombxb0uEB5AAAy+Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aOGsAJscG+0PMkc6z09jcB0OmTMcBlTR0J7Veu/kzfQuJjMW/GjqLubG9f4uyIhVb zs9yEnRvDpgA+9I4xRRtkESueExLaP3573GS4hUFZKvGIQY63FCPjG5aZMeUzOmaWl XEnjNtEdFlXxCvivQvKQaRhmCyKqzy3zwVvOQycDXs43epIjRKWgOPLvXF07UmIyUW EZwn9HZqAYaqArZ/dH+o3mis9Cl2p1fybm/GxY42Yz3L+P+f42ZLA2g8mgu0wrLw2j ZakbjgPcZlrtnLZ7CnWo/WmlcrN73LYZfTxD4MxUgzTV+fHLKe2yl11afRLs6YaJ3A ajq0806Cvebcg== Date: Tue, 24 Mar 2026 11:34:41 +0000 From: "Lorenzo Stoakes (Oracle)" To: Johannes Weiner Cc: Andrew Morton , David Hildenbrand , Shakeel Butt , Yosry Ahmed , Zi Yan , "Liam R. Howlett" , Usama Arif , Kiryl Shutsemau , Dave Chinner , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/7] mm: list_lru: move list dead check to lock_list_lru_of_memcg() Message-ID: <23c223fb-b4be-4290-8831-1f015bb031f1@lucifer.local> References: <20260318200352.1039011-1-hannes@cmpxchg.org> <20260318200352.1039011-4-hannes@cmpxchg.org> 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: <20260318200352.1039011-4-hannes@cmpxchg.org> On Wed, Mar 18, 2026 at 03:53:21PM -0400, Johannes Weiner wrote: > Only the MEMCG variant of lock_list_lru() needs to check if there is a > race with cgroup deletion and list reparenting. Move the check to the > caller, so that the next patch can unify the lock_list_lru() variants. > > Reviewed-by: David Hildenbrand (Arm) > Signed-off-by: Johannes Weiner Logic looks correct so: Reviewed-by: Lorenzo Stoakes (Oracle) > --- > mm/list_lru.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) > > diff --git a/mm/list_lru.c b/mm/list_lru.c > index e873bc26a7ef..1a39ff490643 100644 > --- a/mm/list_lru.c > +++ b/mm/list_lru.c > @@ -68,17 +68,12 @@ list_lru_from_memcg_idx(struct list_lru *lru, int nid, int idx) > return &lru->node[nid].lru; > } > > -static inline bool lock_list_lru(struct list_lru_one *l, bool irq) > +static inline void lock_list_lru(struct list_lru_one *l, bool irq) > { > if (irq) > spin_lock_irq(&l->lock); > else > spin_lock(&l->lock); > - if (unlikely(READ_ONCE(l->nr_items) == LONG_MIN)) { > - unlock_list_lru(l, irq); > - return false; > - } > - return true; > } > > static inline struct list_lru_one * > @@ -90,9 +85,13 @@ lock_list_lru_of_memcg(struct list_lru *lru, int nid, struct mem_cgroup *memcg, > rcu_read_lock(); > again: > l = list_lru_from_memcg_idx(lru, nid, memcg_kmem_id(memcg)); > - if (likely(l) && lock_list_lru(l, irq)) { > - rcu_read_unlock(); > - return l; > + if (likely(l)) { > + lock_list_lru(l, irq); > + if (likely(READ_ONCE(l->nr_items) != LONG_MIN)) { > + rcu_read_unlock(); > + return l; > + } > + unlock_list_lru(l, irq); > } > /* > * Caller may simply bail out if raced with reparenting or > -- > 2.53.0 >