From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: akpm@linux-foundation.org, vdavydov.dev@gmail.com,
ktkhai@virtuozzo.com, bigeasy@linutronix.de, adobriyan@gmail.com,
linux-mm@kvack.org
Subject: [PATCH] mm/list_lru: Simplify __list_lru_walk_one()
Date: Wed, 20 Mar 2019 14:19:27 +0300 [thread overview]
Message-ID: <155308075272.10600.3895589023886665456.stgit@localhost.localdomain> (raw)
1)Spinlock must be locked in any case, so assert_spin_locked()
are moved above the switch;
2)Replace assert_spin_locked() with lockdep_assert_held(),
since it is enabled in debug kernel only and it does
not affect on runtime in other cases;
3)Reorder switch cases to make duplicate comment not needed.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
mm/list_lru.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 0730bf8ff39f..5f9fc84f1046 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -232,33 +232,26 @@ __list_lru_walk_one(struct list_lru_node *nlru, int memcg_idx,
--*nr_to_walk;
ret = isolate(item, l, &nlru->lock, cb_arg);
+ lockdep_assert_held(&nlru->lock);
switch (ret) {
case LRU_REMOVED_RETRY:
- assert_spin_locked(&nlru->lock);
- /* fall through */
case LRU_REMOVED:
isolated++;
nlru->nr_items--;
+ if (ret == LRU_REMOVED)
+ break;
+ /* fall through */
+ case LRU_RETRY:
/*
- * If the lru lock has been dropped, our list
- * traversal is now invalid and so we have to
- * restart from scratch.
+ * The lru lock has been dropped, our list traversal is
+ * now invalid and so we have to restart from scratch.
*/
- if (ret == LRU_REMOVED_RETRY)
- goto restart;
- break;
+ goto restart;
case LRU_ROTATE:
list_move_tail(item, &l->list);
break;
case LRU_SKIP:
break;
- case LRU_RETRY:
- /*
- * The lru lock has been dropped, our list traversal is
- * now invalid and so we have to restart from scratch.
- */
- assert_spin_locked(&nlru->lock);
- goto restart;
default:
BUG();
}
next reply other threads:[~2019-03-20 11:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-20 11:19 Kirill Tkhai [this message]
2019-03-20 18:52 ` Andrew Morton
2019-03-20 19:52 ` Kirill Tkhai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=155308075272.10600.3895589023886665456.stgit@localhost.localdomain \
--to=ktkhai@virtuozzo.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=linux-mm@kvack.org \
--cc=vdavydov.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox