diff options
| author | Mikulas Patocka <mpatocka@redhat.com> | 2016-11-23 16:52:01 -0500 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-12-10 14:25:12 +0100 |
| commit | d3dc597a6c754da47500866c8ebaa46bda2b5e1d (patch) | |
| tree | 360b0500d98e0553d9224a764076834717f1b302 | |
| parent | 2b9cec0604125ebb95b7095fdba876b01eef841c (diff) | |
BACKPORT: dm bufio: don't take the lock in dm_bufio_shrink_count
dm_bufio_shrink_count() is called from do_shrink_slab to find out how many
freeable objects are there. The reported value doesn't have to be precise,
so we don't need to take the dm-bufio lock.
Suggested-by: David Rientjes <rientjes@google.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Bug: 64122284
Change-Id: Id2c3446e03e865f424be8666b1ee0822b9e33a63
(cherry picked from commit d12067f428c037b4575aaeb2be00847fc214c24a)
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
| -rw-r--r-- | drivers/md/dm-bufio.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index ecfc20650..7078ddf21 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -1443,20 +1443,20 @@ static int shrink(struct shrinker *shrinker, struct shrink_control *sc) unsigned long r; unsigned long nr_to_scan = sc->nr_to_scan; - if (sc->gfp_mask & __GFP_IO) - dm_bufio_lock(c); - else if (!dm_bufio_trylock(c)) - return !nr_to_scan ? 0 : -1; + if (nr_to_scan) { + if (sc->gfp_mask & __GFP_IO) + dm_bufio_lock(c); + else if (!dm_bufio_trylock(c)) + return -1; - if (nr_to_scan) __scan(c, nr_to_scan, sc); + dm_bufio_unlock(c); + } - r = c->n_buffers[LIST_CLEAN] + c->n_buffers[LIST_DIRTY]; + r = ACCESS_ONCE(c->n_buffers[LIST_CLEAN]) + ACCESS_ONCE(c->n_buffers[LIST_DIRTY]); if (r > INT_MAX) r = INT_MAX; - dm_bufio_unlock(c); - return r; } |
