From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754509AbcIQTVJ (ORCPT ); Sat, 17 Sep 2016 15:21:09 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:33223 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754341AbcIQTVE (ORCPT ); Sat, 17 Sep 2016 15:21:04 -0400 From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, Alexei Starovoitov Subject: [PATCH] sbitmap: don't update the allocation hint on clear after resize Date: Sat, 17 Sep 2016 12:20:54 -0700 Message-Id: <29fb3ca2c78084b3548fd87c0c9a946e2b68bffc.1474139647.git.osandov@fb.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <54286aca-7ce6-5138-9189-83a2dff444b1@fb.com> References: <54286aca-7ce6-5138-9189-83a2dff444b1@fb.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Omar Sandoval 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 --- 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(-) 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); -- 2.9.3