All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 4/4] btrfs: use test_and_clear_bit() in wait_dev_flush()
Date: Tue, 28 Mar 2023 13:05:12 +0800	[thread overview]
Message-ID: <4eba5d17-ba03-46b6-a936-1d9a9bc55960@oracle.com> (raw)
In-Reply-To: <20230327171427.GI10580@twin.jikos.cz>



On 3/28/23 01:14, David Sterba wrote:
> On Mon, Mar 27, 2023 at 05:53:10PM +0800, Anand Jain wrote:
>> The function wait_dev_flush() tests for the BTRFS_DEV_STATE_FLUSH_SENT
>> bit and then clears it separately. Instead, use test_and_clear_bit().
> 
> But why would we need to do it like that? The write and wait are
> executed in one thread so we don't need atomic change to the status and
> thus a separate set/test/clear bit are fine. If not, then please
> explain. Thanks.

It's true that atomic test_and_clear_bit() isn't necessary in this case.
Nonetheless, using it have benefits such as cleaner code and improved
efficiency[1].

  [1]. I was curious, so I made wait_dev_flush() non-inline and checked
  the ASM code for wait_dev_flush(). After the patch, there were 8 fewer
  instructions.

I'm okay with dropping this patch if you prefer to maintain the correct
usage of test_and_clear_bit().

Thanks, Anand


  reply	other threads:[~2023-03-28  5:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27  9:53 [PATCH 0/4] btrfs: optimize disks flush code Anand Jain
2023-03-27  9:53 ` [PATCH 1/4] btrfs: move last_flush_error to write_dev_flush and wait_dev_flush Anand Jain
2023-03-27  9:53 ` [PATCH 2/4] btrfs: opencode check_barrier_error() Anand Jain
2023-03-27  9:53 ` [PATCH 3/4] Btrfs: change wait_dev_flush() return type to bool Anand Jain
2023-03-27 17:11   ` David Sterba
2023-03-28  2:58     ` Anand Jain
2023-03-27 23:52   ` kernel test robot
2023-03-28  5:31   ` [PATCH] fixup: Btrfs: change wait_dev_flush() return type to bool v2 Anand Jain
2023-03-28 18:28     ` David Sterba
2023-03-27  9:53 ` [PATCH 4/4] btrfs: use test_and_clear_bit() in wait_dev_flush() Anand Jain
2023-03-27 17:14   ` David Sterba
2023-03-28  5:05     ` Anand Jain [this message]
2023-03-28 18:33       ` David Sterba

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=4eba5d17-ba03-46b6-a936-1d9a9bc55960@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@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.