Skip to content

Commit ff0b67e

Browse files
Vladimir Davydovtorvalds
authored andcommitted
list_lru: get rid of ->active_nodes
The active_nodes mask allows us to skip empty nodes when walking over list_lru items from all nodes in list_lru_count/walk. However, these functions are never called from hot paths, so it doesn't seem we need such kind of optimization there. OTOH, removing the mask will make it easier to make list_lru per-memcg. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Greg Thelen <gthelen@google.com> Cc: Glauber Costa <glommer@gmail.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 05257a1 commit ff0b67e

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

‎include/linux/list_lru.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ struct list_lru_node {
3131

3232
struct list_lru {
3333
struct list_lru_node *node;
34-
nodemask_t active_nodes;
3534
};
3635

3736
void list_lru_destroy(struct list_lru *lru);
@@ -94,7 +93,7 @@ static inline unsigned long list_lru_count(struct list_lru *lru)
9493
long count = 0;
9594
int nid;
9695

97-
for_each_node_mask(nid, lru->active_nodes)
96+
for_each_node_state(nid, N_NORMAL_MEMORY)
9897
count += list_lru_count_node(lru, nid);
9998

10099
return count;
@@ -142,7 +141,7 @@ list_lru_walk(struct list_lru *lru, list_lru_walk_cb isolate,
142141
long isolated = 0;
143142
int nid;
144143

145-
for_each_node_mask(nid, lru->active_nodes) {
144+
for_each_node_state(nid, N_NORMAL_MEMORY) {
146145
isolated += list_lru_walk_node(lru, nid, isolate,
147146
cb_arg, &nr_to_walk);
148147
if (nr_to_walk <= 0)

‎mm/list_lru.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item)
1919
WARN_ON_ONCE(nlru->nr_items < 0);
2020
if (list_empty(item)) {
2121
list_add_tail(item, &nlru->list);
22-
if (nlru->nr_items++ == 0)
23-
node_set(nid, lru->active_nodes);
22+
nlru->nr_items++;
2423
spin_unlock(&nlru->lock);
2524
return true;
2625
}
@@ -37,8 +36,7 @@ bool list_lru_del(struct list_lru *lru, struct list_head *item)
3736
spin_lock(&nlru->lock);
3837
if (!list_empty(item)) {
3938
list_del_init(item);
40-
if (--nlru->nr_items == 0)
41-
node_clear(nid, lru->active_nodes);
39+
nlru->nr_items--;
4240
WARN_ON_ONCE(nlru->nr_items < 0);
4341
spin_unlock(&nlru->lock);
4442
return true;
@@ -90,8 +88,7 @@ list_lru_walk_node(struct list_lru *lru, int nid, list_lru_walk_cb isolate,
9088
case LRU_REMOVED_RETRY:
9189
assert_spin_locked(&nlru->lock);
9290
case LRU_REMOVED:
93-
if (--nlru->nr_items == 0)
94-
node_clear(nid, lru->active_nodes);
91+
nlru->nr_items--;
9592
WARN_ON_ONCE(nlru->nr_items < 0);
9693
isolated++;
9794
/*
@@ -133,7 +130,6 @@ int list_lru_init_key(struct list_lru *lru, struct lock_class_key *key)
133130
if (!lru->node)
134131
return -ENOMEM;
135132

136-
nodes_clear(lru->active_nodes);
137133
for (i = 0; i < nr_node_ids; i++) {
138134
spin_lock_init(&lru->node[i].lock);
139135
if (key)

0 commit comments

Comments
 (0)