提交 ff0b67ef 编写于 作者: V Vladimir Davydov 提交者: Linus Torvalds

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: NVladimir 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 05257a1a
...@@ -31,7 +31,6 @@ struct list_lru_node { ...@@ -31,7 +31,6 @@ struct list_lru_node {
struct list_lru { struct list_lru {
struct list_lru_node *node; struct list_lru_node *node;
nodemask_t active_nodes;
}; };
void list_lru_destroy(struct list_lru *lru); void list_lru_destroy(struct list_lru *lru);
...@@ -94,7 +93,7 @@ static inline unsigned long list_lru_count(struct list_lru *lru) ...@@ -94,7 +93,7 @@ static inline unsigned long list_lru_count(struct list_lru *lru)
long count = 0; long count = 0;
int nid; int nid;
for_each_node_mask(nid, lru->active_nodes) for_each_node_state(nid, N_NORMAL_MEMORY)
count += list_lru_count_node(lru, nid); count += list_lru_count_node(lru, nid);
return count; return count;
...@@ -142,7 +141,7 @@ list_lru_walk(struct list_lru *lru, list_lru_walk_cb isolate, ...@@ -142,7 +141,7 @@ list_lru_walk(struct list_lru *lru, list_lru_walk_cb isolate,
long isolated = 0; long isolated = 0;
int nid; int nid;
for_each_node_mask(nid, lru->active_nodes) { for_each_node_state(nid, N_NORMAL_MEMORY) {
isolated += list_lru_walk_node(lru, nid, isolate, isolated += list_lru_walk_node(lru, nid, isolate,
cb_arg, &nr_to_walk); cb_arg, &nr_to_walk);
if (nr_to_walk <= 0) if (nr_to_walk <= 0)
......
...@@ -19,8 +19,7 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item) ...@@ -19,8 +19,7 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item)
WARN_ON_ONCE(nlru->nr_items < 0); WARN_ON_ONCE(nlru->nr_items < 0);
if (list_empty(item)) { if (list_empty(item)) {
list_add_tail(item, &nlru->list); list_add_tail(item, &nlru->list);
if (nlru->nr_items++ == 0) nlru->nr_items++;
node_set(nid, lru->active_nodes);
spin_unlock(&nlru->lock); spin_unlock(&nlru->lock);
return true; return true;
} }
...@@ -37,8 +36,7 @@ bool list_lru_del(struct list_lru *lru, struct list_head *item) ...@@ -37,8 +36,7 @@ bool list_lru_del(struct list_lru *lru, struct list_head *item)
spin_lock(&nlru->lock); spin_lock(&nlru->lock);
if (!list_empty(item)) { if (!list_empty(item)) {
list_del_init(item); list_del_init(item);
if (--nlru->nr_items == 0) nlru->nr_items--;
node_clear(nid, lru->active_nodes);
WARN_ON_ONCE(nlru->nr_items < 0); WARN_ON_ONCE(nlru->nr_items < 0);
spin_unlock(&nlru->lock); spin_unlock(&nlru->lock);
return true; return true;
...@@ -90,8 +88,7 @@ list_lru_walk_node(struct list_lru *lru, int nid, list_lru_walk_cb isolate, ...@@ -90,8 +88,7 @@ list_lru_walk_node(struct list_lru *lru, int nid, list_lru_walk_cb isolate,
case LRU_REMOVED_RETRY: case LRU_REMOVED_RETRY:
assert_spin_locked(&nlru->lock); assert_spin_locked(&nlru->lock);
case LRU_REMOVED: case LRU_REMOVED:
if (--nlru->nr_items == 0) nlru->nr_items--;
node_clear(nid, lru->active_nodes);
WARN_ON_ONCE(nlru->nr_items < 0); WARN_ON_ONCE(nlru->nr_items < 0);
isolated++; isolated++;
/* /*
...@@ -133,7 +130,6 @@ int list_lru_init_key(struct list_lru *lru, struct lock_class_key *key) ...@@ -133,7 +130,6 @@ int list_lru_init_key(struct list_lru *lru, struct lock_class_key *key)
if (!lru->node) if (!lru->node)
return -ENOMEM; return -ENOMEM;
nodes_clear(lru->active_nodes);
for (i = 0; i < nr_node_ids; i++) { for (i = 0; i < nr_node_ids; i++) {
spin_lock_init(&lru->node[i].lock); spin_lock_init(&lru->node[i].lock);
if (key) if (key)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册