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 E21D2C4321E for ; Tue, 29 Nov 2022 00:54:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14B186B0072; Mon, 28 Nov 2022 19:54:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D49A6B0073; Mon, 28 Nov 2022 19:54:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB66A6B0074; Mon, 28 Nov 2022 19:54:40 -0500 (EST) 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 D73146B0072 for ; Mon, 28 Nov 2022 19:54:40 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A14E51C66C5 for ; Tue, 29 Nov 2022 00:54:40 +0000 (UTC) X-FDA: 80184659520.29.6B56BB4 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf22.hostedemail.com (Postfix) with ESMTP id 12883C0008 for ; Tue, 29 Nov 2022 00:54:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669683279; x=1701219279; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=4P2+jl1RIyYOuHVHfl3LKEnthZGh8okJ/3m5N/abcaU=; b=iekCd2YIahiNm77iNNGv1tky0aiPZSALAJwHBvgQ8CIAXEAfSQpVdjMp vv8ivP9/k8A9hhahWsxG6worzxXdNNsTjO5xSASJJ0jyh9GjQAMzObo2A ixJNunNOQ3zmsLDVzFsM57KNyZhZmG4ZNKeZXCOpazyvocsD6csJC2sTf ERb3I1dEwrWT1q6qkT6jLzo4qtErhTO9auy1wWqlQ5fQpqQcvVBbbQvZ8 lJ/1UY2vU5Lr7CBAlhM0+6NUc0jZEblltIgi1JZIx1ED4LICMLJNqAT+2 ENRUVtCWIdImvl7pySjJL1sCv+PCDA2ov6Nmzw45SGtbDmsavcMXcnxwH g==; X-IronPort-AV: E=McAfee;i="6500,9779,10545"; a="379248998" X-IronPort-AV: E=Sophos;i="5.96,201,1665471600"; d="scan'208";a="379248998" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 16:54:33 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10545"; a="768248692" X-IronPort-AV: E=Sophos;i="5.96,201,1665471600"; d="scan'208";a="768248692" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 16:54:27 -0800 From: "Huang, Ying" To: Yang Shi Cc: Johannes Weiner , Mina Almasry , Yang Shi , Yosry Ahmed , Tim Chen , weixugc@google.com, shakeelb@google.com, gthelen@google.com, fvdl@google.com, Michal Hocko , Roman Gushchin , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH V1] mm: Disable demotion from proactive reclaim In-Reply-To: (Yang Shi's message of "Mon, 28 Nov 2022 14:24:03 -0800") References: <20221122203850.2765015-1-almasrymina@google.com> <874juonbmv.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Date: Tue, 29 Nov 2022 08:53:24 +0800 Message-ID: <87a64ad1iz.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ascii ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669683280; a=rsa-sha256; cv=none; b=CyVNHUdwPGZwPiXu40eWTZpPgAYTxyX91uyzUpd/F3aiGoAZnMIPxor8d0/S7I9u2kHTQW dJLDnaTF0jKMl9yVU/McAxxT6r62/kAZOsKniQ7/F1RQWYgOfcwyySwo4kGUl1F/4ATpn5 0hcRt2njxk+UlsKkqvSLS5NgEi7NA/M= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=iekCd2YI; spf=pass (imf22.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669683280; 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:dkim-signature; bh=q6SqfI4/W1OdkJj8NMh2IzslcCcZC1DfPA0ncqAfO7M=; b=ktXCj0iWozbMkSetmTgwLF8L1DfxKQufXq28gH+KBlVfChcJayILRBkATm7ExIp6Gs7PV9 732FJ2s/ZhgTlEh79YP3eR94WMwMCSABSIPiWIyAyLP0HK+zd1ZzRIZcoqXBCMiNQ9GyEQ 3472pd0Rwy/eLD4HXxpNe14bQr8p5pY= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 12883C0008 X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=iekCd2YI; spf=pass (imf22.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: whdbzziewm73955iatqh6reh8gs1xpe4 X-HE-Tag: 1669683278-825953 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: Yang Shi writes: > On Wed, Nov 23, 2022 at 9:52 PM Huang, Ying wrote: >> >> Hi, Johannes, >> >> Johannes Weiner writes: >> [...] >> > >> > The fallback to reclaim actually strikes me as wrong. >> > >> > Think of reclaim as 'demoting' the pages to the storage tier. If we >> > have a RAM -> CXL -> storage hierarchy, we should demote from RAM to >> > CXL and from CXL to storage. If we reclaim a page from RAM, it means >> > we 'demote' it directly from RAM to storage, bypassing potentially a >> > huge amount of pages colder than it in CXL. That doesn't seem right. >> > >> > If demotion fails, IMO it shouldn't satisfy the reclaim request by >> > breaking the layering. Rather it should deflect that pressure to the >> > lower layers to make room. This makes sure we maintain an aging >> > pipeline that honors the memory tier hierarchy. >> >> Yes. I think that we should avoid to fall back to reclaim as much as >> possible too. Now, when we allocate memory for demotion >> (alloc_demote_page()), __GFP_KSWAPD_RECLAIM is used. So, we will trigger >> kswapd reclaim on lower tier node to free some memory to avoid fall back >> to reclaim on current (higher tier) node. This may be not good enough, >> for example, the following patch from Hasan may help via waking up >> kswapd earlier. > > For the ideal case, I do agree with Johannes to demote the page tier > by tier rather than reclaiming them from the higher tiers. But I also > agree with your premature OOM concern. > >> >> https://lore.kernel.org/linux-mm/b45b9bf7cd3e21bca61d82dcd1eb692cd32c122c.1637778851.git.hasanalmaruf@fb.com/ >> >> Do you know what is the next step plan for this patch? >> >> Should we do even more? > > In my initial implementation I implemented a simple throttle logic > when the demotion is not going to succeed if the demotion target has > not enough free memory (just check the watermark) to make migration > succeed without doing any reclamation. Shall we resurrect that? Can you share the link to your throttle patch? Or paste it here? > Waking kswapd sooner is fine to me, but it may be not enough, for > example, the kswapd may not keep up so remature OOM may happen on > higher tiers or reclaim may still happen. I think throttling the > reclaimer/demoter until kswapd makes progress could avoid both. And > since the lower tiers memory typically is quite larger than the higher > tiers, so the throttle should happen very rarely IMHO. > >> >> From another point of view, I still think that we can use falling back >> to reclaim as the last resort to avoid OOM in some special situations, >> for example, most pages in the lowest tier node are mlock() or too hot >> to be reclaimed. >> >> > So I'm hesitant to design cgroup controls around the current behavior. Best Regards, Huang, Ying