From: Jens Axboe <axboe@kernel.dk>
To: Bart Van Assche <bvanassche@acm.org>, linux-block@vger.kernel.org
Subject: Re: [PATCH 2/9] sbitmap: add helper to clear a batch of tags
Date: Tue, 12 Oct 2021 12:34:29 -0600 [thread overview]
Message-ID: <8f7f3314-3cd6-5d30-6bed-b7ed119b1e6b@kernel.dk> (raw)
In-Reply-To: <f7532d88-74a2-9f3e-2a95-29e6508e889f@acm.org>
On 10/12/21 12:29 PM, Bart Van Assche wrote:
> On 10/12/21 11:17 AM, Jens Axboe wrote:
>> +void sbitmap_queue_clear_batch(struct sbitmap_queue *sbq, int offset,
>> + int *tags, int nr_tags)
>> +{
>> + struct sbitmap *sb = &sbq->sb;
>> + unsigned long *addr = NULL;
>> + unsigned long mask = 0;
>> + int i;
>> +
>> + smp_mb__before_atomic();
>> + for (i = 0; i < nr_tags; i++) {
>> + const int tag = tags[i] - offset;
>> + unsigned long *this_addr;
>> +
>> + /* since we're clearing a batch, skip the deferred map */
>> + this_addr = &sb->map[SB_NR_TO_INDEX(sb, tag)].word;
>> + if (!addr) {
>> + addr = this_addr;
>> + } else if (addr != this_addr) {
>> + atomic_long_andnot(mask, (atomic_long_t *) addr);
>> + mask = 0;
>> + addr = this_addr;
>> + }
>> + mask |= (1UL << SB_NR_TO_BIT(sb, tag));
>> + }
>> +
>> + if (mask)
>> + atomic_long_andnot(mask, (atomic_long_t *) addr);
>> +
>> + smp_mb__after_atomic();
>> + sbitmap_queue_wake_up(sbq);
>> + sbitmap_update_cpu_hint(&sbq->sb, raw_smp_processor_id(),
>> + tags[nr_tags - 1] - offset);
>> +}
>> +
>> void sbitmap_queue_clear(struct sbitmap_queue *sbq, unsigned int nr,
>> unsigned int cpu)
>> {
>
> How does replacing the sbitmap_queue_clear() implementation by calling
> sbitmap_queue_clear_batch() affect performance? I'm wondering whether it
> is possible to prevent code duplication without affecting performance
> negatively.
Good question, I'd rather defer that to a followup though if it ends up
making sense. It's not that simple, as we play some tricks for the usual
clear path by inserting a deferred mask to avoid hitting the cacheline
repeatedly. That doesn't make sense to do for batched clears, obviously,
so they work in slightly different ways where the single bit clear has
an extra step to increase the efficiency.
--
Jens Axboe
next prev parent reply other threads:[~2021-10-12 18:37 UTC|newest]
Thread overview: 34+ 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 [this message]
2021-10-12 18:17 ` [PATCH 3/9] sbitmap: test bit before calling test_and_set_bit() Jens Axboe
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 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=8f7f3314-3cd6-5d30-6bed-b7ed119b1e6b@kernel.dk \
--to=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.