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 34BF7C25B7E for ; Tue, 4 Jun 2024 10:25:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A79866B00BB; Tue, 4 Jun 2024 06:25:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A29256B00BE; Tue, 4 Jun 2024 06:25:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C9DE6B00C1; Tue, 4 Jun 2024 06:25:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6526F6B00BB for ; Tue, 4 Jun 2024 06:25:27 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 08AB1A0E34 for ; Tue, 4 Jun 2024 10:25:27 +0000 (UTC) X-FDA: 82192824294.24.02139DA Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf21.hostedemail.com (Postfix) with ESMTP id 55DBC1C0003 for ; Tue, 4 Jun 2024 10:25:24 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf21.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717496725; 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=v/tVeuYmg/0Cf7JSLUHlKqwOtgHxJiF1z0CaB4EFq30=; b=xwEmrSLVorspL1ICR3sp165DYR/OtKirFzNg4cYfUZUS02V859ZiMx62TFDY98cUDZe2c0 4Dml2LgMq6u/3P0h91ih2Nz63avZ9OAMV5Ohny8a0enFHvxqTPffF12/iacubWQD/33P3/ 6FcbEisqSADGIxtsYxEUZ6YrRs5SQEI= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf21.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717496725; a=rsa-sha256; cv=none; b=aOuHU6gxo8rmnJtEi/8f4Fhv6lfz2LVvRCm6SNqYPfPM93hJoz0X0bkgIv/als06/uLaDD kzrpmCZeEV3nxggGiaA4oq89h9j9nd2MKq4OxVXmNtcyVC97YeA8flG47jQ2h8Ti63GDUg tmrGS1W5UXHk8Tsu/A3edwT7p5Q5kcc= X-AuditID: a67dfc5b-d85ff70000001748-54-665eeb91dc3d Date: Tue, 4 Jun 2024 19:25:16 +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: <20240604102516.GB28034@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> <20240604091221.GA28034@system.software.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240604091221.GA28034@system.software.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHLMW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W VpBeYYFUiePbA0BqeAUsJBq/d4DVCAn8ZpQ4eOkcG0RCUOLkzCcsIDazgJbEjX8vmUB6mQWk JZb/4wAJcwpYSrxZ+A1sr6iAssSBbceZJjDyzkLSPQtJ9yyE7gWMzKsYRTLzynITM3NM9Yqz MyrzMiv0kvNzNzECA3dZ7Z+JOxi/XHY/xCjAwajEw2uxMjZNiDWxrLgy9xCjBAezkghvX110 mhBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFer/DUBCGB9MSS1OzU1ILUIpgsEwenVAPjqp2ZbG/D FzDarxI5Mpc/VTGtSvWevZfvpear79PuV5lNqWfa8GfuF2WPsE1BU7PPaUs8ERGtFttt19d9 xbZw/pb7XO++qV+/Oevplx9nli92nmzHm83LumNG5OL6ZYUn7pQ8dJn20m7VneMJAcHlvw0e 5TLvv/zyg+3/DXtnJM74GlJaUVo3XYmlOCPRUIu5qDgRAM3vjUFYAgAA X-CFilter-Loop: Reflected X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 55DBC1C0003 X-Stat-Signature: egcqbtwspsdx3dkd4t99tfh5bu5uzxwa X-Rspam-User: X-HE-Tag: 1717496724-13017 X-HE-Meta: U2FsdGVkX18L16YToW6Gdy3lpmE0LrnR2odQ3w02B5IUt+9phxMQ5XecH0QlAh85DOKpRYbZ63eRVkE9Uly+C2uyViArPgUtEVDjoFwdOghAdOAPLcFKVqFt0R72Tiqpb8esa83G1gy/NPgB8xA2FPOJwhewSmOVyLsQ6sRiE67cZIcmYNZtA6uyapRW1qtAqSS+bYg8eEJEe81N/UAKqD9J0+qe8j1p60TwG+mjSIEtAou7twop58L5ZOC31qlADrtC91v4A6w1dM5SUKgUXd5e1mdTXDyZBldOsstTl0z9KEiyd0qquWpECPew5CSZOHHlkohZwotvPCGE9Q2pzzt/D64CyEohY131/VmFgiowcmR6XjEEndw9mAHLElJJaD0Jnal/zmZ3euYMzKazypotr9CNV4yMHt6jZQzMj4Q4VkQYhQFq3MUDZEK9hR00YPrk9Uj+QmfZNPNhPq1koaECV5SZDo5I/n4S3e+W/uvVcGS3o2AnKN4kGAmUT4wz90UEli/tCbNBUiQW1SSR0i3OCVjTnJD9Qxuldov8q9KiM1mLDzqpstgX26kAbB1K9KE6FhK4e43p7ohi3sW5cgKl51gbdpcHk8yOVR3gpH3IfIiQctDoZP3vBVwUbLo9zDRX7ETTo0tvgtCBTrNLufD9cp/wj2wGaFId0lZEf8i998q3U6f0jnkYP74S2HPBYWOKQ65JZ7/Wm5dWihWeMwxKPxQDR8TrFwNjCm5cTp+6F1EK5DoDD+lGMhA8Pub0lI4ajmOd386/WdsNMcrJ1HHBxNxrugFVsXe2fGNp29vgm53UOh6CfokQixNTRDeYtJrKEXQbGXaD3+ygG2VTnJ1VLeGb7kQtVmHVOnDUGkIZXNRatEOiDSVHLp0GXRT2mfY5jQDbvuYaUwv+E6u5MYSzXacX2YkP4BhyESDRhSZ/ettTZTpMpKyBk8Bhx7l1ccKyjkkRi2ad9zhdxp1 Pym8j51e vnquRlNfMBMXyGWnpHQmzvthNaVwxW5hvPxBJGaBTpUsGK9x2RGQQp5y6nw== 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 Tue, Jun 04, 2024 at 06:12:22PM +0900, Byungchul Park wrote: > 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. > > > > 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 > > I mentioned "tiering" while I described how to reproduce because I ran > into the situation while testing with tiering system but I don't think > it's the necessary condition. > > Let me ask you back, why the logic to stop kswapd was considered in the > first place? That's because the problem was already observed anyway To be clear.. The problem, kswapd_failures >= MAX_RECLAIM_RETRIES, can happen whether tiering is involved not not. Once kswapd stops, the system should run without kswapd even after recovered e.g. by killing the hoggers. *Even worse*, tiering mechanism doesn't work in this situation. I hope what I meant has been delivered. Byungchul > whether tiering is involved or not. The same problem will arise once > kswapd stops. > > Byungchul > > > 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