From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (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 BE289359A8D for ; Thu, 23 Apr 2026 21:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979111; cv=none; b=W0Q20MBWJX03fAplxe6vbH0E3zpu2WvyzFK4CnGyMVswlYnUTLVnzS6TbmgQ4SRmOX/OWZiOqaGztuCJJfmH6Bk/Sv9eZaEd72VvBWvkF9nOMkDTxbkR+Y8oYUixK3FYiY9Yl5TItgJSPtTAIVS044F7FZbnJAd8YHFquo6byDU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979111; c=relaxed/simple; bh=UMk4lPqE1rni7uC88ZpnKqmNJ5I0L91iMmLJEffhQuc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qSSj4WF3WDQPfwU1JGj187JsZ3n7NsOxUP/JX+duvEljTMQjevSLJoP0+RTFyz024ClEXT+klZ9ygWflB3UsLk1XkULu7RRDThL+oC83mFgU4Jf8OkIbmLczVj+q99pgPKElEEzt44/8vIh81y6269rLrQE7lplOidk9/CHW/nA= 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=PHWzdwYz; arc=none smtp.client-ip=95.215.58.173 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="PHWzdwYz" Message-ID: <31f1f2a2-3fcd-4a65-94b4-f1f2921b2e8d@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776979107; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Srz0VVxSUmFDt3GZ0OvBMTfIQB4Mjhfb10ZHRE2XCCA=; b=PHWzdwYzJQP0OZJwISY2XdMOKhws/SbUmpkvrE7hH/PPmbpHFx06vc23C9lh8bA4H3H2Ml amAhh3EeFuZQBF0VDFuqOU7n+XE4520Wyek+Y3FSCErpnvvmRIjxuPF+TpgARc/85h0QQ+ cJzWEosBgSiHAdJ4sdf+mUtbA67AmCU= Date: Thu, 23 Apr 2026 14:18:16 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] mm/lruvec: preemptively free dead folios during lru_add drain To: Shakeel Butt Cc: linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@kernel.org, mhocko@suse.com, willy@infradead.org, hannes@cmpxchg.org, riel@surriel.com, chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com, baohua@kernel.org, youngjun.park@lge.com, qi.zheng@linux.dev, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, linux-kernel@vger.kernel.org, kernel-team@meta.com References: <20260423164307.29805-1-jp.kobryn@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "JP Kobryn (Meta)" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 4/23/26 11:46 AM, Shakeel Butt wrote: > On Thu, Apr 23, 2026 at 09:43:07AM -0700, JP Kobryn (Meta) wrote: >> Of all observable lruvec lock contention in our fleet, we find that ~24% >> occurs when dead folios are present in lru_add batches at drain time. > > So, when they were added to the percpu lru cache, they were alive but during > their stay in lru cache, they were freed (last non-lrucache ref dropped) or > somehow we are adding folio where the caller drops the reference just after > adding to percpu lru cache e.g. folio_putback_lru() ? Both scenarios can occur. Whether all callers put the folio while it is on the per-cpu batch or putback drops ref from 2 to 1, the batch ref is what remains. [...] > > Overall the code looks good but I do wonder if we can add something similar to > folio_add_lru() and if that would be enough. folio_add_lru() is how it gets onto the batch. But it's still alive at that point - at least one caller ref.