From patchwork Wed May 18 19:09:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12854002 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 EEFB8C433F5 for ; Wed, 18 May 2022 19:09:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EFC46B0072; Wed, 18 May 2022 15:09:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19F406B0073; Wed, 18 May 2022 15:09:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0669F6B0074; Wed, 18 May 2022 15:09:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E90E86B0072 for ; Wed, 18 May 2022 15:09:14 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BA16D749 for ; Wed, 18 May 2022 19:09:14 +0000 (UTC) X-FDA: 79479801828.03.F73C846 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf15.hostedemail.com (Postfix) with ESMTP id 16993A00C9 for ; Wed, 18 May 2022 19:08:57 +0000 (UTC) Received: by mail-qt1-f173.google.com with SMTP id g3so2335904qtb.7 for ; Wed, 18 May 2022 12:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RYqL0MLG1DbGBmgYMURzmvbXpQhyxhj8gl5i89V5r90=; b=f4jYk60DD7udDhMwkKHqiV6/3YrbRjeifcxR7rq36/5EDL0R7jhskIGVLU0Im7kLx8 70gOwl8k95pY8w6wTsYt4l1qya3jYGUjdU4krCPxnEwDJZa+O9K1GV6WOJqvpU0N2hsU jNbS2Xf5epeNioenJq5vogiBiqKhhtztNd332raQBunqiAtMwZXRSZ4vS9FZ2zahG2Xz Tdtr/WGcNNFQ3sVbXiMJDn7gQQlPw+hV9neokhvbfEx5F6p+rgK6OIluXTNfrNY5OHg2 kr/uYhgBp3FfZ8WlbmqCx/n3SI1I2Qukgj7FPLw+jAg39ZLZlyNizMY6oHGkhfwWayAv A6pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RYqL0MLG1DbGBmgYMURzmvbXpQhyxhj8gl5i89V5r90=; b=b4/R2ldh4SWv2aDHT26ceRsk12Kzz5QNeDhBlLp05jg7l2JspJkntd4Y9eREgOodDY /cJUmdkRnLgm6FuLfGTiVl9ogq8B5lAITi/5212XoozfxofCaXUD9ZYt7K/4dpEbRHWs VPEd3dROjGd/5Czv4zkgOxrzYByBc3bDI/r2EkTXU8bJBI0SeFAYg1YTcsVWbIHip1jU xB7I+J5R/fxzlvG5rExk+oKKGq9Wz+WDceNIBphbUXwyEc6eFFszY7jC9aBAiq/WXkBW 4cOvWpSba4mHjHx++qlIQxo0gapVrcteo8+1IbvbElMOdKSL6YF8SP5so4LykgMrxYjO M7+A== X-Gm-Message-State: AOAM5335liAeQV+vluSIgsadEZdxs/NLklwfD1NPzBtHNhEyOc1vuJ1h XmZBg4/1j2MWEysRcjE/YZ5NjQ== X-Google-Smtp-Source: ABdhPJwumIQaKq5F0GW4ytkYAWRSgYk3zDOPU/2iHgy/+RVZ51/DaRFHNuE+SaxmvNviRCqS28HKCw== X-Received: by 2002:ac8:5f4c:0:b0:2f3:c99c:e246 with SMTP id y12-20020ac85f4c000000b002f3c99ce246mr1158818qta.122.1652900953299; Wed, 18 May 2022 12:09:13 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:b35b]) by smtp.gmail.com with ESMTPSA id f9-20020a05622a104900b002f39b99f69fsm3011qte.57.2022.05.18.12.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 12:09:12 -0700 (PDT) From: Johannes Weiner To: Dave Hansen , "Huang, Ying" , Yang Shi , Andrew Morton Cc: linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Zi Yan , Michal Hocko , Shakeel Butt , Roman Gushchin Subject: [PATCH] Revert "mm/vmscan: never demote for memcg reclaim" Date: Wed, 18 May 2022 15:09:11 -0400 Message-Id: <20220518190911.82400-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 16993A00C9 X-Stat-Signature: 6d4ng5pi98fsxeeu1cypy3zfj1ai4py9 X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=f4jYk60D; spf=pass (imf15.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.173 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-HE-Tag: 1652900937-744866 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: This reverts commit 3a235693d3930e1276c8d9cc0ca5807ef292cf0a. Its premise was that cgroup reclaim cares about freeing memory inside the cgroup, and demotion just moves them around within the cgroup limit. Hence, pages from toptier nodes should be reclaimed directly. However, with NUMA balancing now doing tier promotions, demotion is part of the page aging process. Global reclaim demotes the coldest toptier pages to secondary memory, where their life continues and from which they have a chance to get promoted back. Essentially, tiered memory systems have an LRU order that spans multiple nodes. When cgroup reclaims pages coming off the toptier directly, there can be colder pages on lower tier nodes that were demoted by global reclaim. This is an aging inversion, not unlike if cgroups were to reclaim directly from the active lists while there are inactive pages. Proactive reclaim is another factor. The goal of that it is to offload colder pages from expensive RAM to cheaper storage. When lower tier memory is available as an intermediate layer, we want offloading to take advantage of it instead of bypassing to storage. Revert the patch so that cgroups respect the LRU order spanning the memory hierarchy. Of note is a specific undercommit scenario, where all cgroup limits in the system add up to <= available toptier memory. In that case, shuffling pages out to lower tiers first to reclaim them from there is inefficient. This is something could be optimized/short-circuited later on (although care must be taken not to accidentally recreate the aging inversion). Let's ensure correctness first. Signed-off-by: Johannes Weiner Cc: Dave Hansen Cc: "Huang, Ying" Cc: Yang Shi Cc: Zi Yan Cc: Michal Hocko Cc: Shakeel Butt Cc: Roman Gushchin Acked-by: Dave Hansen Reviewed-by: Yang Shi Acked-by: Roman Gushchin Acked-by: Shakeel Butt Reviewed-by: "Huang, Ying" Reviewed-by: Muchun Song Acked-by: Michal Hocko Acked-by: Tim Chen --- mm/vmscan.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index c6918fff06e1..7a4090712177 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -528,13 +528,8 @@ static bool can_demote(int nid, struct scan_control *sc) { if (!numa_demotion_enabled) return false; - if (sc) { - if (sc->no_demotion) - return false; - /* It is pointless to do demotion in memcg reclaim */ - if (cgroup_reclaim(sc)) - return false; - } + if (sc && sc->no_demotion) + return false; if (next_demotion_node(nid) == NUMA_NO_NODE) return false;