From: Huan Yang <link@vivo.com>
To: Jonathan Corbet <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeelb@google.com>,
Muchun Song <muchun.song@linux.dev>,
Suleiman Souhlal <suleiman@google.com>,
Mike Rapoport <rppt@kernel.org>,
"Jan Alexander Steffens (heftig)" <heftig@archlinux.org>,
Yu Zhao <yuzhao@google.com>, Huan Yang <link@vivo.com>,
Brian Geffon <bgeffon@google.com>,
Gaosheng Cui <cuigaosheng1@huawei.com>,
Peter Xu <peterx@redhat.com>,
Axel Rasmussen <axelrasmussen@google.com>,
"T.J. Alumbaugh" <talumbau@google.com>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, cgroups@vger.kernel.org,
Oleksandr Natalenko <oleksandr@natalenko.name>,
Steven Barrett <steven@liquorix.net>,
Suren Baghdasaryan <surenb@google.com>
Cc: kernel@vivo.com
Subject: [PATCH 1/3] mm: multi-gen LRU: fold lru_gen run cmd
Date: Thu, 14 Sep 2023 18:47:43 +0800 [thread overview]
Message-ID: <20230914104754.55-2-link@vivo.com> (raw)
In-Reply-To: <20230914104754.55-1-link@vivo.com>
This patch move LRU_GEN define helper into mm_inline which will
used in per memcg lru gen node.
let run aging/eviction into func, per memcg also will run this.
Signed-off-by: Huan Yang <link@vivo.com>
---
include/linux/mm_inline.h | 9 ++++++++
mm/vmscan.c | 45 +++++++++++++++++++++------------------
2 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 8148b30a9df1..b953b305c8a2 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -101,6 +101,15 @@ static __always_inline enum lru_list folio_lru_list(struct folio *folio)
#ifdef CONFIG_LRU_GEN
+#define DEFINE_MAX_SEQ(lruvec) \
+ unsigned long max_seq = READ_ONCE((lruvec)->lrugen.max_seq)
+
+#define DEFINE_MIN_SEQ(lruvec) \
+ unsigned long min_seq[ANON_AND_FILE] = { \
+ READ_ONCE((lruvec)->lrugen.min_seq[LRU_GEN_ANON]), \
+ READ_ONCE((lruvec)->lrugen.min_seq[LRU_GEN_FILE]), \
+ }
+
#ifdef CONFIG_LRU_GEN_ENABLED
static inline bool lru_gen_enabled(void)
{
diff --git a/mm/vmscan.c b/mm/vmscan.c
index ea57a43ebd6b..f59977964e81 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3285,15 +3285,6 @@ static bool should_clear_pmd_young(void)
#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)
-
-#define DEFINE_MIN_SEQ(lruvec) \
- unsigned long min_seq[ANON_AND_FILE] = { \
- READ_ONCE((lruvec)->lrugen.min_seq[LRU_GEN_ANON]), \
- READ_ONCE((lruvec)->lrugen.min_seq[LRU_GEN_FILE]), \
- }
-
#define for_each_gen_type_zone(gen, type, zone) \
for ((gen) = 0; (gen) < MAX_NR_GENS; (gen)++) \
for ((type) = 0; (type) < ANON_AND_FILE; (type)++) \
@@ -6058,6 +6049,29 @@ static int run_eviction(struct lruvec *lruvec, unsigned long seq, struct scan_co
return -EINTR;
}
+static int __process_one_cmd(char cmd, struct lruvec *lruvec, unsigned long seq,
+ struct scan_control *sc, int swappiness,
+ unsigned long opt)
+{
+ int err;
+
+ if (swappiness < 0)
+ swappiness = get_swappiness(lruvec, sc);
+ else if (swappiness > 200)
+ return -EINVAL;
+
+ switch (cmd) {
+ case '+':
+ err = run_aging(lruvec, seq, sc, swappiness, opt);
+ break;
+ case '-':
+ err = run_eviction(lruvec, seq, sc, swappiness, opt);
+ break;
+ }
+
+ return err;
+}
+
static int run_cmd(char cmd, int memcg_id, int nid, unsigned long seq,
struct scan_control *sc, int swappiness, unsigned long opt)
{
@@ -6086,19 +6100,8 @@ static int run_cmd(char cmd, int memcg_id, int nid, unsigned long seq,
lruvec = get_lruvec(memcg, nid);
- if (swappiness < 0)
- swappiness = get_swappiness(lruvec, sc);
- else if (swappiness > 200)
- goto done;
+ err = __process_one_cmd(cmd, lruvec, seq, sc, swappiness, opt);
- switch (cmd) {
- case '+':
- err = run_aging(lruvec, seq, sc, swappiness, opt);
- break;
- case '-':
- err = run_eviction(lruvec, seq, sc, swappiness, opt);
- break;
- }
done:
mem_cgroup_put(memcg);
--
2.34.1
next prev parent reply other threads:[~2023-09-14 10:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 10:47 [PATCH 0/3] Per memcg lru_gen node stat Huan Yang
2023-09-14 10:47 ` Huan Yang [this message]
2023-09-14 10:47 ` [PATCH 2/3] mm: memcg: add per memcg "lru_gen" node Huan Yang
2023-09-14 10:47 ` [PATCH 3/3] mm: multi-gen LRU: add per memcg "lru_gen" document Huan Yang
2023-09-27 17:38 ` [PATCH 0/3] Per memcg lru_gen node stat Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2023-10-09 2:57 [PATCH 0/3 RESEND] " Huan Yang
2023-10-09 2:57 ` [PATCH 1/3] mm: multi-gen LRU: fold lru_gen run cmd Huan Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230914104754.55-2-link@vivo.com \
--to=link@vivo.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=bgeffon@google.com \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=cuigaosheng1@huawei.com \
--cc=hannes@cmpxchg.org \
--cc=heftig@archlinux.org \
--cc=kernel@vivo.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=oleksandr@natalenko.name \
--cc=peterx@redhat.com \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeelb@google.com \
--cc=steven@liquorix.net \
--cc=suleiman@google.com \
--cc=surenb@google.com \
--cc=talumbau@google.com \
--cc=wangkefeng.wang@huawei.com \
--cc=yuzhao@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).