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 67119C5AD4C for ; Thu, 23 Nov 2023 06:18:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DE826B0640; Thu, 23 Nov 2023 01:18:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 98DAE6B0641; Thu, 23 Nov 2023 01:18:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 855696B0642; Thu, 23 Nov 2023 01:18:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 756B66B0640 for ; Thu, 23 Nov 2023 01:18:21 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 44FA1811A9 for ; Thu, 23 Nov 2023 06:18:21 +0000 (UTC) X-FDA: 81488214402.02.7DCDDA9 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by imf07.hostedemail.com (Postfix) with ESMTP id 0206A40004 for ; Thu, 23 Nov 2023 06:18:17 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="PiaJq/qk"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf07.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700720298; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HMa7Py6WpGJXejiqyQU+FjHImGqUIFv5LxRPPBuLr5M=; b=te0DRLRjhlHRh5RrWbbJ5WxVkUqUqWjMK5l4T+pFoKt2BhMkE69Byf5WRUZGfL5UEMQCk6 r4uOQFh9A4exP88rwqOvADVCNlQEE1d36Rjgg1D+te+Wc/KtP1GRki5WeXnmA4Hf7RWwlg 0nijV68up1Mk4XpSi/4J3slMz1TVxPw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="PiaJq/qk"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf07.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700720298; a=rsa-sha256; cv=none; b=u/Tkh3rzFQpJ/kynUeveYMXHsJn4QOLtxW7dvXSFgvGFMd1y0AKVqRLijF/eFZEXU/ZckL JLHx1LgcT0cBVCweJFo2g5Hf9au+3ufvSw3t4uASUfoSuIGab5Bgr5N2dMXPhq/ixeYnFk XOTBPgPQPK3MvsC0EQRg2XXLErxVjAo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700720298; x=1732256298; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=pU5XgnaIyhhzJE/LMU8OzUII0Qq9Lz5PhG+Q/UbLT6E=; b=PiaJq/qkFU6jD0y3ojmXVxHQgwIsE4uGMMD30Um3+dcm6omR/0g3FGzJ PibksP7wpdmHaC/94RuIGy2umucmy68R3fpaWu4RVnHiWXUdAGj23bydK Aq/b6FjvBec3Qs5wzMBGbg6ppesBCEh122Y8Jy0HR1wQwd0wDZW8b13Hn wVdD3QrveWsWf+G3DVeZAuDLFnsgaHf9AnDvbXsv37JMqWaPv+QTVFKNr ZBM0s9yMA9hhciI6NW4tz7wn/ORWzsA/cXBgZ//sHcuC+11979Lcj71oE EuxSoDG6T4G91uLzqsWiQtr85XwJgi+dFu5ad317G1XPCuB47rh18Bw/T w==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="396114101" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="396114101" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 22:18:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="767108348" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="767108348" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 22:18:00 -0800 From: "Huang, Ying" To: Michal Hocko Cc: Yosry Ahmed , Liu Shixin , Yu Zhao , Andrew Morton , Sachin Sant , Johannes Weiner , Kefeng Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10] mm: vmscan: try to reclaim swapcache pages if no swap space In-Reply-To: (Michal Hocko's message of "Wed, 22 Nov 2023 14:19:37 +0100") References: <20231121090624.1814733-1-liushixin2@huawei.com> <32fe518a-e962-14ae-badc-719390386db9@huawei.com> Date: Thu, 23 Nov 2023 14:15:59 +0800 Message-ID: <87msv58068.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0206A40004 X-Stat-Signature: rfzxe14hmk7j5zq3otri9aty73o1he4w X-HE-Tag: 1700720297-848792 X-HE-Meta: U2FsdGVkX19gsl51yDrthLlgiut64j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gMS69SH3tao0aT95K5zjrhtUSzOJLUO5pN/06dYY1yLatTwEtIu8L/hZfcxq0dvG4zkmKOZdcYWqIk0mltNt6Q2WicNwjO8UWkbKFrz4= 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: Michal Hocko writes: > On Wed 22-11-23 02:39:15, Yosry Ahmed wrote: >> On Wed, Nov 22, 2023 at 2:09=E2=80=AFAM Michal Hocko w= rote: >> > >> > On Wed 22-11-23 09:52:42, Michal Hocko wrote: >> > > On Tue 21-11-23 22:44:32, Yosry Ahmed wrote: >> > > > On Tue, Nov 21, 2023 at 10:41=E2=80=AFPM Liu Shixin wrote: >> > > > > >> > > > > >> > > > > On 2023/11/21 21:00, Michal Hocko wrote: >> > > > > > On Tue 21-11-23 17:06:24, Liu Shixin wrote: >> > > > > > >> > > > > > However, in swapcache_only mode, the scan count still increase= d when scan >> > > > > > non-swapcache pages because there are large number of non-swap= cache pages >> > > > > > and rare swapcache pages in swapcache_only mode, and if the no= n-swapcache >> > > > > > is skipped and do not count, the scan of pages in isolate_lru_= folios() can >> > > > > > eventually lead to hung task, just as Sachin reported [2]. >> > > > > > I find this paragraph really confusing! I guess what you meant= to say is >> > > > > > that a real swapcache_only is problematic because it can end u= p not >> > > > > > making any progress, correct? >> > > > > This paragraph is going to explain why checking swapcache_only a= fter scan +=3D nr_pages; >> > > > > > >> > > > > > AFAIU you have addressed that problem by making swapcache_only= anon LRU >> > > > > > specific, right? That would be certainly more robust as you ca= n still >> > > > > > reclaim from file LRUs. I cannot say I like that because swapc= ache_only >> > > > > > is a bit confusing and I do not think we want to grow more spe= cial >> > > > > > purpose reclaim types. Would it be possible/reasonable to inst= ead put >> > > > > > swapcache pages on the file LRU instead? >> > > > > It looks like a good idea, but I'm not sure if it's possible. I = can try it, is there anything to >> > > > > pay attention to? >> > > > >> > > > I think this might be more intrusive than we think. Every time a p= age >> > > > is added to or removed from the swap cache, we will need to move it >> > > > between LRUs. All pages on the anon LRU will need to go through the >> > > > file LRU before being reclaimed. I think this might be too big of a >> > > > change to achieve this patch's goal. >> > > >> > > TBH I am not really sure how complex that might turn out to be. >> > > Swapcache tends to be full of subtle issues. So you might be right b= ut >> > > it would be better to know _why_ this is not possible before we end = up >> > > phising for couple of swapcache pages on potentially huge anon LRU to >> > > isolate them. Think of TB sized machines in this context. >> > >> > Forgot to mention that it is not really far fetched from comparing this >> > to MADV_FREE pages. Those are anonymous but we do not want to keep them >> > on anon LRU because we want to age them indepdendent on the swap >> > availability as they are just dropped during reclaim. Not too much >> > different from swapcache pages. There are more constrains on those but >> > fundamentally this is the same problem, no? >>=20 >> I agree it's not a first, but swap cache pages are more complicated >> because they can go back and forth, unlike MADV_FREE pages which >> usually go on a one way ticket AFAICT. > > Yes swapcache pages are indeed more complicated but most of the time > they just go away as well, no? When we swapin a page, we will put it in swapcache too. And the page can be in that state for long time if there is more than 50% free space in the swap device. > MADV_FREE can be reinitiated if they are > written as well. So fundamentally they are not that different. > [snip] -- Best Regards, Huang, Ying