diff options
author | Waiman Long <longman@redhat.com> | 2018-05-26 14:15:31 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2018-05-26 14:29:10 +1000 |
commit | 9f55e4564e4cd622368a284d4f4b97e9cdacb124 (patch) | |
tree | 27940103bdf8914d4f3f0c04e5863ca0659aa4f4 /mm | |
parent | b2b2d2d41727c0b45f176913be0d3ea28d7584fc (diff) | |
download | linux-next-9f55e4564e4cd622368a284d4f4b97e9cdacb124.tar.gz |
mm/list_lru.c: prefetch neighboring list entries before acquiring lock
list_lru_del() removes the given item from the LRU list. The operation
looks simple, but it involves writing into the cachelines of the two
neighboring list entries in order to get the deletion done. That can take
a while if the cachelines aren't there yet, thus prolonging the lock hold
time.
To reduce the lock hold time, the cachelines of the two neighboring list
entries are now prefetched before acquiring the list_lru_node's lock.
Using a multi-threaded test program that created a large number of
dentries and then killed them, the execution time was reduced from 38.5s
to 36.6s after applying the patch on a 2-socket 36-core 72-thread x86-64
system.
Link: http://lkml.kernel.org/r/1511965054-6328-1-git-send-email-longman@redhat.com
Signed-off-by: Waiman Long <longman@redhat.com>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/list_lru.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mm/list_lru.c b/mm/list_lru.c index fcfb6c89ed47..c1818d85b0f5 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -133,8 +133,16 @@ bool list_lru_del(struct list_lru *lru, struct list_head *item) struct list_lru_node *nlru = &lru->node[nid]; struct list_lru_one *l; + /* + * Prefetch the neighboring list entries to reduce lock hold time. + */ + if (unlikely(list_empty(item))) + return false; + prefetchw(item->prev); + prefetchw(item->next); + spin_lock(&nlru->lock); - if (!list_empty(item)) { + if (likely(!list_empty(item))) { l = list_lru_from_kmem(nlru, item); list_del_init(item); l->nr_items--; |