From nobody Tue Apr 7 16:16:03 2026 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 412B43AC0FC for ; Thu, 12 Mar 2026 20:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773348821; cv=none; b=QKAksyyf4gZG3AQuxoykFyCFrtspxsoRw0gRv5m4b2qFd2jr9/NukRUhNjrO6MGstHXIFuFgHwpczEIgVsUEtW5PFonoXcaCdxbB7F2FWUmIpgW2tSdcZ1rrrVgIePKAj9e12xY3jg2zDj917EmKwYmWvxZBTg2Rf+wjMUpazdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773348821; c=relaxed/simple; bh=lXGs8kmFC+AdsUro3ZawPlwIzcatYTm8zi/IbrDcSnc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t7UsKgPQUiT5YcnIYDl5zs8qgVKLQtRCZmblC4QrxDqcCO7D6bWTYqG63rOUJd4Ks6HElkQb8NTae3Xhn+tz3+kH6p+VeZtvsBxaLROfaILMDKGlyACa3NesKY3bMJPgOLv17pQwONfWNP/50CouS56dv/B6gqj9qA99gBudS6I= 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=qszlxOle; arc=none smtp.client-ip=209.85.219.47 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="qszlxOle" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-89a465bd7edso11375776d6.0 for ; Thu, 12 Mar 2026 13:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1773348817; x=1773953617; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kXGfWWKzNbxM79mVGdQBIJH3/Y1RdaXH5DLrm3GtnoY=; b=qszlxOleg9F8YFov+eLvmhdxBeDe7MgdN96lCJevnBOLnRW1x9UjjGCVEatI2hFo0S 3LJUhsXroXgf9DN9vSZBRRuxIQDOEFqwiXcEvq3HiYBmdf1DdrZecrss2c1yswvcXsB3 zKdLdut1K7MbwBI4J5G9HeXyJooZPOTdSN8805OvojhhQNItkSPHzphRBihKFkVQeG3g bNyxANDoWYqFR+cxfUgNokIHnkEnP4ONzhwY22CHNp+OFliWo5IIrrQYwaCh9KpTHhKv w9pRHFIM+l3XqC6RHWfRCh56wwdEsC6x/EU5b+jcC7Ka72GDHqVmKUkzSRazondaJ5UB Wi6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773348817; x=1773953617; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kXGfWWKzNbxM79mVGdQBIJH3/Y1RdaXH5DLrm3GtnoY=; b=pu8j0jGkR4KWNl8Fnb5mOJ2jYcHK6JKwaSIV3rArlECwpdpRry85nzUAzFZ0DWF/Bc tmoubNVzxSuOM6Vupcyazfa42p4zHCMrCP/6JBDafLCrZmHAubG5PvmGAgNLrqKo4nLE 7Mi36hUPZKfvn9Ip0bEKGZczqVV1wQm8oPifvawmtxV+jJQslrLtNSJ3ZziqzYfOlBRC xdDiY6Sl7pRjsOfH6fTEi4WXL+YmBrAyMcZyKQHpx6Lx5lFaK2i9UYv3yM4jyRZKnQ20 JUwfvHbypTt8XwL+tok9rvAvrhLeDFgdPw13Hb7/Khphkf4uQW0lbt+j4tL4Bq6OCJy5 /48Q== X-Forwarded-Encrypted: i=1; AJvYcCUqdILzNE8ZYs24cnfr+Ho8wSc5xJazAvE4VcR4l+f27LjmxQHY26fOOPTpWO2PfWtme3iGzF3ADYFK/qs=@vger.kernel.org X-Gm-Message-State: AOJu0YwW/JeZbMW1/HOoF1Joh8ikN3ckk21hzpLwwNLhpHXLIt0eBHJt VGdDlw5ZgEkcpkUSw79/eC1X7IegWIDAaZbBkJAGPii3QF/l8WG+Wc7IFOCHdYTLvMw= X-Gm-Gg: ATEYQzzCWcgqWogwB/eNHzSwVL0DNnER+BSVLqOEdsyX8KYsLGmtjyLvCFZQLl2w2kL b7ZWDYqRPLSi+QGeShPDuwD1H+W18qMc0nIVXWOY49zrcnAJts3WJMyVIdesarkir/KV6yPgj3r i4a6+VJARqMnET9HgRGU7qU+IwJ5nlOskLCrj3RmfHcEa+h428wkKoPbCmOOqOZHVUj1prRFhHp L3hZg0HG3Wl1hIcKpAhifa4Jw+IvPCUkbqi1Eovt1bfy+S9bp+vLKUII4DgYdxj4p3cX3PT9U4P 4hvnPecJMvlujT00VOYQmgTwYpEDNjLiX35gR5dLnfki+8lemYXZc2mrvakg9NobihZgREClAML nNf6EFUGxtuzqOOcs3vpkpyJjqPQAtsCUHq8rP4gBt/EuVBfAazoOhxidTU05sobklmJHRgjCBq chGP76qAo+x9+neZWE+3nWvg== X-Received: by 2002:ad4:5c6f:0:b0:89a:6e62:1dd1 with SMTP id 6a1803df08f44-89a81fb92c8mr19060666d6.60.1773348817112; Thu, 12 Mar 2026 13:53:37 -0700 (PDT) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89a65d17023sm42324226d6.49.2026.03.12.13.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 13:53:36 -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 4/7] mm: list_lru: deduplicate lock_list_lru() Date: Thu, 12 Mar 2026 16:51:52 -0400 Message-ID: <20260312205321.638053-5-hannes@cmpxchg.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260312205321.638053-1-hannes@cmpxchg.org> References: <20260312205321.638053-1-hannes@cmpxchg.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The MEMCG and !MEMCG paths have the same pattern. Share the code. Signed-off-by: Johannes Weiner Reviewed-by: David Hildenbrand (Arm) --- mm/list_lru.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mm/list_lru.c b/mm/list_lru.c index 1a39ff490643..4d74c2e9c2a5 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -15,6 +15,14 @@ #include "slab.h" #include "internal.h" =20 +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); +} + static inline void unlock_list_lru(struct list_lru_one *l, bool irq_off) { if (irq_off) @@ -68,14 +76,6 @@ list_lru_from_memcg_idx(struct list_lru *lru, int nid, i= nt idx) return &lru->node[nid].lru; } =20 -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); -} - static inline struct list_lru_one * lock_list_lru_of_memcg(struct list_lru *lru, int nid, struct mem_cgroup *m= emcg, bool irq, bool skip_empty) @@ -136,10 +136,7 @@ lock_list_lru_of_memcg(struct list_lru *lru, int nid, = struct mem_cgroup *memcg, { struct list_lru_one *l =3D &lru->node[nid].lru; =20 - if (irq) - spin_lock_irq(&l->lock); - else - spin_lock(&l->lock); + lock_list_lru(l, irq); =20 return l; } --=20 2.53.0