From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 DF7A84DBD90 for ; Wed, 8 Jul 2026 14:57:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522654; cv=none; b=bGk5XZ9sCeIuJBu2xQXQjcrmHORVVz1ScrJjtr/aVm1a6HC9IlUkDg/JKFRGHvHuHyI0yaAkrzpx0mm+9Z5efuN8dJUztSGs2MwgfElBOp3cSyO7BpMXtnYhpBfFwe6aWk2Bqt3mLulSkyTAeKDGBz1FiM95FoID9B1VVegBefI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522654; c=relaxed/simple; bh=YBgoLu7DmLR9DwvABt1BfZtwq5WeN6AKsroIxkJJKkA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=lXX3PmCJVRAUlXs6rG4JUpMLbZ3ejOiiOmH8h7OXKYyu+koIdUUjtrr4xFHjXEdGyszCfYwldj/QkBrh9hkwS/KjplwgUZw6daFiV/VxTDa28qNQhsy5+Vc/3Jip+8nvrx1wSo2B4fqmI8iDoCYi8wroMjwNoXNYIB/ny0nilcM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lK6+f+U6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lK6+f+U6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BE601F000E9; Wed, 8 Jul 2026 14:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783522652; bh=GZa8vw9eM2fM+wbCCDp4SpTWaA3yorJgYmnsImoOKjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lK6+f+U6IiymicFHG6iWIRSOroHgN+5rIAoqosSWNtbmDz1NmriUXwRbiIlgiE3X4 jOLnUnz+90j7kp2lbKg/spiXA5KayOCjcZ8RRDapUFqkBtb539B5uuQwufA+zh2m+s aOq6Bw79rYv4WrElMbIZ/E7ycNsPzUUmPibLV9Hl6UvOXkB+psoJOL/tCu3J0aLs6f whGMOFz7PXhpwzP8aETbk1hxAxAY9RBJKaGrySn2v7qPPAdExgMvS3CtydT0SlkBlT 21ychWsdSEPIzHjG5nnDEybqkkSyCbfYfE/lMIVTTpb2kJqmffC0R88+hBGc0VwoZt RU4tPp7LbNOFw== From: "Barry Song (Xiaomi)" To: david@kernel.org, akpm@linux-foundation.org Cc: baohua@kernel.org, baoquan.he@linux.dev, chrisl@kernel.org, jp.kobryn@linux.dev, liam@infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ljs@kernel.org, mhocko@suse.com, nphamcs@gmail.com, rppt@kernel.org, ryncsn@gmail.com, shakeel.butt@linux.dev, shikemeng@huaweicloud.com, surenb@google.com, usama.arif@linux.dev, vbabka@kernel.org, youngjun.park@lge.com Subject: Re: [PATCH v3 1/4] mm: avoid unnecessary lru drain for wp_can_reuse_anon_folio() Date: Wed, 8 Jul 2026 22:57:18 +0800 Message-Id: <20260708145718.82690-1-baohua@kernel.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <793fe8b9-f5f5-4458-9150-5edbabde44e7@kernel.org> References: <793fe8b9-f5f5-4458-9150-5edbabde44e7@kernel.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=UTF-8 Content-Transfer-Encoding: 8bit On Tue, Jul 7, 2026 at 11:58 PM David Hildenbrand (Arm) wrote: > > On 7/7/26 17:26, Kairui Song wrote: > > On Mon, Jul 6, 2026 at 4:54 PM Barry Song wrote: > >> > >> On Thu, Jul 2, 2026 at 4:05 PM David Hildenbrand (Arm) wrote: > >>> > >>> The other folks should probably re-review this patch that changed quite a bit :) > >>> > >>> > >>> Acked-by: David Hildenbrand (Arm) > >> > >> Thanks! > >> > >> Hi Baoquan, Shakeel, and Kairui, > >> > >> Would you like to re-review the patches so I can re-collect your > >> tags? If not, are you okay with me removing your tags when I > >> send v4? > > > > Sure, no problem. > > > > The only complain from me, and a trivial one is that `in_lru_cache = > > !folio_test_lru(folio)` looks a bit odd. > > I was debating with myself a bit, how to keep it short yet expressive. > > "maybe_in_lru_cache" could work. yes. sounds very good to me. Thanks, Kairui and David. Hi Andrew, Would you like to squash the below change? >From 4ce3a8e95eaa58ca58291ac8c2986f00e0e4db12 Mon Sep 17 00:00:00 2001 From: "Barry Song (Xiaomi)" Date: Wed, 8 Jul 2026 22:46:43 +0800 Subject: [PATCH] mm: rename in_lru_cache to maybe_in_lru_cache !folio_test_lru(folio) doesn't necessarily mean folio is in lru cache. so let's put "maybe" prefix. Suggested-by: David Hildenbrand (Arm) Signed-off-by: Barry Song (Xiaomi) --- mm/memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 5689b7cff76c..631c170f812a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4174,7 +4174,7 @@ static bool __wp_can_reuse_large_anon_folio(struct folio *folio, static bool wp_can_reuse_anon_folio(struct folio *folio, struct vm_area_struct *vma) { - const bool in_lru_cache = !folio_test_lru(folio); + const bool maybe_in_lru_cache = !folio_test_lru(folio); const bool in_swapcache = folio_test_swapcache(folio); if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && folio_test_large(folio)) @@ -4188,9 +4188,9 @@ static bool wp_can_reuse_anon_folio(struct folio *folio, * KSM doesn't necessarily raise the folio refcount. */ if (folio_test_ksm(folio) || - folio_ref_count(folio) > 1 + in_lru_cache + in_swapcache) + folio_ref_count(folio) > 1 + maybe_in_lru_cache + in_swapcache) return false; - if (in_lru_cache) + if (maybe_in_lru_cache) /* * We cannot easily detect+handle references from * remote LRU caches or references to LRU folios. -- 2.39.3 (Apple Git-146) > > -- > Cheers, > > David