From: YangYang <yang.yang@vivo.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jens Axboe <axboe@kernel.dk>, Ming Lei <ming.lei@redhat.com>,
Omar Sandoval <osandov@fb.com>,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH v6] sbitmap: fix io hung due to race on sbitmap_word::cleared
Date: Thu, 11 Jul 2024 17:47:36 +0800 [thread overview]
Message-ID: <591ba004-c28a-4956-ae13-c02cc8d235d3@vivo.com> (raw)
In-Reply-To: <ff5cc2b2-bf8e-4a48-8422-cdaac4129043@acm.org>
On 2024/7/11 0:41, Bart Van Assche wrote:
> On 7/9/24 11:56 PM, Yang Yang wrote:
>> + spin_lock_irqsave(&map->swap_lock, flags);
>
> Please use guard(spinlock_irqsave) in new code instead of spin_lock_irqsave() + goto out_unlock
> + spin_unlock_irqrestore().
> That will make this function significantly easier to read and to
> maintain.
Got it.
>
>> +
>> + if (!map->cleared) {
>> + if (depth > 0) {
>> + word_mask = (~0UL) >> (BITS_PER_LONG - depth);
>> + /*
>> + * The current behavior is to always retry after moving
>> + * ->cleared to word, and we change it to retry in case
>> + * of any free bits. To avoid dead loop, we need to take
>
> What is a "dead loop"? Did you perhaps want to write "infinite loop"?
Yeah. I suppose so.
>
>> + * wrap & alloc_hint into account. Without this, a soft
>> + * lockup was detected in our test environment.
>
> Source code comments should not refer to "our test environment". Code
> that is intended for upstream inclusion should work for all setups.
Got it.
>
>> + */
>> + if (!wrap && alloc_hint)
>> + word_mask &= ~((1UL << alloc_hint) - 1);
>
> Above I see an open-coded __clear_bit() operation. Has it been
> considered to use __clear_bit() instead of open-coding it?
It is meant to reset multiple bits to zero, but __clear_bit() is only
capable of resetting one bit to zero.
Thanks.
>
> Thanks,
>
> Bart.
next prev parent reply other threads:[~2024-07-11 9:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 6:56 Yang Yang
2024-07-10 16:41 ` Bart Van Assche
2024-07-11 9:47 ` YangYang [this message]
2024-07-10 19:54 ` Bart Van Assche
2024-07-11 12:48 ` YangYang
2024-07-11 13:39 ` Ming Lei
2024-07-11 16:33 ` Bart Van Assche
2024-07-12 1:01 ` Ming Lei
2024-07-12 17:53 ` Bart Van Assche
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=591ba004-c28a-4956-ae13-c02cc8d235d3@vivo.com \
--to=yang.yang@vivo.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=osandov@fb.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
all inboxes | Powered by JetHome®