From: Pankaj Raghav <pankydev8@gmail.com>
To: Keith Busch <kbusch@fb.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
Keith Busch <kbusch@kernel.org>,
Pankaj Raghav <p.raghav@samsung.com>
Subject: Re: [PATCHv2] sbitmap: fix batched wait_cnt accounting
Date: Thu, 25 Aug 2022 13:48:07 +0200 [thread overview]
Message-ID: <20220825114807.v5pjnkvtfttlsiv4@quentin> (raw)
In-Reply-To: <20220824201440.127782-1-kbusch@fb.com>
On Wed, Aug 24, 2022 at 01:14:40PM -0700, Keith Busch wrote:
>
> -static bool __sbq_wake_up(struct sbitmap_queue *sbq)
> +static bool __sbq_wake_up(struct sbitmap_queue *sbq, int *nr)
> {
> struct sbq_wait_state *ws;
> - unsigned int wake_batch;
> - int wait_cnt;
> + int wake_batch, wait_cnt, sub, cur;
>
> ws = sbq_wake_ptr(sbq);
> if (!ws)
> return false;
>
> - wait_cnt = atomic_dec_return(&ws->wait_cnt);
> + wake_batch = READ_ONCE(sbq->wake_batch);
> + do {
> + cur = atomic_read(&ws->wait_cnt);
I think the above statement is not needed if we use atomic_try_cmpxchg
as the old value is updated in that function itself.
https://docs.kernel.org/staging/index.html?highlight=atomic_try_cmpxchg#atomic-types
> + sub = min3(wake_batch, *nr, cur);
> + wait_cnt = cur - sub;
> + } while (!atomic_try_cmpxchg(&ws->wait_cnt, &cur, wait_cnt));
> +
> + *nr -= sub;
> +
> /*
--
Pankaj Raghav
next prev parent reply other threads:[~2022-08-25 11:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 20:14 [PATCHv2] sbitmap: fix batched wait_cnt accounting Keith Busch
2022-08-25 6:09 ` Hannes Reinecke
2022-08-25 12:59 ` Keith Busch
2022-08-25 13:29 ` Keith Busch
2022-08-25 11:48 ` Pankaj Raghav [this message]
2022-08-25 11:55 ` Pankaj Raghav
2022-08-25 13:05 ` Keith Busch
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=20220825114807.v5pjnkvtfttlsiv4@quentin \
--to=pankydev8@gmail.com \
--cc=axboe@kernel.dk \
--cc=kbusch@fb.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=p.raghav@samsung.com \
/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