From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07A34E7716D for ; Thu, 5 Dec 2024 15:26:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F39536B00B9; Thu, 5 Dec 2024 10:19:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFACD6B0099; Thu, 5 Dec 2024 10:19:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3358D6B00E4; Thu, 5 Dec 2024 10:19:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2C2776B0089 for ; Thu, 17 Oct 2024 13:58:46 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C1BC1120297 for ; Thu, 17 Oct 2024 17:58:35 +0000 (UTC) X-FDA: 82683854316.26.2637717 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf19.hostedemail.com (Postfix) with ESMTP id 34B831A001C for ; Thu, 17 Oct 2024 17:58:31 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ieGWUTaM; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=pass (imf19.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729187875; a=rsa-sha256; cv=none; b=JCLVLDhXAHiW1B7ktV1tnGz7hThc8jTUjUfjAbjmbiK1/Ug//VjJHEnestAVUNby3BQbIL jKC13HAv0YmVwZmNM8cSOGS8M9jdguxPSdXTmZWe5UDUte6EckIm2+kJvF6jgEZCwuKDYl F3MuJyKdJ0bksfidZy4y7DS3ziQMl9A= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ieGWUTaM; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=pass (imf19.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729187875; h=from:from:sender:sender: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:dkim-signature; bh=8VcKf0XycGDY+Rid1o4E677dTgUp3s7OnB/oi3um0GI=; b=sW4SGfZBFL7jsztQdj4XZcE++n8fFbvt+RIsADaKY8I16abn3m9YSORz/O8QdydQVPX4Yu nMnADAbxEyeAENiGS9PwX618zpxbZM42tHPGUSYrEvGdLrwZmZsdS9bFlrx0nCzAvxlcyj xQ5x9V5Hqo6sKy/JVI2nuvrd5oUXglw= Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2e30db524c2so962601a91.1 for ; Thu, 17 Oct 2024 10:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729187922; x=1729792722; darn=kvack.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :from:to:cc:subject:date:message-id:reply-to; bh=8VcKf0XycGDY+Rid1o4E677dTgUp3s7OnB/oi3um0GI=; b=ieGWUTaMFIjSPf3aMQFRpSkNYevWyzqM8xMD9I3/ds1nlVK65+yydrn810o6YTT2kV B8ncpUyfPwrOIesRrTFEjSVS1uchE5itRZDrRR9W17Os0g9sEVPSmIGycX0IrJnsJtAT ye20an4dVXBQDFj89+rx5UzuK085z8h06HK7lZfznDp6kkJg2i8Y+75QVZO0BkjwaJMt AYsB95Mvv+Xpho0jpKaukeOUw7n5gxecx9VTxpSl5eB/vAECDH4inNU5bSnk49BWjKgL vjUHREudRxkaFCyAIr7Z+Z+oPs7ZtBhfpetZdkiK696OLTv02+ob6ONObhkuVljDzl2z wWHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729187922; x=1729792722; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8VcKf0XycGDY+Rid1o4E677dTgUp3s7OnB/oi3um0GI=; b=kRmSsFz8tg/I5kPncsc7xnhCUWF5H7MsHudQ4VJRXkjO5+LNKcb5RNRN33FQLWTsIJ i378mlFxQ9isUGRY8MFyPd/NO5VE7QhB4+oeIN+kxmTsK+nShi704X9KJaKAs1sasKR0 rCw5JtCrQG08A6skP6OJKo+np9aMQ6TJUVFGCdxUHy8oMIiUgwbCMyvJJPvWeQ9MeejG CamE8P9L/jD1tydWAKshuIzFw5XFZGKN5grj2aox6KdtgstENZ0O+bQq3lIGO7qpmIZF jPwP/rccvWDkq0HnmNMnAEiUHQKaYXWmlNVWYrbiuPBQj1XqJiHeTrPkLAfKgaOjtcJD 4arg== X-Forwarded-Encrypted: i=1; AJvYcCUpfHXO7K3N0snSO/6wWD1Tr5fwsFEXKkP3BT8ZhB7OLnwC75IgHRQ1TfY6c8gvW9dCoL8nNDvr+A==@kvack.org X-Gm-Message-State: AOJu0Yxi5IZqBnq/LUTHo0IqxKaeznFJ1OBNWJ1OxUl6Lh8b+Fh/2SlF jkJmzTU1Bu+uSmuAg0oAtCuLnE7+bfIWttrkI6DDPpe0+7m5EblX X-Google-Smtp-Source: AGHT+IHIRyyf06yIo6AYO87aYU+GUid2jBDVbm0CegdCobOuS1xMdbdExXeP+XCMkhl7onCsiRvQZQ== X-Received: by 2002:a17:90a:5ae2:b0:2e0:f896:9d6d with SMTP id 98e67ed59e1d1-2e3152c87a3mr24179725a91.16.1729187922383; Thu, 17 Oct 2024 10:58:42 -0700 (PDT) Received: from google.com ([2a00:79e0:2e14:7:9ecc:1f99:e33e:cc8b]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e55d7bf9a8sm143076a91.13.2024.10.17.10.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 10:58:41 -0700 (PDT) Date: Thu, 17 Oct 2024 10:58:38 -0700 From: Minchan Kim To: Barry Song <21cnbao@gmail.com> Cc: Andrew Morton , yuzhao@google.com, linux-mm@kvack.org, david@redhat.com, fengbaopeng@honor.com, gaoxu2@honor.com, hailong.liu@oppo.com, kaleshsingh@google.com, linux-kernel@vger.kernel.org, lokeshgidra@google.com, mhocko@suse.com, ngeoffray@google.com, shli@fb.com, surenb@google.com, v-songbaohua@oppo.com, yipengxiang@honor.com, Gao Xu Subject: Re: [PATCH v2] mm: mglru: provide a separate list for lazyfree anon folios Message-ID: References: <20241016033030.36990-1-21cnbao@gmail.com> <20241016155835.8fadc58d913d9df14099514b@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspamd-Queue-Id: 34B831A001C X-Rspamd-Server: rspam01 X-Stat-Signature: f3548ru8tpjyagmefhxbn9mcmgh1ki91 X-Rspam: Yes X-HE-Tag: 1729187911-587991 X-HE-Meta: U2FsdGVkX19gW5EvZFxV9/GX1xR7jktdPSU0zwxFFG/sMOUGOIlH2/LrWFxTFb1XWCjv/pr+Y6QlQjIri8RaCX2PHuTL6BY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0HE1zO6/TFv6kUMQlAD8ZgfbdJlTem1V49YXBsYn0Obb5hf47fhav1b5Qxrery8ehnpkKJWKlP8mfrZkNLO8qunyfNxRJv6v7GgU3ef5OS9Nkjlk4ZyG3l5tGQp9LBnlZxq5XDU32ts16m6SZYE4D0EranUoQ1hfw1wFiFbDGUV0Lr6ZHF7etBMIIUwO22ibxz9hJcihmZJm8yldFfXmdE7GD8ozy7qx4+fDmZKsPMqg2HFad9cH+r6H1qVdjVDy3V+tis5QUqKzKEy6my8RdIAP32EXM0ArphCTX4V8fNHU4Bro0UjAHq3SXUfD8c5iry80JXW1ZEQnPaerOOxNN9Qhq5pnLUb+uxrEJ4+Xoiw3CmYp/O34wbRRdb1A3m5CjsyMBwIB7vsD1eRU1YIks0lVqYHj3MUXorp2K4upQQXK7ae6Ffc6hl0GrrAl4ZQpVK6RFIfX0/fDzMqq2O61MbbhQXXITuEXFpfelx1HB/pYkJPKb14gnt1xTotkWu2An/cqJVhimjL1tlNX72soa1ebBbvpVdPYUhRS6OcA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.003486, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Oct 17, 2024 at 06:59:09PM +1300, Barry Song wrote: > On Thu, Oct 17, 2024 at 11:58 AM Andrew Morton > wrote: > > > > On Wed, 16 Oct 2024 16:30:30 +1300 Barry Song <21cnbao@gmail.com> wrote: > > > > > To address this, this patch proposes maintaining a separate list > > > for lazyfree anon folios while keeping them classified under the > > > "file" LRU type to minimize code changes. > > > > Thanks. I'll await input from other MGLRU developers before adding > > this for testing. > > Thanks! > > Hi Minchan, Yu, > > Any comments? I understand that Minchan may have a broader plan > to "enable the system to maintain a quickly reclaimable memory > pool and provide a knob for admins to control its size." While I > have no objection to that plan, I believe improving MADV_FREE > performance is a more urgent priority and a low-hanging fruit at this > stage. Hi Barry, I have no idea why my email didn't send well before. I sent following reply on Sep 24. Hope it works this time. ====== &< ====== My proposal involves the following: 1. Introduce an "easily reclaimable" LRU list. This list would hold pages that can be quickly freed without significant overhead. 2. Implement a parameter to control the size of this list. This allows for system tuning based on available memory and performance requirements. 3. Modify kswapd behavior to utilize this list. When kswapd is awakened due to memory pressure, it should attempt to drop those pages first to refill free pages up to the high watermark by first reclaiming. 4. Before kswapd goes to sleep, it should scan the tail of the LRU list and move cold pages to the easily reclaimable list, unmapping them from the page table. 5. Whenever page cache hit, move the page into evictable LRU. This approach allows the system to maintain a pool of readily available memory, mitigating the "aging" problem. The trade-off is the potential for minor page faults and LRU movement ovehreads if these pages in ez_reclaimable LRU are accessed again. Furthermore, we could put some asynchrnous writeback pages(e.g., swap out or writeback the fs pages) into the list, too. Currently, what we are doing is rotate those pages back to head of LRU and once writeback is done, move the page to the tail of LRU again. We can simply put the page into ez_reclaimable LRU without rotating back and forth.