From patchwork Mon Oct 14 22:12:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Xu X-Patchwork-Id: 13835528 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 695D8D18151 for ; Mon, 14 Oct 2024 22:12:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D27286B0089; Mon, 14 Oct 2024 18:12:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD6006B008A; Mon, 14 Oct 2024 18:12:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC3FF6B008C; Mon, 14 Oct 2024 18:12:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A56D86B0089 for ; Mon, 14 Oct 2024 18:12:34 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 055B6AB02E for ; Mon, 14 Oct 2024 22:12:18 +0000 (UTC) X-FDA: 82673607450.17.1A46E13 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf15.hostedemail.com (Postfix) with ESMTP id CA010A0023 for ; Mon, 14 Oct 2024 22:12:25 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=J1zO08JC; spf=pass (imf15.hostedemail.com: domain of 3TpcNZwcKCPEpXbqnZVZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--weixugc.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3TpcNZwcKCPEpXbqnZVZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--weixugc.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=1728943810; 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=StVEPLlBONEMwFAfdA5SiN1ofT0Acong4DzVn1DhVfw=; b=r/jh+ZTEDEpmVQVv7ubRB0m6jIMoHTfN2etVa+Al8t6kp4EYW3dNHNo56HiJNnYgebvkJk ISIaw4DI0EhAmC1uiyrUtk0JA/1Hl407FcgZyejbstkiB2Cl1z7MaD8E2yhHznoL/CmvuG 5zqcAn4np+R18lZMScic7NYRgL3uXSQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728943810; a=rsa-sha256; cv=none; b=zqtdx3x1f1P5y2Zu/TawM0oRRR6FFzMrYhuA52nSnHX/b7csZKPKzGgV+7+pHhtoSx7yi8 dy0lkTVOct6sEzpb8Ywec1b5kjumIFsoVD3CHnKxzr+cTP2TFvrEuJ8Xrux0QzIEXoJvJz vt4JhWd7Q1v3in/bBqRO+BBd/mALGko= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=J1zO08JC; spf=pass (imf15.hostedemail.com: domain of 3TpcNZwcKCPEpXbqnZVZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--weixugc.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3TpcNZwcKCPEpXbqnZVZhhZeX.Vhfebgnq-ffdoTVd.hkZ@flex--weixugc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-20c8b0b0736so35921785ad.3 for ; Mon, 14 Oct 2024 15:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728943951; x=1729548751; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=StVEPLlBONEMwFAfdA5SiN1ofT0Acong4DzVn1DhVfw=; b=J1zO08JCOyQjg9lIHOXfS7vgRh24Ix+kVzi4HPQvW8xKeXVzQ6hjNh9+yDL/DLZrnD ZQhMKq5hbQLDSWoKXe0k2Ky+iL+tE07R/6Zzs/lOocgkmlfgBqrjmur9kNHib8Gfyl9t Dt4APyK/9FgpxeWM1fCOd3tKsVUA1/1fmEdhORDyOmUOO4hPJ6MB4Ybj36f6x2ObbDWA h6b+mkxbfHxRfCNPIdAPhIbtByNdlLmcbkZy2xkSEstJHp5XEv3EZeHgv6vx0dVyxzIP vnJeH4iBcMIT0CvkNJjLS0u8pXPJ7CNe0Fax9GE6jfbIMMBL98c/U+eZ4XL+YDVi1Dvk 0Kaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728943951; x=1729548751; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=StVEPLlBONEMwFAfdA5SiN1ofT0Acong4DzVn1DhVfw=; b=ds/LXjQ4ne2a4vZFvF+iTi+CSkhoTcvS0gnukzcZHBVS+N+INLuUr0nYbZrL/guucQ l2lLaeiM7+iQ8GTDYw0msu8jjIBoX8uUaFtVQ1Y2h7+Eqmq/KGmWTijlFq4BeJ5iOPGf CTgb030L4r/s5CNtFuDAdNyzX7L58hns1f0MxVrs0TufWL/arU1O7Xf9LWceuDmUba68 7EEC859YIvXcNgP+UNBE0UBvKJpF+509AdfI3tnJOfPME0ljWLnMeknopNgsccd1JKd/ 5MuicNmU086CDeZ4ixWbmcQ7ufQnO4Fg5xkDiTeug7whLSzXQmr5rLBB412jJI4ZtIUK tD8A== X-Forwarded-Encrypted: i=1; AJvYcCWlyW+u5xjjlYmivfqezCd6kQ59YYGHlHqf6zmXVNqNGi0kcVkUaOUOJVv9WJlme5HtV0waKJfUdA==@kvack.org X-Gm-Message-State: AOJu0YyCaMQVURJnZRtS59OaTOVO8d107tTTrrxlSStamSgCNtr/1H4v l4ui+xzSJD/dwrvwKY/EB+i3ouWZ3Y/Qos+GpSxDb4bjdxn+DUptdCSJACMwtWny8iQ0pkumW5p TbYEE5Q== X-Google-Smtp-Source: AGHT+IGdWq3ur/1CLZxNkGUkotrxh2qaCJZVTMSVykoVMtaGwuXheZm8sohIFrC3G7BSLGKky9qVb6Inlz7W X-Received: from monterey.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:641d]) (user=weixugc job=sendgmr) by 2002:a17:902:c40b:b0:20b:7be8:8ed0 with SMTP id d9443c01a7336-20ca142a427mr560145ad.2.1728943950779; Mon, 14 Oct 2024 15:12:30 -0700 (PDT) Date: Mon, 14 Oct 2024 22:12:11 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241014221211.832591-1-weixugc@google.com> Subject: [PATCH 1/2] mm/mglru: only clear kswapd_failures if reclaimable From: Wei Xu To: Yu Zhao Cc: Andrew Morton , Axel Rasmussen , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Xu X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CA010A0023 X-Stat-Signature: k9spc1kf9nf8wgp77a7hck7uauscqs4b X-HE-Tag: 1728943945-315477 X-HE-Meta: U2FsdGVkX190MDXWwPy4KdLrx6nhnLWG0URL9Xnizd/LXJ/WlQquJSxD7VaX5/NPhl+tXT480iQ+IMZCziWSg5G19ByTdbv69UEyZpiO4zbXazyYJlNM9cPXK4xP56vqc4C/Dc9BvhzLAjaUd4RludTn6L3ao6hXU+TTRu/66BeoyAuy/jdUKODPcvp7zvaYfOvBDKKUvF0B8eucY7wUG10K1me9Y6vgZCsFwC/g5aBK45tC1g/yUwHLzzRs+5QCjelpiDs5/BhFjqrz/54C05IhPIzyXIF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G470PJdATjB3MEkgtk3Un+k4IYVSordAKVLSy7UpQeHKV7wMsrYDi97MMeuLHS9/E92su3txigRuWXdXJ30alPjNAKTIZvWkDzkSlqUCBkSI6VDMOvingFrxsNB3GatCpktLQMJP/GOL3pv3DMKu1iNDyvEUW+cu7jnLuY199fn4pc4ADqOiRLyWPY2nguXEBHocagxUWHW6Nh3OZEvAtY7mj1qriQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000033, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: lru_gen_shrink_node() unconditionally clears kswapd_failures, which can prevent kswapd from sleeping and cause 100% kswapd cpu usage even when kswapd repeatedly fails to make progress in reclaim. Only clear kswap_failures in lru_gen_shrink_node() if reclaim makes some progress, similar to shrink_node(). Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists") Signed-off-by: Wei Xu --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 50dc06d55b1d..9d1e1c4e383d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4970,8 +4970,8 @@ static void lru_gen_shrink_node(struct pglist_data *pgdat, struct scan_control * blk_finish_plug(&plug); done: - /* kswapd should never fail */ - pgdat->kswapd_failures = 0; + if (sc->nr_reclaimed > reclaimed) + pgdat->kswapd_failures = 0; } /****************************************************************************** From patchwork Mon Oct 14 22:12:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Xu X-Patchwork-Id: 13835529 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 DAF54D18156 for ; Mon, 14 Oct 2024 22:12:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7809C6B008C; Mon, 14 Oct 2024 18:12:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7309E6B0092; Mon, 14 Oct 2024 18:12:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61F106B0093; Mon, 14 Oct 2024 18:12:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4235F6B008C for ; Mon, 14 Oct 2024 18:12:40 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7979712132D for ; Mon, 14 Oct 2024 22:12:32 +0000 (UTC) X-FDA: 82673607828.06.F1B765C Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf06.hostedemail.com (Postfix) with ESMTP id 421F8180011 for ; Mon, 14 Oct 2024 22:12:33 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gUGRYTF0; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3VJcNZwcKCPcvdhwtfbfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--weixugc.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3VJcNZwcKCPcvdhwtfbfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--weixugc.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728943853; a=rsa-sha256; cv=none; b=BYamrJkKZWhSQOox8NZ2vqsG0FQflpuUwREaAlT0cx4DaIWtv/nSbikguDNKWmGy6pvSQh lCMOJBMl4YFMCFFZ/3x29Vu9VYR59cMvXVA8vGupdzVGGkbbdZVlZexQTrvpJKmBgiOAJ6 BSYVpi9uCIbJq70NwTAL9fz1D+jj2Bk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gUGRYTF0; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of 3VJcNZwcKCPcvdhwtfbfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--weixugc.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3VJcNZwcKCPcvdhwtfbfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--weixugc.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728943853; 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=VLFlB8ArhD8sBmaD8/9E7s8jR7UTSwheYDE3N7Ewx8Q=; b=EGqNGpSTAPSCuPyZd0OhSSgk1LpBB+RqUA4ELU5N0D+/sEi0RnCSm/CXZ61RyLpmKu8bX8 PteoEA/3+RuVGZ6HI+7mVDaC4btW/Ol7K8XWqZymYi8bB1S5iwSn2cbMeWwaUHJnVgd+5J 005CajVGwKAqnyXZ5MoMOvWZvmR/Djg= Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-7ea0069a8b0so4136501a12.0 for ; Mon, 14 Oct 2024 15:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728943957; x=1729548757; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=VLFlB8ArhD8sBmaD8/9E7s8jR7UTSwheYDE3N7Ewx8Q=; b=gUGRYTF0lY8LGEGnaZBEEO83530Pyxsr6f9QTK7OyosE/g/SD7aegbLF05k46SWLF8 tsPy92XsrqEclcVl6crsXowOv2aoV7CypahfYE/NVvh9NGlN/AI9XPIgpA5bu09ih5cR XKhhyhk+nXgLO38I2adn3LPhgFcL9ePjjWhA6Zb10OsMk1WIBMvffeL5/ZMv19xwxVfr 4WI2XNa7fgxT3HFLqZcMov3Tu4Ti+CNp8KLOGQqoBrldikxwEkcAYkF7ONXjuS7vRXIA 1VDkq+updnvdCJCWtp2/Zslaz7L7bET60DAsRVnYkm6FZTSwv1Yr4gXAnf9/ia7uAIeP 8ZUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728943957; x=1729548757; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VLFlB8ArhD8sBmaD8/9E7s8jR7UTSwheYDE3N7Ewx8Q=; b=W44LISjwrIoRlLGWlZkQLTj74OuETFYleeu+qlQXNUKwbSJAwTOuPzCLX3Q9wcQ1Lg +61OYmmf7uQJWO3tQWdNWLhXtiQUcBmlPd4SfyIsl/gkZ+ddcJDfA8JzQOuahxKUbYaA tvRf1yFVMir2CdCwETTVYUlqI500X0ZPbbWqTSfdXi0wkNSHOvOhd5L9x5P32ZJK8YTG R+G4tafuMlogbbV8N2mut0C++bO9HzVnOAplgzATxRYC3u6IDRvi4ib4v1aIqk8hzvpw 9oB1xQwMv93ZTZz14q/8/+x0xoMKYcTo95AtkvY0blA8iFIe6jo+ir9MW8Xq9MFr+dvb XxuA== X-Forwarded-Encrypted: i=1; AJvYcCXP3HVKi3xDj65eh0mE68If7JAxnnD3hf9ESZc/l3JMYYoggFazaZTOsAh8ZqWSD1wI8fq4cAs8DA==@kvack.org X-Gm-Message-State: AOJu0YzF8GUR4LLlEEkyEX9R6JNnZZj9U2Rhwe9Etmw4c4SjCznesO2h lRTT6xAJ7P8EyGjUL3WYxA1T/RjSvASUiJzz1qYtFMGe1ChUbHSB5UZhnv8XLaXrktMscDjdhND c0O85tQ== X-Google-Smtp-Source: AGHT+IEZbp7h/ndmghwF1NV+bCjPhzb/M48R/4ukJlrDWG9j0yNm9iKhDQ51QtS4buCnNidxEv+y6NGvapg5 X-Received: from monterey.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:641d]) (user=weixugc job=sendgmr) by 2002:a17:903:181:b0:20c:d303:cae6 with SMTP id d9443c01a7336-20cd303cdffmr228005ad.5.1728943956134; Mon, 14 Oct 2024 15:12:36 -0700 (PDT) Date: Mon, 14 Oct 2024 22:12:31 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241014221231.832959-1-weixugc@google.com> Subject: [PATCH 2/2] mm/mglru: reset page lru tier bits when activating From: Wei Xu To: Yu Zhao Cc: Brian Geffon , Jan Alexander Steffens , Andrew Morton , Suleiman Souhlal , Axel Rasmussen , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Xu X-Rspamd-Queue-Id: 421F8180011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: pam43o8yj4a5oo4h81m4wjsgz4qewqwp X-HE-Tag: 1728943953-882911 X-HE-Meta: U2FsdGVkX19BJ0jSnK/c2/eQq0E4B4SBMWFpbR5OgDPpvuQUzXTuESEJI565PGOEYbO90wPZwoW1pcZpsBqVj9GH6cF3/xOVDjwur6hn7wFXW/25uTdG+C8LFX7FfpMiGhlmGaGqrM550Vtcw87IxTe2a0rV0X8tqiXWnKW4rH1SPBZZuo5nHHIdi6SwC/Zc+F7gydIt4716TGU16/6PK0JDxOReBXQswuA4WwyBfRavJnNP91Tb1VIMyY4jd9NWMDb6+bfgTsZDmvlp+w577Xs9O/eGUoibC1ewHadZ5IlsEwbLkYelpfm7/j9+J0vqqVAEfZ04hsktHe60YpiHKSplQ1ML1H0MfB+oO75s/UFZJsPRubyzLZ3b5hrctaYqqyQ9Z48tuM2qpj8USZ3Ic6zeRoTcyP3waOLymJuBFt4YdRUhmnw30SfcLVQTwoMZcySH9d6JPnOIQ4EyDvJa5l+FpHMOMra20r6EvveTloAfzDVsD3QdM2SyTkSWLdnNU2NUHTGIdet/jT9tN0FAE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org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: folio_activate() calls lru_gen_add_folio() to move the folio to the youngest generation. But unlike folio_update_gen()/folio_inc_gen(), lru_gen_add_folio() doesn't reset the folio lru tier bits (LRU_REFS_MASK | LRU_REFS_FLAGS). Fix this inconsistency in lru_gen_add_folio() when activating a folio. Fixes: 018ee47f1489 ("mm: multi-gen LRU: exploit locality in rmap") Signed-off-by: Wei Xu --- include/linux/mm_inline.h | 5 ++++- include/linux/mmzone.h | 2 ++ mm/vmscan.c | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index 6f801c7b36e2..87580e8363ef 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -222,6 +222,7 @@ static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio, { unsigned long seq; unsigned long flags; + unsigned long mask; int gen = folio_lru_gen(folio); int type = folio_is_file_lru(folio); int zone = folio_zonenum(folio); @@ -257,7 +258,9 @@ static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio, gen = lru_gen_from_seq(seq); flags = (gen + 1UL) << LRU_GEN_PGOFF; /* see the comment on MIN_NR_GENS about PG_active */ - set_mask_bits(&folio->flags, LRU_GEN_MASK | BIT(PG_active), flags); + mask = LRU_GEN_MASK | BIT(PG_active); + mask |= folio_test_active(folio) ? (LRU_REFS_MASK | LRU_REFS_FLAGS) : 0; + set_mask_bits(&folio->flags, mask, flags); lru_gen_update_size(lruvec, folio, -1, gen); /* for folio_rotate_reclaimable() */ diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 17506e4a2835..96dea31fb211 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -403,6 +403,8 @@ enum { NR_LRU_GEN_CAPS }; +#define LRU_REFS_FLAGS (BIT(PG_referenced) | BIT(PG_workingset)) + #define MIN_LRU_BATCH BITS_PER_LONG #define MAX_LRU_BATCH (MIN_LRU_BATCH * 64) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9d1e1c4e383d..907262ebaef8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2601,8 +2601,6 @@ static bool should_clear_pmd_young(void) * shorthand helpers ******************************************************************************/ -#define LRU_REFS_FLAGS (BIT(PG_referenced) | BIT(PG_workingset)) - #define DEFINE_MAX_SEQ(lruvec) \ unsigned long max_seq = READ_ONCE((lruvec)->lrugen.max_seq)