Skip to content

Commit

Permalink
list_lru: don't call list_lru_from_kmem if the list_head is empty
Browse files Browse the repository at this point in the history
If the list_head is empty then we'll have called list_lru_from_kmem for
nothing.  Move that call inside of the list_empty if block.

Signed-off-by: Jeff Layton <[email protected]>
Reviewed-by: Vladimir Davydov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jtlayton authored and torvalds committed Sep 8, 2015
1 parent 21cd3a6 commit 26f5d76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/list_lru.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item)
struct list_lru_one *l;

spin_lock(&nlru->lock);
l = list_lru_from_kmem(nlru, item);
if (list_empty(item)) {
l = list_lru_from_kmem(nlru, item);
list_add_tail(item, &l->list);
l->nr_items++;
spin_unlock(&nlru->lock);
Expand All @@ -118,8 +118,8 @@ bool list_lru_del(struct list_lru *lru, struct list_head *item)
struct list_lru_one *l;

spin_lock(&nlru->lock);
l = list_lru_from_kmem(nlru, item);
if (!list_empty(item)) {
l = list_lru_from_kmem(nlru, item);
list_del_init(item);
l->nr_items--;
spin_unlock(&nlru->lock);
Expand Down

0 comments on commit 26f5d76

Please sign in to comment.