Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Vladimir Davydov and committed by
Linus Torvalds
ff0b67ef 05257a1a

+5 -10
+2 -3
include/linux/list_lru.h
··· 31 31 32 32 struct list_lru { 33 33 struct list_lru_node *node; 34 - nodemask_t active_nodes; 35 34 }; 36 35 37 36 void list_lru_destroy(struct list_lru *lru); ··· 93 94 long count = 0; 94 95 int nid; 95 96 96 - for_each_node_mask(nid, lru->active_nodes) 97 + for_each_node_state(nid, N_NORMAL_MEMORY) 97 98 count += list_lru_count_node(lru, nid); 98 99 99 100 return count; ··· 141 142 long isolated = 0; 142 143 int nid; 143 144 144 - for_each_node_mask(nid, lru->active_nodes) { 145 + for_each_node_state(nid, N_NORMAL_MEMORY) { 145 146 isolated += list_lru_walk_node(lru, nid, isolate, 146 147 cb_arg, &nr_to_walk); 147 148 if (nr_to_walk <= 0)
+3 -7
mm/list_lru.c
··· 19 19 WARN_ON_ONCE(nlru->nr_items < 0); 20 20 if (list_empty(item)) { 21 21 list_add_tail(item, &nlru->list); 22 - if (nlru->nr_items++ == 0) 23 - node_set(nid, lru->active_nodes); 22 + nlru->nr_items++; 24 23 spin_unlock(&nlru->lock); 25 24 return true; 26 25 } ··· 36 37 spin_lock(&nlru->lock); 37 38 if (!list_empty(item)) { 38 39 list_del_init(item); 39 - if (--nlru->nr_items == 0) 40 - node_clear(nid, lru->active_nodes); 40 + nlru->nr_items--; 41 41 WARN_ON_ONCE(nlru->nr_items < 0); 42 42 spin_unlock(&nlru->lock); 43 43 return true; ··· 88 90 case LRU_REMOVED_RETRY: 89 91 assert_spin_locked(&nlru->lock); 90 92 case LRU_REMOVED: 91 - if (--nlru->nr_items == 0) 92 - node_clear(nid, lru->active_nodes); 93 + nlru->nr_items--; 93 94 WARN_ON_ONCE(nlru->nr_items < 0); 94 95 isolated++; 95 96 /* ··· 130 133 if (!lru->node) 131 134 return -ENOMEM; 132 135 133 - nodes_clear(lru->active_nodes); 134 136 for (i = 0; i < nr_node_ids; i++) { 135 137 spin_lock_init(&lru->node[i].lock); 136 138 if (key)