From: Jens Axboe <axboe@kernel.dk>
To: linux-block@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 3/9] sbitmap: test bit before calling test_and_set_bit()
Date: Tue, 12 Oct 2021 12:17:36 -0600 [thread overview]
Message-ID: <20211012181742.672391-4-axboe@kernel.dk> (raw)
In-Reply-To: <20211012181742.672391-1-axboe@kernel.dk>
If we come across bits that are already set, then it's quicker to test
that first and gate the test_and_set_bit() operation on the result of
the bit test.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
lib/sbitmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index c6e2f1f2c4d2..11b244a8d00f 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -166,7 +166,7 @@ static int __sbitmap_get_word(unsigned long *word, unsigned long depth,
return -1;
}
- if (!test_and_set_bit_lock(nr, word))
+ if (!test_bit(nr, word) && !test_and_set_bit_lock(nr, word))
break;
hint = nr + 1;
--
2.33.0
next prev parent reply other threads:[~2021-10-12 18:17 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 18:17 [PATCHSET 0/9] Batched completions Jens Axboe
2021-10-12 18:17 ` [PATCH 1/9] block: add a struct io_batch argument to fops->iopoll() Jens Axboe
2021-10-12 18:25 ` Bart Van Assche
2021-10-12 18:28 ` Jens Axboe
2021-10-12 18:17 ` [PATCH 2/9] sbitmap: add helper to clear a batch of tags Jens Axboe
2021-10-12 18:29 ` Bart Van Assche
2021-10-12 18:34 ` Jens Axboe
2021-10-12 18:17 ` Jens Axboe [this message]
2021-10-12 18:17 ` [PATCH 4/9] block: add support for blk_mq_end_request_batch() Jens Axboe
2021-10-12 18:32 ` Bart Van Assche
2021-10-12 18:55 ` Jens Axboe
2021-10-12 18:17 ` [PATCH 5/9] nvme: move the fast path nvme error and disposition helpers Jens Axboe
2021-10-13 6:57 ` Christoph Hellwig
2021-10-13 14:41 ` Jens Axboe
2021-10-13 15:11 ` Christoph Hellwig
2021-10-12 18:17 ` [PATCH 6/9] nvme: add support for batched completion of polled IO Jens Axboe
2021-10-13 7:08 ` Christoph Hellwig
2021-10-13 15:10 ` Jens Axboe
2021-10-13 15:16 ` Christoph Hellwig
2021-10-13 15:42 ` Jens Axboe
2021-10-13 15:49 ` Jens Axboe
2021-10-13 15:50 ` Christoph Hellwig
2021-10-13 16:04 ` Jens Axboe
2021-10-13 16:13 ` Christoph Hellwig
2021-10-13 16:33 ` Jens Axboe
2021-10-13 16:45 ` Jens Axboe
2021-10-13 9:09 ` John Garry
2021-10-13 15:07 ` Jens Axboe
2021-10-12 18:17 ` [PATCH 7/9] block: assign batch completion handler in blk_poll() Jens Axboe
2021-10-12 18:17 ` [PATCH 8/9] io_uring: utilize the io_batch infrastructure for more efficient polled IO Jens Axboe
2021-10-12 18:17 ` [PATCH 9/9] nvme: wire up completion batching for the IRQ path Jens Axboe
2021-10-13 7:12 ` Christoph Hellwig
2021-10-13 15:04 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211012181742.672391-4-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).