From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (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 247C82111 for ; Thu, 19 Dec 2024 14:11:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=96.67.55.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734617512; cv=none; b=oYoPFE24UpnOkeKApKdVzF17peCtUJCUGHw9k6X+OfkxqM0J+kER69UadrBzYJh8T0F1suzXsI0TT/VcBwMY4e3OEP5UU23P6YnyYo2LVoyJQzQYz6lfXV2Wbba5ZFLQunREWJTJAEMOmlDw7b0AP8pY5YMtDD9r304ZwS/EU9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734617512; c=relaxed/simple; bh=EhPEHrgmh67POpkhH/RlBlV925WUbUp8eLNuX3AQaqU=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=V3uGyeOksdjLCoTXLRAHSNaWLTGCwECk3A/baxr3+J0lGJFPvOSPtEhSQhMu6rsYKZaaYfxQH9YfKtu7qJsIGA8BOwQD+DyM0+8UtZeWQoz28fmQoVPkV8Foddga1qY3MCGAfC/e/leOuc+vMqt8oQaOVem6/DT2oiNnmsUdMPw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com; spf=pass smtp.mailfrom=shelob.surriel.com; arc=none smtp.client-ip=96.67.55.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shelob.surriel.com Received: from fangorn.home.surriel.com ([10.0.13.7]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1tOHF5-000000005rJ-33Ql; Thu, 19 Dec 2024 09:11:07 -0500 Message-ID: <58d69446edb0e2b3b4edec442043cd0a9748f15f.camel@surriel.com> Subject: Re: [PATCH] mm: add maybe_lru_add_drain() that only drains when threshold is exceeded From: Rik van Riel To: David Hildenbrand , Andrew Morton Cc: Chris Li , Ryan Roberts , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-team@meta.com Date: Thu, 19 Dec 2024 09:11:07 -0500 In-Reply-To: <189f4767-e7c2-4522-b943-b644126bf897@redhat.com> References: <20241218115604.7e56bedb@fangorn> <189f4767-e7c2-4522-b943-b644126bf897@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.1 (3.54.1-1.fc41) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: riel@surriel.com On Thu, 2024-12-19 at 14:47 +0100, David Hildenbrand wrote: >=20 > > +++ b/mm/swap_state.c > > @@ -317,7 +317,7 @@ void free_pages_and_swap_cache(struct > > encoded_page **pages, int nr) > > =C2=A0=C2=A0 struct folio_batch folios; > > =C2=A0=C2=A0 unsigned int refs[PAGEVEC_SIZE]; > > =C2=A0=20 > > - lru_add_drain(); > > + maybe_lru_add_drain(); >=20 > I'm wondering about the reason+effect of this existing call. >=20 > Seems to date back to the beginning of git. >=20 > Likely it doesn't make sense to have effectively-free pages in the=20 > LRU+mlock cache. But then, this only considers the local CPU > LRU/mlock=20 > caches ... hmmm >=20 > So .... do we need this at all? :) >=20 That is a very good question. I think we need to free those pending pages at some point. They can't accumulate there forever. However, I am not sure where those points should be.=20 I can think of a few considerations: 1) We should consider approximate LRU ordering, and move pages onto the LRU every once in a while. 2) When we are trying to free memory, we should maybe ensure not too many pages are in these temporary buffers? 3) For lock batching reasons, we do not want to drain these buffers too frequently. My patch takes a small step in the direction of more batching, but maybe we can take a larger one? --=20 All Rights Reversed.