From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (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 9597F2D23A6 for ; Thu, 23 Apr 2026 22:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776984366; cv=none; b=GiRzloWzm8eTQqRq/o8OXp2bB3mjgqqOB2cUMtCO5AOkya6k4xXGHbtTT/o+rz4IBD7wh5xgX9o9B2ZIWGZ6MpqFq93axNCWXRqnjfZjsoJ6fDwHW4jivfPIz8ZfcvH2j8L1xz2ET3CEx7TPXffopIlSiV5+XGwnEXyWp2+CJ3k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776984366; c=relaxed/simple; bh=fcAbRk0g0rkyxuyA7yrtFMYMzhTd5vRx0NfaqpfEVXY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m73xdfzT7hOu98PLa50gxBGzO/NQwTrSFOC1WUuPqFFucXHWUpexjY7CZKaL7zwrwqc2DtffJQ4H2ISAq4wkMSCEuR/s1XYld7+doVseKIYVSUH/WRD5femrrtmPvUB6fCEiosgYc3eGdb3+ft6mZkAUpvaRqqTJSb1pbKdKVOQ= 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=larkBWn8; arc=none smtp.client-ip=91.218.175.185 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="larkBWn8" Date: Thu, 23 Apr 2026 15:45:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776984362; 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=+0mHKBq61/yarwq4Sa7hTm08Lz676EcU0K67E1wCp6I=; b=larkBWn85qeCAy6AWKBJ82KrrH2khVDU88IR6pNIFm1qvU1ygq1VR9BSotmLKRty/o2hz4 1ejZlx8hT5hs+K+eQ2NAIS1Wv+QbN+KRVewdkMwkxIZXYHOmZEUuduUFKIUBKo0Fx9p6Mf mBZx3n+WWlx/Nt43b3qwNgogXSYWbSQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: "JP Kobryn (Meta)" 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 Subject: Re: [PATCH] mm/lruvec: preemptively free dead folios during lru_add drain Message-ID: References: <20260423164307.29805-1-jp.kobryn@linux.dev> <31f1f2a2-3fcd-4a65-94b4-f1f2921b2e8d@linux.dev> 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: <31f1f2a2-3fcd-4a65-94b4-f1f2921b2e8d@linux.dev> X-Migadu-Flow: FLOW_OUT On Thu, Apr 23, 2026 at 02:18:16PM -0700, JP Kobryn (Meta) wrote: > 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. I was wondering which one is dominant. > > [...] > > > > 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. Yeah, I was thinking if we do special checking at folio_putback_lru() to avoid folio_add_lru() at all (only if folio_putback_lru() is the one causing such scenario most of the time). Anyways, that analysis can be done later. So, for the path: Acked-by: Shakeel Butt