From: Omar Sandoval Date: Sat, 17 Sep 2016 19:20:54 +0000 (-0700) Subject: sbitmap: don't update the allocation hint on clear after resize X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5c64a8df0ca88c79c9cb74674c2481e5f7ede511;p=linux-beck.git sbitmap: don't update the allocation hint on clear after resize If we have a bunch of high-numbered bits allocated and then we resize the struct sbitmap_queue, when those bits get cleared, we'll update the hint and then have to re-randomize it repeatedly. Avoid that by checking that the cleared bit is still a valid hint. No measurable performance difference in the common case. Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe --- diff --git a/lib/sbitmap.c b/lib/sbitmap.c index f736c52a712c..e40808921544 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c @@ -321,7 +321,7 @@ void sbitmap_queue_clear(struct sbitmap_queue *sbq, unsigned int nr, { sbitmap_clear_bit(&sbq->sb, nr); sbq_wake_up(sbq); - if (likely(!sbq->round_robin)) + if (likely(!sbq->round_robin && nr < sbq->sb.depth)) *per_cpu_ptr(sbq->alloc_hint, cpu) = nr; } EXPORT_SYMBOL_GPL(sbitmap_queue_clear);