From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 60AC842E8F4 for ; Tue, 7 Jul 2026 15:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783437724; cv=none; b=OYy2xYy7gzwwQvcanAdenFKCqlwmuJG0oFkW1ON4JGxRXfYU+DxluST/3AtaxeEE6soP5QVKVmZpH+Nh2AYBMl3MvZq3svLB2VjgEhwuucE3J5tom72eGeLuNwCf1kcj5dk2yHlcJGOHLsx6uXBuU7XUe+OFPL1eIOcZH5TxpdE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783437724; c=relaxed/simple; bh=R/zPKReyglyqWtc8dI/j1s+YUprPzWR0cktow1FSnyE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VeUtRHcACcH0BH4AKqwOAUrYGf0b5xQokfr82UEsgMCtYYA1HN5LTDLmIn8NtTrNtruKY1LWfh/GTbUEkQcMfxA886CvyoQW5e7zBuB5FCL10mG7rG9sO71MEFbZQJvpD4Z1K/QYYfta0ZEXQWs8dmNiE5A95knIWxpmRh9nZ1w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=T2vOWI17; arc=none smtp.client-ip=95.215.58.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="T2vOWI17" Date: Tue, 7 Jul 2026 08:21:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783437713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fZqNR/hJXyHATC8osIHWTwdsl59/ylbDsciT2VvP7vg=; b=T2vOWI17ZaQmdSdcTfCIq8RSHmwO1JxMP+uS0DshR7eLGTIruOYdwVJhBg4rsQ+yP7YCEy tVn7G5NKc/4cfFHNY3AnOjDNirTR4OXin3Bh/koAzLcsRgac1epGqj/A0SLwmEkKGbBkVc GL2bNfd9Xm+0SVTXxLJubUZCOMqRbso= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: "David Hildenbrand (Arm)" Cc: "Barry Song (Xiaomi)" , akpm@linux-foundation.org, linux-mm@kvack.org, baoquan.he@linux.dev, chrisl@kernel.org, jp.kobryn@linux.dev, kasong@tencent.com, liam@infradead.org, linux-kernel@vger.kernel.org, ljs@kernel.org, mhocko@suse.com, nphamcs@gmail.com, rppt@kernel.org, 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() Message-ID: References: <20260701235955.36126-1-baohua@kernel.org> <20260701235955.36126-2-baohua@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=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Thu, Jul 02, 2026 at 10:05:48AM +0200, David Hildenbrand (Arm) wrote: > On 7/2/26 01:59, Barry Song (Xiaomi) wrote: > > There is a case where `folio_ref_count(folio) == 3` and > > `!folio_test_swapcache(folio)`. In that case, both > > `folio_ref_count(folio) > 3` and > > `folio_ref_count(folio) > 1 + folio_test_swapcache(folio)` evaluate > > false, causing an unnecessary local LRU drain. > > > > During an Ubuntu boot, I observed over 5,000 redundant local LRU > > drains. For a kernel build with a minimal configuration, I observed > > more than 20,000 redundant drains. > > > > Fix this by checking against: `1 + in_swapcache + in_lrucache` > > instead of hardcoding `folio_ref_count(folio) > 3`. > > > > Suggested-by: David Hildenbrand (Arm) > > Reviewed-by: Kairui Song > > Acked-by: Shakeel Butt > > Reviewed-by: Baoquan He > > Signed-off-by: Barry Song (Xiaomi) > > --- > The other folks should probably re-review this patch that changed quite a bit :) > > > Acked-by: David Hildenbrand (Arm) The code looks much better and Barry can keep my tag.