From patchwork Thu Dec 1 23:33:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 13061947 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 A4590C4332F for ; Thu, 1 Dec 2022 23:33:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A2936B0072; Thu, 1 Dec 2022 18:33:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0532D6B0073; Thu, 1 Dec 2022 18:33:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5D276B0074; Thu, 1 Dec 2022 18:33:22 -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 D71D36B0072 for ; Thu, 1 Dec 2022 18:33:22 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 816F2120732 for ; Thu, 1 Dec 2022 23:33:22 +0000 (UTC) X-FDA: 80195341044.09.27FCAAE Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf26.hostedemail.com (Postfix) with ESMTP id 3360A14000B for ; Thu, 1 Dec 2022 23:33:22 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ewb56Xgk; spf=pass (imf26.hostedemail.com: domain of 3wTmJYwsKCHwfqrfxw3rnsflttlqj.htrqnsz2-rrp0fhp.twl@flex--almasrymina.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3wTmJYwsKCHwfqrfxw3rnsflttlqj.htrqnsz2-rrp0fhp.twl@flex--almasrymina.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669937602; 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=j5xM6059haRL2w3Ml8a9OvL6hEZxMiznHTFr64Muu3Y=; b=RgT+UjNQ4U0N+ZiDcBnE7a8NPoBak9Pbr4D/KozYYRGWdJvR/0BFBTpBXH5vSbKDNL/WTu n3OcFRgAfyqmZY3YahGVfZ+73I5muUu1NGWKxNa/NBYf4ks3LcE0QGAC3Wbts2xtIle7BG lrgC4GjkoyUFHyYpnnmWE/kDXiQlsSU= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ewb56Xgk; spf=pass (imf26.hostedemail.com: domain of 3wTmJYwsKCHwfqrfxw3rnsflttlqj.htrqnsz2-rrp0fhp.twl@flex--almasrymina.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3wTmJYwsKCHwfqrfxw3rnsflttlqj.htrqnsz2-rrp0fhp.twl@flex--almasrymina.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669937602; a=rsa-sha256; cv=none; b=cuHfcSXAX8kerihr2KjIWOMVIHglyOylk823+VCiAeJQBc0ybnoN/piSfhng+WOfa6hqvm XJe++VvjrRoVdbzNN66p9LTj1gbqLc4ze/brkxHCSmbamKcv0CcxojJGmobXUGacqnLPzx FDQhwRuh7oVNxODmdfECMT9AM1jgIPQ= Received: by mail-yb1-f201.google.com with SMTP id b4-20020a253404000000b006fad1bb09f4so3314008yba.1 for ; Thu, 01 Dec 2022 15:33:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=j5xM6059haRL2w3Ml8a9OvL6hEZxMiznHTFr64Muu3Y=; b=ewb56XgkB8OJ94EaI97ZNlJi8hda6Yr2t8q/bkmq3CwmXRsSaDFbJ3M2qcP3Yj2dKA x+WXST6VfgBddgE2zHpubheKMa0xiWrMKYNegpChRy0JHvzkCgwNg0C39luwmaKTBPct xzsWH5vK6uM04ozXYjeyVqAdfMDNK5298lLSIoNCLJuM6ZqXwohnfue0mu1WJ0bVx8HG q8KUfKfm9KdhsuVz1Sb4NfzeW/s1BqCPvIdF4pPry0GId2KBTQ0jsJopvKeiJ7Vta/tW 7NSD0AV3P8ivtFJwq588AHC2zW4gjr5w2x6KE71cC2dzC4zTiGFheA9Gk4KQSBrqLyXb fuwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=j5xM6059haRL2w3Ml8a9OvL6hEZxMiznHTFr64Muu3Y=; b=thHXRjdvUj8nbUKH6dJFlyn5bNM3PHX8Np7iKugQOjoSbNxXgdmNAi9CJ3KnZjj7NN MDMbupcrUHMAOX/x4LqlBlkJR9xHg+Dhi8QcQwID3Tl4G0h3Twj6p949YOZo8L1H7xfg VmH3ckKy5eP4VKML465XWz9Pl3U2RqqUxnzxQYBjMlDIryROjxvrRUJe8WOn8blryaW8 YpsESEuTqHCmcILgZAj+pRxq23NAdMPItQTKdtN2Shb7mBBqmCrVAEn6aM3Oh76QJsxw NMgstOjSuxbuxhYHjlAqM1JWVoq8IHNnIV/tGRqU6N79JmuLCAXZtai0gzKDkvjTVEH/ tSoQ== X-Gm-Message-State: ANoB5plbKNCPSGPY1yS8pzWot8k784pW2ecfyz0OLN5mLxnda3IrioKk b4tSjsS2e+hfWEfmS7LTY5Aow3CRvwE46YwFmg== X-Google-Smtp-Source: AA0mqf6KQU6tuDVl1pJYFk7jClux0jWzfMz7wsgxiZKagx1M0EFtB2nfBvK7fKwyYR+G6wQ4nvVr/fFBymw+KEnPAg== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2d4:203:4f7:4c6:3f81:f009]) (user=almasrymina job=sendgmr) by 2002:a25:c447:0:b0:6f8:784:efb9 with SMTP id u68-20020a25c447000000b006f80784efb9mr17934822ybf.334.1669937601439; Thu, 01 Dec 2022 15:33:21 -0800 (PST) Date: Thu, 1 Dec 2022 15:33:17 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog Message-ID: <20221201233317.1394958-1-almasrymina@google.com> Subject: [PATCH v1] mm: disable top-tier fallback to reclaim on proactive reclaim From: Mina Almasry To: Huang Ying , Yang Shi , Yosry Ahmed , Tim Chen , weixugc@google.com, shakeelb@google.com, gthelen@google.com, fvdl@google.com, Andrew Morton Cc: Mina Almasry , linux-mm@kvack.org, linux-kernel@vger.kernel.org X-Spamd-Result: default: False [4.16 / 9.00]; SORBS_IRL_BL(3.00)[209.85.219.201:from]; MID_CONTAINS_FROM(1.00)[]; BAYES_HAM(-0.74)[83.88%]; MV_CASE(0.50)[]; FORGED_SENDER(0.30)[almasrymina@google.com,3wTmJYwsKCHwfqrfxw3rnsflttlqj.htrqnsz2-rrp0fhp.twl@flex--almasrymina.bounces.google.com]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; PREVIOUSLY_DELIVERED(0.00)[linux-mm@kvack.org]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_DKIM_ALLOW(0.00)[google.com:s=20210112]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; R_SPF_ALLOW(0.00)[+ip4:209.85.128.0/17]; RCPT_COUNT_TWELVE(0.00)[12]; DKIM_TRACE(0.00)[google.com:+]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; DMARC_POLICY_ALLOW(0.00)[google.com,reject]; FROM_NEQ_ENVFROM(0.00)[almasrymina@google.com,3wTmJYwsKCHwfqrfxw3rnsflttlqj.htrqnsz2-rrp0fhp.twl@flex--almasrymina.bounces.google.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 3360A14000B X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: qibrtkjrhrge1zpzwxnrfqug59ftc9nj X-HE-Tag: 1669937602-886402 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: Reclaiming directly from top tier nodes breaks the aging pipeline of memory tiers. 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. However disabling reclaim from top tier nodes entirely would cause ooms in edge scenarios where lower tier memory is unreclaimable for whatever reason, e.g. memory being mlocked() or too hot to reclaim. In these cases we would rather the job run with a performance regression rather than it oom altogether. However, we can disable reclaim from top tier nodes for proactive reclaim. That reclaim is not real memory pressure, and we don't have any cause to be breaking the aging pipeline. Signed-off-by: Mina Almasry Reviewed-by: "Huang, Ying" --- mm/vmscan.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) -- 2.39.0.rc0.267.gcb52ba06e7-goog diff --git a/mm/vmscan.c b/mm/vmscan.c index 23fc5b523764..6eb130e57920 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2088,10 +2088,31 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, nr_reclaimed += demote_folio_list(&demote_folios, pgdat); /* 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: */ + /* + * Folios which weren't demoted go back on @folio_list. + */ list_splice_init(&demote_folios, folio_list); - do_demote_pass = false; - goto retry; + + /* + * goto retry to reclaim the undemoted folios in folio_list if + * desired. + * + * Reclaiming directly from top tier nodes is not often desired + * due to it breaking the LRU ordering: in general memory + * should be reclaimed from lower tier nodes and demoted from + * top tier nodes. + * + * However, disabling reclaim from top tier nodes entirely + * would cause ooms in edge scenarios where lower tier memory + * is unreclaimable for whatever reason, eg memory being + * mlocked or too hot to reclaim. We can disable reclaim + * from top tier nodes in proactive reclaim though as that is + * not real memory pressure. + */ + if (!sc->proactive) { + do_demote_pass = false; + goto retry; + } } pgactivate = stat->nr_activate[0] + stat->nr_activate[1];