From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (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 058503B0AF5 for ; Thu, 12 Mar 2026 20:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773348814; cv=none; b=rVqHVn+hU5FfFt6I459bQ8dMGaCtIflsVGbs2qZ4HtG/yBocUE+yMXG20gHEGGnSa5SyPnaPAcbfmqWvC/59bC94NYrHM2Cqdks8g/x221hlMyG5rqzWXNm7P4TBoQM34TYQQmVRi+60HnFM+tb14QFZMZ9f139jldkpF38G2YM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773348814; c=relaxed/simple; bh=MItLQoGC7AwIES9YzX7k9ZSB1QpT+3JYMZTovDe4lbc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sIJLRw2dPOSFl8SXOdbrKfB9o5JojQ2IPngUZtBLzz66b7F1SwYjL4aeIWpgvKGXl20vW35aTrMbwiXKVbENC8TDKaEXTvCmxGncTw15tU9eyG91sGsi6vtq2M4dQaz+3ds8jZmN1qn2pXVDwtPINaBx4AjqAIMCP7ajvpUVXG4= 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=d9XxqM8o; arc=none smtp.client-ip=209.85.222.177 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="d9XxqM8o" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-8cb38e86cf2so154340185a.1 for ; Thu, 12 Mar 2026 13:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1773348810; x=1773953610; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QV2CFG026yzLrH1KSoyywnXP2sha9Q6L0bPhjH46BqY=; b=d9XxqM8o3RSh0cgIUumuBn18DwC982ZQhH6jR+cgtmIQm/eGqZDv/dLp0mUdoPzQk2 GxGsMXctbiBnDlSw48ibnEC4ZYGynUhFHePYclR0rON+M7F+WKmB2FxkwnTBt0lS1Jqc tQp/iUXhoq5E9pj2gB71fYEgBhq5e6URrO0T+o+Pia1b+6/5aevxEMQtzNJn7FG9gdli bglgUtg3HV1xEbOHwsqIwz2TB6/5u2AXprCxAJO6c8cpaW0ehv40hb03ijVJK3gKTLdq G14yOQIpGWvSYCFBJBbGmk/b4xI3HoiFrVc1Yidhyj/qzgKf3e3Cb5FrdSgE2zfFBppn E8Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773348810; x=1773953610; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QV2CFG026yzLrH1KSoyywnXP2sha9Q6L0bPhjH46BqY=; b=TOIeY1q7jAga8XHj6eu0zlR3N6bLmAALsBhJ1MEH+BNrIVisp88jE0/bLTCai0ry+N hnUEmE2Xt5QlGYJ/A0X31BaTpMjq04mt5aFllJQgXzTxPs3Jw3nvKUFx7gRIrZdiaN+1 ZrfLFqGEMTdtQtS3tNgKpyPf/VE2BWxlb6zT21jE2EXhrL/vnL4GmLs5OAWU8alyknRO eeJwnumQj5RisE+mZpCx+8Jz8moVo/3eFXgnwdqTq3flP38f34iJBW8ZD/TfbXn7LJd4 2068rf8PtKMvFfCr9U+6ZbxdkMkGpNr0E/pkz2f26I7l+HdXsG35/M0oG2dJPMM9kSCe N9Qw== X-Forwarded-Encrypted: i=1; AJvYcCWxerMDmfPpYkCyXA+o8Xd4aDKAWAYdNN2klB3H1nW4cu73u+OmrNEvVE8Z8Uk3m3wr5G3USCk5MP3DTY0=@vger.kernel.org X-Gm-Message-State: AOJu0YwbbJF1zVUld4dbtf5U/pABEnMBsl3ABfA9g5F0yIsff7fR6h8G SSpCFdcY4ICSnroU/y9O+o++wdN0Fa8K3iqCj6Drr4uBQbhuH/CJzbW75Xb7AKms7dVns8O2eXR nn1Jp X-Gm-Gg: ATEYQzxRL3Anh0CybeFVAGsFVD4MJRHRCE36Ph6YqdZ8RRPejj4QIsf9459LfLBSbV5 aCvsFbDOuFj9OpYi05pOLGIHI9WFDG+nNtk82lomB7e4OclmkGDNlR/tLVwt/NddjB7GII4baOy 6wVPa88u89ahGrW1THdZ6K5XfIdyvL+iTnB8rlEhg9CKpRJimscMj/w3o3SVad4lhOYu+hDbAyI OkjlgfOjaw2jsCwSWKAjsNRWyXZmNDQP4VaacXAGrfUy+xjMHUtK8oDf+QsSgYlVy8ziLgbT6Y5 oW9Y3Rs4te6Bb3LOOSNZuPv4aXYa0mcWbsqil2FGbca9l8HCAg1bPlVX0LVeGiizsbXj5nlYJvJ WjB1QuxtfZETGFMc3KLmXZ4Bn+nEREt1PHVNjrBgrwkjpc8PcmhYmCGoRBjncC3A0Fybqu9LnyL r7Yi0eze1PflpbHwvzkgfgOw== X-Received: by 2002:a05:620a:3709:b0:8cd:9599:b7c7 with SMTP id af79cd13be357-8cdb5a5c90bmr169145985a.23.1773348809607; Thu, 12 Mar 2026 13:53:29 -0700 (PDT) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8cda1fbd120sm412847685a.7.2026.03.12.13.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 13:53:28 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: 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: [PATCH v2 0/7] mm: switch THP shrinker to list_lru Date: Thu, 12 Mar 2026 16:51:48 -0400 Message-ID: <20260312205321.638053-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is version 2 of switching the THP shrinker to list_lru. I fixed the lockdep splat Usama had called out - with explicit rcu_read_lock() annotation based on list feedback (thanks!). I also split out the list_lru prep bits, per Dave's request, to make review a bit easier. I was initially looking at mm/shrinker.c and the scalability issues resulting from shrinker_alloc -> for_each_nid -> for_each_memcg. In the process of working on that, though, the open-coded THP shrinker queue started getting in the way. Switching it to list_lru seemed like a good bugfix and cleanup (9 files changed, 140 insertions(+), 300 deletions(-)) in its own right, so here goes. Patches 1-4 are cleanups and small refactors in list_lru code. They're basically independent, but make the THP shrinker conversion easier. Patch 5 extends the list_lru API to allow the caller to control the locking scope. The THP shrinker has private state it needs to keep synchronized with the LRU state. Patch 6 extends the list_lru API with a convenience helper to do list_lru head allocation (memcg_list_lru_alloc) when coming from a folio. Anon THPs are instantiated in several places, and with the folio reparenting patches pending, folio_memcg() access is now a more delicate dance. This avoids having to replicate that dance everywhere. Patch 7 finally switches the deferred_split_queue to list_lru. Based on mm-unstable. include/linux/huge_mm.h | 6 +- include/linux/list_lru.h | 46 ++++++ include/linux/memcontrol.h | 4 - include/linux/mmzone.h | 12 -- mm/huge_memory.c | 330 +++++++++++++------------------------------ mm/internal.h | 2 +- mm/khugepaged.c | 7 + mm/list_lru.c | 193 ++++++++++++++++--------- mm/memcontrol.c | 12 +- mm/memory.c | 52 ++++--- mm/mm_init.c | 15 -- 11 files changed, 309 insertions(+), 370 deletions(-)