From patchwork Tue Dec 13 15:41:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 13072154 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 6F268C10F1D for ; Tue, 13 Dec 2022 15:41:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE9628E0005; Tue, 13 Dec 2022 10:41:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A70ED8E0002; Tue, 13 Dec 2022 10:41:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95FF58E0005; Tue, 13 Dec 2022 10:41:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8A3E18E0002 for ; Tue, 13 Dec 2022 10:41:15 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 58BE8A0D37 for ; Tue, 13 Dec 2022 15:41:15 +0000 (UTC) X-FDA: 80237696910.05.E696876 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf27.hostedemail.com (Postfix) with ESMTP id A5F0540006 for ; Tue, 13 Dec 2022 15:41:12 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=QrGlBWEJ; spf=pass (imf27.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670946073; 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: references:dkim-signature; bh=hZHHLXA3S9Kbf2JRMvqBzSTM8rtSEvTfbtQDdV3liug=; b=MdOS35LU5gt4RL01y8GiJB+4FO5RGkdRke4E3aQWLT2kMSRBEc/5yTyfhUN7HEv5iDDSDH oSkdeSOsnWL0MrUZlsu/MXam7chlNr50ySu5J/M4IE2d6VHxHp6CcY83UE5z++H+Aay8Ar nV7GXOW63nECUvps1C6eXl7W4/OX2F8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=QrGlBWEJ; spf=pass (imf27.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670946073; a=rsa-sha256; cv=none; b=QGQUHbL8B8hJk4E7D68e6ekociDSV5TAg+g0aaWXoY3dDrv3b2lcpdHZ0ZTyckjB/QAnFR kPfFWxMrWm3oBzEX6lIH6WHvt7TQMZYokE3vLuKXEypp80UlpSM6UOphXGLt+dEi3rztdt +q160rVxVVNx3umYwb4ddOP+fHsKzeA= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4CE8D1FDAE; Tue, 13 Dec 2022 15:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1670946071; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=hZHHLXA3S9Kbf2JRMvqBzSTM8rtSEvTfbtQDdV3liug=; b=QrGlBWEJKe2JGY12pd07OU2dSw6YPyobFQF9jHRi9mlDwHetfE3brIYzrrYOBjXg7zLOuk lksp7w1AYQah06bSaZNXj2rD6nTXILeGqlkVDxAw7APO94ovtECr8kJB21vYREfDbZQkK3 d06cZXzHYaT1gL3v9QW6l638CANOfwI= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2E43C138EE; Tue, 13 Dec 2022 15:41:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1nMPCRedmGMyHgAAMHmgww (envelope-from ); Tue, 13 Dec 2022 15:41:11 +0000 Date: Tue, 13 Dec 2022 16:41:10 +0100 From: Michal Hocko To: Dave Hansen , "Huang, Ying" Cc: Yang Shi , Wei Xu , Johannes Weiner , Andrew Morton , linux-mm@kvack.org, LKML Subject: memcg reclaim demotion wrt. isolation Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A5F0540006 X-Rspam-User: X-Stat-Signature: p13qnmwch6iu5fp6twzf7d3i8b5nw61b X-HE-Tag: 1670946072-913012 X-HE-Meta: U2FsdGVkX1+4JaeCSNfTH9H76L35F7ptLk0k9+5vl09OzydhK9Z1aQ7oUxveVCRQSZsaV7xwcurMPNjlg76e8uefaUvHtsAO2Yyhh+G228Pgw2DKkM6ClUL9V58h+JEQ296WnnqFwNYHFh1wN9GuwPYMmDoIb4GzeGMZwDTmPGe9H1G508AWdhxu+mNPQI9stsMUR4wtCvOCg8uJ43m3d5NJ6hfG/XLC5dml3kSDznktHbbaHjp5w4vm1IevmNxdWdHBfrC5Zay3Bj6kdnKwX3LfGIxNL26ExffjhnPZwIO0zHcsuIw/lSnbW7N82TKHg1o4PsOH3QNqhvda6/PHgRnXsPLOSn3QqgGsd2i2c9chUJLMDh8WqpPqWjbiOqljA29X+XVrxggZncEg7hclMuvsLsTrgJzJKpcfKiGQtQWViquXUOxftFvbEgdRRFQWz1Z4mg0cBQo9OQsO4q6mBULYIfdXJcZZuG2Vgz1pQxA+FsVsrPDsc/slDhOOLI6ICFQyo3RMGho9jtPhOEd7X30HekZqHPsc4oDKffiGSziU5RM9ugCIpGtwj/jTWq3ZrJi0Gi9tCKD4hXN0j03vCilgYNVnqTGxcvyajnXlX7MfV2ESmIsDYYkeXWLxWVIMcEZDXp4gE14qBAYFg3B+yNdx6T06iqam3ciaPMgMQVqTO/dul5xk7Ai1OSi0D1UmIR6llir0MA87UK/xgAEnR/9lw9Hh3MM0jTigMx3kOi+KmG6mql9uoMp1Qr/WB+2Shw1gIe3vrV8Yp2Ta12YK7dNbx4YKkazf6zG49DGJA4/ozIunQP+W9Ev+ogPgFluVI82oVooHYpnSn1ko9Lfb32hgc9Bnlzm2TaZloWKXYlo= 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: Hi, I have just noticed that that pages allocated for demotion targets includes __GFP_KSWAPD_RECLAIM (through GFP_NOWAIT). This is the case since the code has been introduced by 26aa2d199d6f ("mm/migrate: demote pages during reclaim"). I suspect the intention is to trigger the aging on the fallback node and either drop or further demote oldest pages. This makes sense but I suspect that this wasn't intended also for memcg triggered reclaim. This would mean that a memory pressure in one hierarchy could trigger paging out pages of a different hierarchy if the demotion target is close to full. I haven't really checked at the current kswapd wake up checks but I suspect that kswapd would back off in most cases so this shouldn't really cause any big problems. But I guess it would be better to simply not wake kswapd up for the memcg reclaim. What do you think? diff --git a/mm/vmscan.c b/mm/vmscan.c index 8fcc5fa768c0..1f3161173b85 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1568,7 +1568,7 @@ static struct page *alloc_demote_page(struct page *page, unsigned long private) * Folios which are not demoted are left on @demote_folios. */ static unsigned int demote_folio_list(struct list_head *demote_folios, - struct pglist_data *pgdat) + struct pglist_data *pgdat, bool cgroup_reclaim) { int target_nid = next_demotion_node(pgdat->node_id); unsigned int nr_succeeded; @@ -1589,6 +1589,10 @@ static unsigned int demote_folio_list(struct list_head *demote_folios, if (list_empty(demote_folios)) return 0; + /* local memcg reclaim shouldn't directly reclaim from other memcgs */ + if (cgroup_reclaim) + mtc->gfp_mask &= ~__GFP_RECLAIM; + if (target_nid == NUMA_NO_NODE) return 0; @@ -2066,7 +2070,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, /* 'folio_list' is always empty here */ /* Migrate folios selected for demotion */ - nr_reclaimed += demote_folio_list(&demote_folios, pgdat); + nr_reclaimed += demote_folio_list(&demote_folios, pgdat, cgroup_reclaim(sc)); /* Folios that could not be demoted are still in @demote_folios */ if (!list_empty(&demote_folios)) { /* Folios which weren't demoted go back on @folio_list for retry: */