Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1209836 > unrolled thread

[PATCH] list_lru: don't call list_lru_from_kmem if the list_head is empty

Started byJeff Layton <jlayton@poochiereds.net>
First post2015-08-19 16:10 +0200
Last post2015-08-19 16:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] list_lru: don't call list_lru_from_kmem if the list_head is empty Jeff Layton <jlayton@poochiereds.net> - 2015-08-19 16:10 +0200
    Re: [PATCH] list_lru: don't call list_lru_from_kmem if the list_head  is empty Vladimir Davydov <vdavydov@parallels.com> - 2015-08-19 16:30 +0200

#1209836 — [PATCH] list_lru: don't call list_lru_from_kmem if the list_head is empty

FromJeff Layton <jlayton@poochiereds.net>
Date2015-08-19 16:10 +0200
Subject[PATCH] list_lru: don't call list_lru_from_kmem if the list_head is empty
Message-ID<pZcdY-88J-3@gated-at.bofh.it>
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.

Cc: Vladimir Davydov <vdavydov@parallels.com>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
---
 mm/list_lru.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1209849 — Re: [PATCH] list_lru: don't call list_lru_from_kmem if the list_head is empty

FromVladimir Davydov <vdavydov@parallels.com>
Date2015-08-19 16:30 +0200
SubjectRe: [PATCH] list_lru: don't call list_lru_from_kmem if the list_head is empty
Message-ID<pZcxk-8va-23@gated-at.bofh.it>
In reply to#1209836
On Wed, Aug 19, 2015 at 10:05:40AM -0400, Jeff Layton wrote:
> 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.
> 
> Cc: Vladimir Davydov <vdavydov@parallels.com>
> Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>

Reviewed-by: Vladimir Davydov <vdavydov@parallels.com>

> ---
>  mm/list_lru.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web