From patchwork Sat Sep 17 19:20:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9337327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 852996022E for ; Sat, 17 Sep 2016 19:21:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 783D428E87 for ; Sat, 17 Sep 2016 19:21:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CE2228ECC; Sat, 17 Sep 2016 19:21:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9D6D28E87 for ; Sat, 17 Sep 2016 19:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754428AbcIQTVF (ORCPT ); Sat, 17 Sep 2016 15:21:05 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:33223 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754376AbcIQTVE (ORCPT ); Sat, 17 Sep 2016 15:21:04 -0400 Received: by mail-pf0-f169.google.com with SMTP id 21so26797042pfy.0 for ; Sat, 17 Sep 2016 12:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1owlOVd8qvQ32W3Ng/Dc3bmTpR9PVSkcx5m3ZQJwGUU=; b=Vea2YNt5uYy3xSr5HophtxmCMeoxRyfiAocQ2xvh6AVd7dtI2mtVUFaQ3pnFrpsStH 3wzG9nUCjA/tlaBHj05ndb5imsmb9R/moI8jyTFsU19BCu2mENmB1bNLQiMsb4mEFlPV 0HqqPU3cHcUS7wcUXxhPwUXpsJc2Ub6zP6xgcqGw6mnV2iVlZIz5Hhu5ECyLBtjYYyAA LReAILrBkJk1QT9BELofjgQKnlI0X7yAw/HSzr8qsTWVAVRBjeQnodQgw+BK0mOhvlLT yMpmmAXTlbxQ4doarBvKuDRQBy7hNfGCdltdPhaVcwRNrViGPtdaxhOYVS7D75HSDsPq k7aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1owlOVd8qvQ32W3Ng/Dc3bmTpR9PVSkcx5m3ZQJwGUU=; b=OiTe88IEcwLANfh0bD/jtETv47cR+jqejHgVo68gF3yyYrzRnQ/i1CzFzmzIpu6cvt MSdU7IzJrdIF+QHTzTaoqPC6sFS8rniSGkp2ePz2beHFDgeS+2C7F19tGvR+llSPnUVG hCIeyk46NFCmDKoTp8kcCM773U8xefyE85ZF6SwxTmo//+PABF0IamesnZaJ9mzGTtef ZPjPg73u+bkQo54GrytpCKxtL1yd19xA3s7TsU+/j5nKES8AF7OY3t2MaEfDmhRVHvXR osy+2N9gn0d18mytnusTPlr0W8DF7eZ+bwEgEDDGOxdwjUoJtmjH9PLMsABmLb/Jh2YH 2ciA== X-Gm-Message-State: AE9vXwOBs2+06rviHG2lkcnCKtxZNpUPwcSj8+CxUV3KJTvqZICNHgehBwPORJEoSkEBJ7HD X-Received: by 10.98.220.93 with SMTP id t90mr33435702pfg.30.1474140063420; Sat, 17 Sep 2016 12:21:03 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:180::f2c]) by smtp.gmail.com with ESMTPSA id ci9sm20720315pad.34.2016.09.17.12.21.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Sep 2016 12:21:02 -0700 (PDT) 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-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);