diff mbox

sbitmap: don't update the allocation hint on clear after resize

Message ID 29fb3ca2c78084b3548fd87c0c9a946e2b68bffc.1474139647.git.osandov@fb.com (mailing list archive)
State New, archived
Headers show

Commit Message

Omar Sandoval Sept. 17, 2016, 7:20 p.m. UTC
From: Omar Sandoval <osandov@fb.com>

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 <osandov@fb.com>
---
Jens,

Small tweak to patch 6 that occurred to me after I sent the series out.
Feel free to fold it in to patch 6 or apply it separately as you see
fit.

Thanks!

 lib/sbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jens Axboe Sept. 17, 2016, 7:39 p.m. UTC | #1
On 09/17/2016 01:20 PM, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> 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 <osandov@fb.com>
> ---
> Jens,
>
> Small tweak to patch 6 that occurred to me after I sent the series out.
> Feel free to fold it in to patch 6 or apply it separately as you see
> fit.

No worries. I can't fold since the series was already applied, so I just
added the extra patch.
Omar Sandoval Sept. 17, 2016, 7:49 p.m. UTC | #2
On Sat, Sep 17, 2016 at 01:39:59PM -0600, Jens Axboe wrote:
> On 09/17/2016 01:20 PM, Omar Sandoval wrote:
> > From: Omar Sandoval <osandov@fb.com>
> > 
> > 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 <osandov@fb.com>
> > ---
> > Jens,
> > 
> > Small tweak to patch 6 that occurred to me after I sent the series out.
> > Feel free to fold it in to patch 6 or apply it separately as you see
> > fit.
> 
> No worries. I can't fold since the series was already applied, so I just
> added the extra patch.
> 

Okay with me, thanks!
diff mbox

Patch

diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index f736c52..e408089 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);