mm-multi-gen-lru-kill-switch.patch removed from -mm tree
The quilt patch titled
Subject: mm: multi-gen LRU: kill switch
has been removed from the -mm tree. Its filename was
mm-multi-gen-lru-kill-switch.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Yu Zhao <[email protected]>
Subject: mm: multi-gen LRU: kill switch
Date: Sun, 18 Sep 2022 02:00:07 -0600
Add /sys/kernel/mm/lru_gen/enabled as a kill switch. Components that can be disabled include:
0x0001: the multi-gen LRU core
0x0002: walking page table, when arch_has_hw_pte_young() returns
true
0x0004: clearing the accessed bit in non-leaf PMD entries, when
CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG=y
[yYnN]: apply to all the components above
E.g.,
echo y >/sys/kernel/mm/lru_gen/enabled
cat /sys/kernel/mm/lru_gen/enabled
0x0007
echo 5 >/sys/kernel/mm/lru_gen/enabled
cat /sys/kernel/mm/lru_gen/enabled
0x0005
NB: the page table walks happen on the scale of seconds under heavy memory pressure, in which case the mmap_lock contention is a lesser concern, compared with the LRU lock contention and the I/O congestion. So far the only well-known case of the mmap_lock contention happens on Android, due to Scudo [1] which allocates several thousand VMAs for merely a few hundred MBs. The SPF and the Maple Tree also have provided their own assessments [2][3]. However, if walking page tables does worsen the mmap_lock contention, the kill switch can be used to disable it. In this case the multi-gen LRU will suffer a minor performance degradation, as shown previously.
Clearing the accessed bit in non-leaf PMD entries can also be disabled, since this behavior was not tested on x86 varieties other than Intel and AMD.
[1] https://source.android.com/devices/tech/debug/scudo
[2] https://lore.kernel.org/r/[email protected]/
[3] https://lore.kernel.org/r/[email protected]/
---
include/linux/cgroup.h | 15 + include/linux/mm_inline.h | 15 + include/linux/mmzone.h | 9 + kernel/cgroup/cgroup-internal.h | 1 mm/Kconfig | 6 mm/vmscan.c | 228 +++++++++++++++++++++++++++++- 6 files changed, 265 insertions(+), 9 deletions(-)
include/linux/cgroup.h renamed from include/linux/cgroup.h~mm-multi-gen-lru-kill-switch +14 -1
@@ -432,6 +432,18 @@ static inline void cgroup_put(struct cgrcss_put (&cgrp->self); } +extern struct mutex cgroup_mutex; + +static inline void cgroup_lock (void ) +{ +mutex_lock (&cgroup_mutex); +} + +static inline void cgroup_unlock (void ) +{ +mutex_unlock (&cgroup_mutex); +} +/** * task_css_set_check - obtain a task's css_set with extra access conditions * @task: the task to obtain css_set for
@@ -446,7 +458,6 @@ static inline void cgroup_put(struct cgr* as locks used during the cgroup_subsys::attach() methods. */ #ifdef CONFIG_PROVE_RCU -extern struct mutex cgroup_mutex;extern spinlock_t css_set_lock;#define task_css_set_check (task, __c) \ rcu_dereference_check((task)->cgroups, \
@@ -708,6 +719,8 @@ struct cgroup;static inline u64 cgroup_id (const struct cgroup *cgrp) {return 1 ; }static inline void css_get (struct cgroup_subsys_state *css) {}static inline void css_put (struct cgroup_subsys_state *css) {} +static inline void cgroup_lock (void ) {} +static inline void cgroup_unlock (void ) {}static inline int cgroup_attach_task_all (struct task_struct *from,struct task_struct *t) {return 0 ; } static inline int cgroupstats_build(struct cgroupstats *stats,
include/linux/mm_inline.h renamed from include/linux/mm_inline.h~mm-multi-gen-lru-kill-switch +13 -2
@@ -106,10 +106,21 @@ static __always_inline enum lru_list fol#ifdef CONFIG_LRU_GEN +#ifdef CONFIG_LRU_GEN_ENABLED static inline bool lru_gen_enabled (void ) { -return true; +DECLARE_STATIC_KEY_TRUE (lru_gen_caps[NR_LRU_GEN_CAPS ]); + +return static_branch_likely (&lru_gen_caps[LRU_GEN_CORE ]); +} +#else +static inline bool lru_gen_enabled (void ) +{ +DECLARE_STATIC_KEY_FALSE (lru_gen_caps[NR_LRU_GEN_CAPS ]); + +return static_branch_unlikely (&lru_gen_caps[LRU_GEN_CORE ]); } +#endif static inline bool lru_gen_in_fault (void ) {
@@ -222,7 +233,7 @@ static inline bool lru_gen_add_folio(strVM_WARN_ON_ONCE_FOLIO (gen !=-1 , folio); -if (folio_test_unevictable (folio)) +if (folio_test_unevictable (folio) || !lrugen->enabled)return false;/* * There are three common cases for this page:
include/linux/mmzone.h renamed from include/linux/mmzone.h~mm-multi-gen-lru-kill-switch +9 -0
@@ -387,6 +387,13 @@ enum { LRU_GEN_FILE, }; +enum { +LRU_GEN_CORE , +LRU_GEN_MM_WALK , +LRU_GEN_NONLEAF_YOUNG , +NR_LRU_GEN_CAPS +}; +#define MIN_LRU_BATCH BITS_PER_LONG#define MAX_LRU_BATCH (MIN_LRU_BATCH * 64)
@@ -428,6 +435,8 @@ struct lru_gen_struct {/* can be modified without holding the LRU lock */ atomic_long_t evicted[NR_HIST_GENS ][ANON_AND_FILE ][MAX_NR_TIERS ];atomic_long_t refaulted[NR_HIST_GENS ][ANON_AND_FILE ][MAX_NR_TIERS ]; +/* whether the multi-gen LRU is enabled */ +bool enabled; };enum {
kernel/cgroup/cgroup-internal.h renamed from kernel/cgroup/cgroup-internal.h~mm-multi-gen-lru-kill-switch +0 -1
@@ -164,7 +164,6 @@ struct cgroup_mgctx {#define DEFINE_CGROUP_MGCTX (name) \ struct cgroup_mgctx name = CGROUP_MGCTX_INIT(name) -extern struct mutex cgroup_mutex;extern spinlock_t css_set_lock;extern struct cgroup_subsys *cgroup_subsys[];extern struct list_head cgroup_roots;
mm/Kconfig renamed from mm/Kconfig~mm-multi-gen-lru-kill-switch +6 -0
@@ -1127,6 +1127,12 @@ config LRU_GEN help A high performance LRU implementation to overcommit memory. +config LRU_GEN_ENABLED + bool "Enable by default" + depends on LRU_GEN + help + This option enables the multi-gen LRU by default. + config LRU_GEN_STATS bool "Full stats for debugging" depends on LRU_GEN
mm/vmscan.c renamed from mm/vmscan.c~mm-multi-gen-lru-kill-switch +223 -5
277 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are