From: Jeff Layton Date: Tue, 8 Sep 2015 22:03:44 +0000 (-0700) Subject: list_lru: don't call list_lru_from_kmem if the list_head is empty X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=26f5d7609f03ad8d6dc552458e4e371a62416b37;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git list_lru: don't call list_lru_from_kmem if the list_head is empty 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 Reviewed-by: Vladimir Davydov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/list_lru.c b/mm/list_lru.c index 909eca2c820e..e1da19fac1b3 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -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); @@ -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);