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 DBAC1C25B78 for ; Wed, 5 Jun 2024 02:19:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F2A16B0082; Tue, 4 Jun 2024 22:19:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A32E6B008A; Tue, 4 Jun 2024 22:19:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56A2E6B0096; Tue, 4 Jun 2024 22:19:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3A1336B0082 for ; Tue, 4 Jun 2024 22:19:13 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E197A40EE5 for ; Wed, 5 Jun 2024 02:19:12 +0000 (UTC) X-FDA: 82195227744.08.1AD3380 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf23.hostedemail.com (Postfix) with ESMTP id 36D9E140013 for ; Wed, 5 Jun 2024 02:19:09 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717553951; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=umutIFr0A+nlg3iVpr/C1lnpv+KPVu7BP+aJqsJekgE=; b=F0HuKBk2GdMkcpqqHoqf8UG+9L3TpqrGi+BnMLCslA1AD1DpiC6IdNSxGytRWSsYkmc5cc jKLO7A9kkVLF4ZTEgsXK8H3GW2oCQYDAgbM+WFdNI1WhxDPO70WeNqrANhs3ncxjKtVYVO 9fOtvmtx1iEWoeWFtYh2clNjVhnJTLU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717553951; a=rsa-sha256; cv=none; b=IVdtn0y65JGNO5YvZ5avNuge6QfYRBwVDRzI9yWQq+DvANh34yNNQn2CJZHk5Z7NFfVzpl g5hx7PHJBhEJ4PE4TEpx1Cv+rYLjyhlSOgl4Gpkyfe0zjbac8IBsMWU7VryVWCowcrZeJ/ 0DnBd7LIXmkGOgVmTpE1d9g2piC2nvs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none X-AuditID: a67dfc5b-d6dff70000001748-b9-665fcb1bc2af Date: Wed, 5 Jun 2024 11:19:02 +0900 From: Byungchul Park To: "Huang, Ying" Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, hannes@cmpxchg.org, iamjoonsoo.kim@lge.com, rientjes@google.com Subject: Re: [PATCH v2] mm: let kswapd work again for node that used to be hopeless but may not now Message-ID: <20240605021902.GC75311@system.software.com> References: <20240604072323.10886-1-byungchul@sk.com> <87bk4hcf7h.fsf@yhuang6-desk2.ccr.corp.intel.com> <20240604084533.GA68919@system.software.com> <8734ptccgi.fsf@yhuang6-desk2.ccr.corp.intel.com> <20240605015021.GB75311@system.software.com> <87tti8b10g.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87tti8b10g.fsf@yhuang6-desk2.ccr.corp.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2IX IyeHhICJxKW7u9lBbBYBFYm5L8+zgNhsAuoSN278ZAaxRQQ0JD4tXA5Uw8XBLLCWUeLI1RbW LkYODmGBVInj2wNAangFLCRO35rMCFIjJLCeSeJHz0t2iISgxMmZT8CGMgtoSdz495IJpJdZ QFpi+T8OkDCngJ3E60m/mEBsUQFliQPbjjNNYOSdhaR7FpLuWQjdCxiZVzGKZOaV5SZm5pjq FWdnVOZlVugl5+duYgSG7rLaPxN3MH657H6IUYCDUYmHd8evuDQh1sSy4srcQ4wSHMxKIrx+ xfFpQrwpiZVVqUX58UWlOanFhxilOViUxHm9wlMThATSE0tSs1NTC1KLYLJMHJxSDYz7ll+4 Z8p9K/L73U+pjK2aNadbNq3y8o/YO4Vrth3j2jIm9vqXIslZLrZlXsXm1xrjd8p8ervk7LxF PVPPstpIL0s8+G6d500WvgPWIRFVvWdX57V7nJ9k3fuObaMvo2HvEc1JCWp2pyoen9d56bZE bjvLsWcqjX5feTwWbjP7qLO2YlPmbDslluKMREMt5qLiRADujAtHWQIAAA== X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: zswifapqudzxrcc1qoomeshtouf7is66 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 36D9E140013 X-HE-Tag: 1717553949-899508 X-HE-Meta: U2FsdGVkX18b4dOKZ/ucCSy1zUtlAEv7MLUjhu6hUslMKAlUBx/XwsWaBmGCfFi2OHkewZ+jCXi52bBeAN01wQZkgG5svNqkTpTs/AXfA1IPajyF/05qMb8IInfcwEBKCEYzuuEPxdkKmEkcnX4pjBM0AlCkk3QsN7J+XpNIs3kDnxbz+K9pm/P4hiKWTA5OqeGwx2RNz+1nd6RyNEWNDrn2P0Twwh+fsxzvF7LfZGD2rSApR17w/DEa+gbctocKMJTGLxxbf/5r0CL0AdgZn1Y3q7D8EbOvRjfPIazIsU04cCqttpIYwPbgU57tReoupHIVCvtX54ueZljIzdS/Z6h/Xu936Jf+I2JX8QeTBAeRbIeA8sSgvPobgyIX33oqPyKOki81YmvWba/bOxzODjAqtuar1+fYyVvZJk6PYNrMcA7lWfsFo/fFXP3zh1NHbQ4QRdkfJyk3ANwsfWUUNFyvxthvVO954vBKsfNvFzUHqUVxYuAVjukHVteQUSoSHZUh9ZnAubGA7Ak1m4zYi77xrgEq3V6d9FpKUadzSKi5ZuY0uA7aHcspVxUVnc4SQcMBYz8nXaGl1qoZaxef1sonxuSuAvS+lUuyS8ibNFlMyPKKguvNuz2vYKML/cg8O0K1mzdQ+qN4+OqeJ7+DgWXi/UaMs78sEnSQob6OB+Jvm1aOSuU16FS323+IaBTt7zgTCRnkN4zlAr6O/+eL8BS/rOACizy0n2FQwgzXGFKWhD1nlyEEcXw9vkiXJtj8JYx8LniAvPfaLSm7VV/KXp/XCk3FVcJncnGJsPpEprlzpW7AkxEA8T8k9m65zBjMpS+EhfxsuAVztb07dEmsddtrAD5zpAcVIIrhYj4OdViUhbT9+DFZtWNaKqqTHQg7KkXGJezlEtIyNdms9SOH9A7SUFViHIQvtRJ0alFqNzCyAS1+EHXOKNaggJX6XEXfyFyvXNZXDDkQJXhIQg9 wXh/EfQg adDCQNA74efnKPzcS/IvwXwrlLMnK7p2kPHtJoZVgU4JOCwtxp6HfCMxIww== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Wed, Jun 05, 2024 at 10:02:07AM +0800, Huang, Ying wrote: > Byungchul Park writes: > > > On Tue, Jun 04, 2024 at 04:57:17PM +0800, Huang, Ying wrote: > >> Byungchul Park writes: > >> > >> > On Tue, Jun 04, 2024 at 03:57:54PM +0800, Huang, Ying wrote: > >> >> Byungchul Park writes: > >> >> > >> >> > Changes from v1: > >> >> > 1. Don't allow to resume kswapd if the system is under memory > >> >> > pressure that might affect direct reclaim by any chance, like > >> >> > if NR_FREE_PAGES is less than (low wmark + min wmark)/2. > >> >> > > >> >> > --->8--- > >> >> > From 6c73fc16b75907f5da9e6b33aff86bf7d7c9dd64 Mon Sep 17 00:00:00 2001 > >> >> > From: Byungchul Park > >> >> > Date: Tue, 4 Jun 2024 15:27:56 +0900 > >> >> > Subject: [PATCH v2] mm: let kswapd work again for node that used to be hopeless but may not now > >> >> > > >> >> > A system should run with kswapd running in background when under memory > >> >> > pressure, such as when the available memory level is below the low water > >> >> > mark and there are reclaimable folios. > >> >> > > >> >> > However, the current code let the system run with kswapd stopped if > >> >> > kswapd has been stopped due to more than MAX_RECLAIM_RETRIES failures > >> >> > until direct reclaim will do for that, even if there are reclaimable > >> >> > folios that can be reclaimed by kswapd. This case was observed in the > >> >> > following scenario: > >> >> > > >> >> > CONFIG_NUMA_BALANCING enabled > >> >> > sysctl_numa_balancing_mode set to NUMA_BALANCING_MEMORY_TIERING > >> >> > numa node0 (500GB local DRAM, 128 CPUs) > >> >> > numa node1 (100GB CXL memory, no CPUs) > >> >> > swap off > >> >> > > >> >> > 1) Run a workload with big anon pages e.g. mmap(200GB). > >> >> > 2) Continue adding the same workload to the system. > >> >> > 3) The anon pages are placed in node0 by promotion/demotion. > >> >> > 4) kswapd0 stops because of the unreclaimable anon pages in node0. > >> >> > 5) Kill the memory hoggers to restore the system. > >> >> > > >> >> > After restoring the system at 5), the system starts to run without > >> >> > kswapd. Even worse, tiering mechanism is no longer able to work since > >> >> > the mechanism relies on kswapd for demotion. > >> >> > >> >> We have run into the situation that kswapd is kept in failure state for > >> >> long in a multiple tiers system. I think that your solution is too > >> > > >> > My solution just gives a chance for kswapd to work again even if > >> > kswapd_failures >= MAX_RECLAIM_RETRIES, if there are potential > >> > reclaimable folios. That's it. > >> > > >> >> limited, because OOM killing may not happen, while the access pattern of > >> > > >> > I don't get this. OOM will happen as is, through direct reclaim. > >> > >> A system that fails to reclaim via kswapd may succeed to reclaim via > >> direct reclaim, because more CPUs are used to scanning the page tables. > > > > Honestly, I don't think so with this description. > > > > The fact that the system hit MAX_RECLAIM_RETRIES means the system is > > currently hopeless unless reclaiming folios in a stronger way by *direct > > reclaim*. The solution for this situation should not be about letting > > more CPUs particiated in reclaiming, again, *at least in this situation*. > > > > What you described here is true only in a normal state where the more > > CPUs work on reclaiming, the more reclaimable folios can be reclaimed. > > kswapd can be a helper *only* when there are kswapd-reclaimable folios. > > Sometimes, we cannot reclaim just because we doesn't scan fast enough so > the Accessed-bit is set again during scanning. With more CPUs, we can > scan faster, so make some progress. But, yes, this only cover one > situation, there are other situations too. What I mean is *the issue we try to solve* is not the situation that can be solved by letting more CPUs participate in reclaiming. Byungchul > -- > Best Regards, > Huang, Ying > > > Byungchul > > > >> In a system with NUMA balancing based page promotion and page demotion > >> enabled, page promotion will wake up kswapd, but kswapd may fail in some > >> situations. But page promotion will no trigger direct reclaim or OOM. > >> > >> >> the workloads may change. We have a preliminary and simple solution for > >> >> this as follows, > >> >> > >> >> https://git.kernel.org/pub/scm/linux/kernel/git/vishal/tiering.git/commit/?h=tiering-0.8&id=17a24a354e12d4d4675d78481b358f668d5a6866 > >> > > >> > Whether tiering is involved or not, the same problem can arise if > >> > kswapd gets stopped due to kswapd_failures >= MAX_RECLAIM_RETRIES. > >> > >> Your description is about tiering too. Can you describe a situation > >> without tiering? > >> > >> -- > >> Best Regards, > >> Huang, Ying > >> > >> > Byungchul > >> > > >> >> where we will try to wake up kswapd to check every 10 seconds if kswapd > >> >> is in failure state. This is another possible solution. > >> >> > >> >> > However, the node0 has pages newly allocated after 5), that might or > >> >> > might not be reclaimable. Since those are potentially reclaimable, it's > >> >> > worth hopefully trying reclaim by allowing kswapd to work again. > >> >> > > >> >> > >> >> [snip] > >> >> > >> >> -- > >> >> Best Regards, > >> >> Huang, Ying