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 37501C25B78 for ; Wed, 5 Jun 2024 00:21:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97FAA6B0092; Tue, 4 Jun 2024 20:21:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9300E6B0093; Tue, 4 Jun 2024 20:21:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F8286B0095; Tue, 4 Jun 2024 20:21:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 62E666B0092 for ; Tue, 4 Jun 2024 20:21:27 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 10C42160E07 for ; Wed, 5 Jun 2024 00:21:27 +0000 (UTC) X-FDA: 82194931014.02.D645595 Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by imf14.hostedemail.com (Postfix) with ESMTP id 17180100010 for ; Wed, 5 Jun 2024 00:21:23 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf14.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=1717546885; 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=bUj4baNL2QjEeWRLM64qRVHN+E3oK9zWa0UQ4aoXe+E=; b=Re020rBr6mZK+akePUEKcs8nhrVmOuRlawh6SOH+k+vtjhJX3OX6Om/XN0ptd1HphfYx00 OTZf/y5dR4y7xbwsoj8C0xyWIQmiUTHGIporBERRKBE6b6y07vq4hR8RFH5dVLT4E1jCp0 V4OpH9PkaeBlssr6C6ty4aJLywraXHQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf14.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=1717546885; a=rsa-sha256; cv=none; b=y8evDF9QeFrnwRa/gaEuNFsh3aM0o7Jli6KB7kxvjuA3H3mg8QqcN/cPUiJHz4Rb22FZ0Q jmUmeSLofHLQgAprsKQsNFU9OzT5u6aFvg3bzLcnA3umrwSa9BcxIUmyinvxKFUfxIQMQR of1GyqZ01uJ7j6CIyFYuPvmwBRIL/iU= X-AuditID: a67dfc5b-d85ff70000001748-85-665faf7fe9ab Date: Wed, 5 Jun 2024 09:21:14 +0900 From: Byungchul Park To: Johannes Weiner Cc: "Huang, Ying" , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, 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: <20240605002114.GA23651@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> <20240604102516.GB28034@system.software.com> <20240604122927.GA1992@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240604122927.GA1992@cmpxchg.org> User-Agent: Mutt/1.9.4 (2018-02-28) X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3PjJDGKLCGhIXFrUwdbFyMXBLHCQUeLNwbvs XYwcHMICqRLHtweA1PAKWEhcfvuEFaRGSOACk8ScvwdZIRKCEidnPmEBsZkFtCRu/HvJBNLL LCAtsfwfB0iYU8BA4tTuX2B7RQWUJQ5sO840gZF3FpLuWUi6ZyF0L2BkXsUokplXlpuYmWOq V5ydUZmXWaGXnJ+7iREYustq/0zcwfjlsvshRgEORiUe3h2/4tKEWBPLiitzDzFKcDArifD6 FcenCfGmJFZWpRblxxeV5qQWH2KU5mBREuf1Ck9NEBJITyxJzU5NLUgtgskycXBKNTC6sbG/ PHtPWjky/ZJIuPn9nW8tzu99p3l0fVX0TxPtLcI/Fuww4zXR3Pvif1DIsT/rl+894bWsSfje tZ911hrfNQonNH/4cay+82FUkcKcqwssGNd8mlduqHfrN/ueBclpz+0nKJwyT9yQtO1n3lKn XRvf3+ePPc2Zkn39xK+Lf79O6/y9jF/ujxJLcUaioRZzUXEiACWHbTNZAgAA X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 17180100010 X-Stat-Signature: oj695yhyxwporr9x1y41k9m3o93bnroe X-HE-Tag: 1717546883-897909 X-HE-Meta: U2FsdGVkX1+lVTtOHLtfnK57XMCNeWKBF1nxmAZbvREvXqxd2kYrvTZ0Yczt89mMsxe78yqgZFB15wi9E8QjOHzdOPogbiGqNLHta6zOTWFEf/0TTcAwUtukpwb08LGo2Cf6XRZyMFNS5jikaAH+SLgOfCZULAmS+U0esD/bkOXubln+55fVpvuZy54CXT9HrPX4YCEHorS+Tv9zfxo/6dQJvDOYdUP5nZuPIJkd+3J7ec0N904O8y8BnhGPhIf4jYNGqAMrssKTrF4fYHI3gTlKC7AC5i1R11PuyEiVBycD1DeHWPovq4Wia8UjX1xnyeZ2FnJd9k+/mpPogy0IF8X7T0DO48k0iGl4XcoORMyI5A6re3MbzSW0+iqaefeY8gOfYKZdH0LqrnE80pEw/FLIjLWiUNmztKPQS2AXwQIXLE8jaXHp6cdI8Cn3khRh8r+Ae78M+ZuAlsf9YX07GFMcnOcbkP8ARXUgEshrS2L89w+2M3QEW7Lx57McTatr8FoEbemF9oh3Mn9l8WbtetJGG+QJFVttmX8Ikrdld8d+UDo0M3vGKDkewxp3UQPkoeXSkHJuZcZ8i1G+hpKADin8BWVQQRGSDJo6dmxs3TnOgnYM9gew8Eo8QHZWxPoE+W8yamBHbwxf6po1M5F+dMesSyhqeHXw1l4sR/j3TRMBjaSwVXG49P5rmJEoLIhnoLF0a+ennTQ9kmd5CfWHHqAVbuQNWEqimTDBG258vx7+PcS+X1Pv7KsnNy+lEixy9MigXYWVzDxWNJgHWD34f9NBg2NsMx0OeBZ3E89COHgy9F8fISuz7BFiu6CC1/wRNRG3IbvuFbCDRILJs/H6/I9LMSxBRY2DaAwLjm8YY6iAhYSlcdnc2MFs4SkfcLyvwvtyOqAY9L/jEac8Y5bIoffUwrBtCdxe3Rl2q8rvT0o91ljy8KN2HV8jn/DJYyX+0brWRJAE/jBiotwAcj4 6sDlcihc xrKGbCj3gZDSc7OligzsYM+4S1ickWXElWDuaD7vClCnF4/JPrqoLR4yhlQ== 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 08:29:27AM -0400, Johannes Weiner wrote: > On Tue, Jun 04, 2024 at 07:25:16PM +0900, Byungchul Park wrote: > > 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. > > But like Ying said, in other situations it's direct reclaim that kicks > in and clears the flag. I already described it in the commit message. > The failure-sleep and direct reclaim triggered recovery have been in Sure. It's better than nothing. > place since 2017. Both parties who observed an issue with it recently > did so in tiering scenarios. IMO a tiering-specific solution makes the > most sense. So.. Is the follow situation in a non-tiering system okay? Really? A system runs with kswapd disabled unless hitting min water mark, even if there might be something that kswapd can work on. I don't undertand why it's okay. Could you explain more? Then why do we use kswapd in background? Byungchul