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: 32860 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp197759wrn; Tue, 13 Dec 2022 07:45:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf6/iPEUi2Yi/Qspu+jV6bZRuLsG4UHRQqoT0JDOfppbl+e2r87sGnTwt9cMCEGMDfkkhY3W X-Received: by 2002:a17:906:e104:b0:7c1:22ad:655a with SMTP id gj4-20020a170906e10400b007c122ad655amr15794922ejb.23.1670946357286; Tue, 13 Dec 2022 07:45:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670946357; cv=none; d=google.com; s=arc-20160816; b=Os8MSqCC0qniqgucca36ma8wCj4mgvn+SGPC4pH6cn8ZyNJz8rlSBEDx4cxSyEB+NJ s4USLmVHeG6V5qftTeZPLBrRRiogu5vSHBsn+3ul3E7a/9eXJ2a28mXU+ndf31Yk1nJ3 G5xmgKykwvrsBmhIm6oCmXwcFzbFZ2nFezjojKMXxIQqi+SPgMfj8jtnUnZjrT9zBxdE yxZvzp6qRNEVMsvFc2nAI9JcR2v61T9tUWcZNXj0cV5oAKWT2PszcI2OtAFLU4MwosLj 7lPIMjW+oOcCM87cVm5YUT4cmF9uzB4puHzmJ2pJ+/XkxokLq1z9knc5uSs4YJKb5Brj zn+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=hZHHLXA3S9Kbf2JRMvqBzSTM8rtSEvTfbtQDdV3liug=; b=dEpEUhbJ4hc1Ezk3OpIdJWg5ruXidaiWqhyT7T3L8/uyuGg5061k4NGNXPvJPCuQof Hsth2sZ5pQu3G590J5xvzUGlkgqncKBMyI7VBhxOBzTqdxGLgvqhsu/qrsEL3Kiz/gAo 47aqMHXnoIfcQLONPfBFI7EFbv44OT7ftE4IQtX/w36h/eiTwn5OLhMI1SDSO1ZYkQTC 0WcKl95iyi5sanBbVHKDsEt+BfDEmPbzGW8mFoB7s3xh+sG0ivnAn2/1qY6y85hcZWKH VZlpe9x8POhz3yguV7k+KBb4niha0mUt7Dhrq/1GUeAzI30RfMaN871rKFrQxv/tpGi5 CNaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QrGlBWEJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga30-20020a1709070c1e00b007c11b8a1d74si9587617ejc.41.2022.12.13.07.45.34; Tue, 13 Dec 2022 07:45:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QrGlBWEJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236046AbiLMPlU (ORCPT + 99 others); Tue, 13 Dec 2022 10:41:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231939AbiLMPlP (ORCPT ); Tue, 13 Dec 2022 10:41:15 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 019911834A for ; Tue, 13 Dec 2022 07:41:12 -0800 (PST) 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752114247725917275?= X-GMAIL-MSGID: =?utf-8?q?1752114247725917275?= 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: */