From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.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 3E898344DB4 for ; Mon, 30 Mar 2026 16:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774889672; cv=none; b=N47jM3zqFjqDAFqEgEyR0Ha6hTsQK8ZxNvwD/G7uiaNHzili9jzfjouBvB6W9TwGiTIEdZrw63297KsnA3r25z8bjQh6LLMIdXfCKeOcLKL5TqHxGPMjqPaGP03hoHKqKF8obeddB8YC76+1dqozyO/IvLixsZawinrK1qfHZFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774889672; c=relaxed/simple; bh=CiZ3SHOBh80eUlZa0ySigxj8GIdEG2vowaH5NCQWrks=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AEgnBOrNUOfQqjrBLrblipd60JdG7VYrO3yC7uCC+Kti5AmFwNd0r9BATsekpz/nV3fQ/SVN44DTUosgF0YOKAtiZFFqrvUSFS4GMzqA3haJnEVERXZBOO1OPM2kGIDcgyoc+CsQG8r5i0C8BBmJVLjpX6VsGUT17DgCLefUBrk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=V0JcSt8a; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="V0JcSt8a" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-8cbb6d5f780so535682985a.1 for ; Mon, 30 Mar 2026 09:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1774889670; x=1775494470; 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=VZuPwKTNPVQjiFtLvrGtZ65+9un4Hd00GfhyViH1PA0=; b=V0JcSt8aDPhZ2ARg1TTAk11vmE+2ySOfcpWKk7TxfxCRZL9z/nwX1GXWPxqTiLIHM9 sF37ao3B4o8h7ahl8jAwP5765Thpd8QT9LcW6ivbCJqQ3o0JrqA/X3LY+ajP9yNzLC0Q 7lnkvCT/KXxjDtCYZ6Pb8KRRdcaOW/mhd9joGMCPc53D7czUC/rnRg+KM0Fxq3Q1b6Nl gmpZs/xEe2gN9CPqSWo3K2UN+ZCrftYSpCdjJMOCZhTPv5l9bGvcvcgcv96uc6p7BRRL xSQ5psFdMZ/F6gnWJCin3d5lD3hUpYLv19HfMEIIgVbPMStXghZ6qt+KwZLfd9T5jfMA Wg2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774889670; x=1775494470; 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=VZuPwKTNPVQjiFtLvrGtZ65+9un4Hd00GfhyViH1PA0=; b=DW1A7+0s1Em6Si1mzSSIxBCYM3nfpCyc32bmoh3sIjLYUfRNHEqZyZH6cN68Is3sAo 3IHRlQ6ZPJIA21jmZYHDE/Fk9VQXNLoV4mGJIpqjX93zYSUKK6drpLEBux+4nrBzQp/S n367JzTQUJNz+RyhyD8FrEJ91864LKQ69Pw4TXiPrKAS6MhM6Lc2PLvGeHKtlf4CZhy8 8RAxHHxgCdoggWmbeqI8jHeXatVAXd8T00c1Su7i9y0nvgyayVbr+H2jSHqmQmVZdl0I iDzjlyItQ3bekZ0MZaeYeE/gDA1EKgFCAt5SHL1X95+o+TzvtWlnMPaqKD+gr1JLZiIk OeBw== X-Forwarded-Encrypted: i=1; AJvYcCV6IbHVvKIIzP66zL33hTYweMoCHpBiEDpUHRZFoy0EZsFJ5X7XveCoX7QZAJkSy45WnKDalFDK6nge+eE=@vger.kernel.org X-Gm-Message-State: AOJu0YzOFI9GjKDhulL/Qig3meiH4WhscBgv2ShNnFp27ZgCStojsTEV OXHRiQUrqTV5YOoshU1O2XYEbJq4yWc8e3nZs2jmt5/2Jx7OhHziAOj2GldYZ2Kqcq8= X-Gm-Gg: ATEYQzzHIM/ATux0BzM/xXz0RLLkKYulh9ZTd6YniZyTauqQbuDJ4Mroeh/sJ/ps8H0 KIcHvnXP491ck7tjTDOPuSy7I6nLdhYZNUA6u7hZKXNzowIgB6RrJAXR+JrIcw70isVhA6X3qaJ 28gq9bXjMuErpgBLLzr2/uvwODQxoVQjIRsjtnFP6h3FQqzMAa9c111inx5szVX1Par+W2XL0ju 8QHvSFRnbEEBwAHonN7r4OpcHNbEVx9ijZSaKeWJjK4e882EhIKwoi81rMjvTPycUA9Qci0D5Ne RJKDEdDOGof+PB1wEayHZPSW0md3/UEHcIdk2G9W4+/ewYQ1F5xk4a9MQRZccg1rp3gdIZ8zbwG T+fcU3ngXImJiq5F2OPkqteXDNUluATa/zrPLwrPECJu1mE8Z8H6398hMXNaGmV3NmYyCfXynbz iwR7JD4fuaYwiLoOLs3bPKNQ== X-Received: by 2002:a05:620a:45a2:b0:8c6:db3a:3735 with SMTP id af79cd13be357-8d01c617239mr1742558885a.5.1774889669945; Mon, 30 Mar 2026 09:54:29 -0700 (PDT) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8d028041f8esm659456985a.31.2026.03.30.09.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 09:54:29 -0700 (PDT) Date: Mon, 30 Mar 2026 12:54:28 -0400 From: Johannes Weiner To: "Lorenzo Stoakes (Oracle)" 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: <58ea360a-54e1-468e-99b5-57b716026088@lucifer.local> 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.