Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8574483rwb; Tue, 13 Dec 2022 07:59:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf5GIa9MQqk6cGc/bju0ZFu3L3FGd/q6/PMcTYX6M76FTls0nJDEcns43RTyLKP7ADvv1hs0 X-Received: by 2002:a05:6402:50:b0:468:354b:2815 with SMTP id f16-20020a056402005000b00468354b2815mr17511784edu.7.1670947167327; Tue, 13 Dec 2022 07:59:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670947167; cv=none; d=google.com; s=arc-20160816; b=c1nZ+TT5q6l8cdg4q9HqRu13mjAlr+4x7z8r19chByWey/qELKFtHg4xHf1v7m9YKi xz5sUCSdXpk+RA1N0LEolnm47JLcrztmuAR9ZaRKSb9mfN6HmoHd2NnhLdMpWEIXugTz kfn2688nNe+Xl+xpyQrWwpyWGFTJdgY0fhrxk+9oZuEqv5sLibr+qfMspug8i++lW2nr HUVWPt8xbS9hrHULEZHf/uAX9Kc4cGzIEiH9H2TF5/s2ACayHuqBwFJJXZxvY5+AMwkN IBmOxlkZaXMFQjOzojnragD4lADTaQaaZHQrLuK/K4JE+jRXDOeLBJwAgG39ncONICO2 e+Ug== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa3-20020a170906eda300b0078cdba56108si7523297ejb.296.2022.12.13.07.59.10; Tue, 13 Dec 2022 07:59:27 -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 + 73 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-Type: text/plain; charset=us-ascii 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 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: */ -- Michal Hocko SUSE Labs