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 B17663FFADD for ; Wed, 1 Apr 2026 14:43:14 +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=1775054594; cv=none; b=HBnjBIfJJ/TmF+VLWkBNanR5PSxZ7rTRmftCHDE/VWFsbkXTkRN0cHW6W2Vjx15ev7UfS/R4yzEOrN1+2UbqT9fXCpkJ4jBDLvlpngByvI9MOpWetahzaETKn4AaY+BzKoyDogCsQZSMycMBAv/MwBiZ9/0pFmqyyT1U6je0pH4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775054594; c=relaxed/simple; bh=Ryrbj2IiZ4oRSg/YxtGqfJDYuXiLqJFKUZfZB+svoLE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OTRv6oj8boE2/xwOiujv0uGHEiv8LQiTm8i9dXcU0KQrdxow4huPTqITHAFHYWs9yHa+l9dSsssG19Gl/bpf3exwrOYdQZzymA+HFXkxtLow8qxpWx+lx4ZYfrqRaiP9Yeh9uVeFq4HkWI63s/aqaMNCkRKfHe6tLYuLn/IcMEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QRWI7TCY; 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="QRWI7TCY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6624C4CEF7; Wed, 1 Apr 2026 14:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775054594; bh=Ryrbj2IiZ4oRSg/YxtGqfJDYuXiLqJFKUZfZB+svoLE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QRWI7TCY2OEibcAM+J9UNMnBQJseoKKaYdIG2FL84fqqQRus5j4dSxuNq9MLClz+j y402AZmpGPvw5gjZgu9NMATWREV3TnDFAOaIqU7YgW6uI3VZBE0HrnPUp0V4V4ERen REAj/V/owhJzJuVhcxXVqryWBB1W/4Hi+diLvc5E3jIcbYBVRlEeA0PxOEDGstklW3 j7P3dxGO1VRQu52R3i42R2086LRfC/Kb5atGPJqA9T0StbvKcOFI75PO46qepHtPx3 2lMyWRavoiL6/aFp2MHbEkfzIxMApmYZKoSB/KHoLznt9Rs5tC+z7GK2tO1NP4/QR5 45OwMtGWNwWhQ== Date: Wed, 1 Apr 2026 15:43:12 +0100 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 6/7] mm: list_lru: introduce folio_memcg_list_lru_alloc() Message-ID: References: <20260318200352.1039011-1-hannes@cmpxchg.org> <20260318200352.1039011-7-hannes@cmpxchg.org> <58ea360a-54e1-468e-99b5-57b716026088@lucifer.local> 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, Mar 30, 2026 at 12:54:28PM -0400, Johannes Weiner wrote: > On Tue, Mar 24, 2026 at 12:01:55PM +0000, Lorenzo Stoakes (Oracle) wrote: > > On Wed, Mar 18, 2026 at 03:53:24PM -0400, Johannes Weiner wrote: > > > memcg_list_lru_alloc() is called every time an object that may end up > > > on the list_lru is created. It needs to quickly check if the list_lru > > > heads for the memcg already exist, and allocate them when they don't. > > > > > > Doing this with folio objects is tricky: folio_memcg() is not stable > > > and requires either RCU protection or pinning the cgroup. But it's > > > desirable to make the existence check lightweight under RCU, and only > > > pin the memcg when we need to allocate list_lru heads and may block. > > > > > > In preparation for switching the THP shrinker to list_lru, add a > > > helper function for allocating list_lru heads coming from a folio. > > > > > > Reviewed-by: David Hildenbrand (Arm) > > > Signed-off-by: Johannes Weiner > > > > Logic LGTM, but would be nice to have some kdoc. With that addressed, feel free > > to add: > > > > Reviewed-by: Lorenzo Stoakes (Oracle) > > Thanks! > > > > include/linux/list_lru.h | 12 ++++++++++++ > > > mm/list_lru.c | 39 ++++++++++++++++++++++++++++++++++----- > > > 2 files changed, 46 insertions(+), 5 deletions(-) > > > > > > diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h > > > index 4afc02deb44d..4bd29b61c59a 100644 > > > --- a/include/linux/list_lru.h > > > +++ b/include/linux/list_lru.h > > > @@ -81,6 +81,18 @@ static inline int list_lru_init_memcg_key(struct list_lru *lru, struct shrinker > > > > > > int memcg_list_lru_alloc(struct mem_cgroup *memcg, struct list_lru *lru, > > > gfp_t gfp); > > > + > > > +#ifdef CONFIG_MEMCG > > > +int folio_memcg_list_lru_alloc(struct folio *folio, struct list_lru *lru, > > > + gfp_t gfp); > > > > Could we have a kdoc comment for this? Thanks! > > And one kdoc comment. > > Your total will be 8.75, you can pull up to the next window, sir. :>) Thanks!