summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorKairui Song <kasong@tencent.com>2024-11-05 01:52:52 +0800
committerAndrew Morton <akpm@linux-foundation.org>2024-11-11 17:22:25 -0800
commit3f28bbe56c7b77e73f1dd0515cad009cfdd64962 (patch)
treea1e7b2c80fc231a045368d63cb5661ad850cba49 /mm
parent3738290bfc99606787f515a4590ad38dc4f79ca4 (diff)
mm/list_lru: don't pass unnecessary key parameters
Patch series "mm/list_lru: Split list_lru lock into per-cgroup scope". When LOCKDEP is not enabled, lock_class_key is an empty struct that is never used. But the list_lru initialization function still takes a placeholder pointer as parameter, and the compiler cannot optimize it because the function is not static and exported. Remove this parameter and move it inside the list_lru struct. Only use it when LOCKDEP is enabled. Kernel builds with LOCKDEP will be slightly larger, while !LOCKDEP builds without it will be slightly smaller (the common case). Link: https://lkml.kernel.org/r/20241104175257.60853-1-ryncsn@gmail.com Link: https://lkml.kernel.org/r/20241104175257.60853-2-ryncsn@gmail.com Signed-off-by: Kairui Song <kasong@tencent.com> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Cc: Chengming Zhou <zhouchengming@bytedance.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Muchun Song <muchun.song@linux.dev> Cc: Qi Zheng <zhengqi.arch@bytedance.com> Cc: Roman Gushchin <roman.gushchin@linux.dev> Cc: Waiman Long <longman@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/list_lru.c9
-rw-r--r--mm/workingset.c4
2 files changed, 7 insertions, 6 deletions
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 9b7ff06e9d32..ea7dc9fa4d05 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -562,8 +562,7 @@ static void memcg_destroy_list_lru(struct list_lru *lru)
}
#endif /* CONFIG_MEMCG */
-int __list_lru_init(struct list_lru *lru, bool memcg_aware,
- struct lock_class_key *key, struct shrinker *shrinker)
+int __list_lru_init(struct list_lru *lru, bool memcg_aware, struct shrinker *shrinker)
{
int i;
@@ -583,8 +582,10 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware,
for_each_node(i) {
spin_lock_init(&lru->node[i].lock);
- if (key)
- lockdep_set_class(&lru->node[i].lock, key);
+#ifdef CONFIG_LOCKDEP
+ if (lru->key)
+ lockdep_set_class(&lru->node[i].lock, lru->key);
+#endif
init_one_lru(&lru->node[i].lru);
}
diff --git a/mm/workingset.c b/mm/workingset.c
index 0e38bec261a4..5c8861edbf17 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -813,8 +813,8 @@ static int __init workingset_init(void)
if (!workingset_shadow_shrinker)
goto err;
- ret = __list_lru_init(&shadow_nodes, true, &shadow_nodes_key,
- workingset_shadow_shrinker);
+ ret = list_lru_init_memcg_key(&shadow_nodes, workingset_shadow_shrinker,
+ &shadow_nodes_key);
if (ret)
goto err_list_lru;