mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: Hou Tao <houtao@huaweicloud.com>, linux-cachefs@redhat.com
Cc: David Howells <dhowells@redhat.com>,
	Jeff Layton <jlayton@kernel.org>,
	linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	houtao1@huawei.com
Subject: Re: [PATCH v2 2/2] fscache: Add the missing smp_mb__after_atomic() before wake_up_bit()
Date: Thu, 12 Jan 2023 12:34:30 +0800	[thread overview]
Message-ID: <8b0af045-25c1-9848-3c8c-de7da94d06da@linux.alibaba.com> (raw)
In-Reply-To: <20221226103309.953112-3-houtao@huaweicloud.com>



On 12/26/22 6:33 PM, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>
> 
> fscache_create_volume_work() uses wake_up_bit() to wake up the processes
> which are waiting for the completion of volume creation. According to
> comments in wake_up_bit() and waitqueue_active(), an extra smp_mb() is
> needed to guarantee the memory order between FSCACHE_VOLUME_CREATING
> flag and waitqueue_active() before invoking wake_up_bit().
> 
> Considering clear_bit_unlock() before wake_up_bit() is an atomic
> operation, use smp_mb__after_atomic() instead of smp_mb() to provide
> such guarantee.
> 
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
>  fs/fscache/volume.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/fscache/volume.c b/fs/fscache/volume.c
> index fc3dd3bc851d..734d17f404e7 100644
> --- a/fs/fscache/volume.c
> +++ b/fs/fscache/volume.c
> @@ -281,6 +281,11 @@ static void fscache_create_volume_work(struct work_struct *work)
>  				 fscache_access_acquire_volume_end);
>  
>  	clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags);
> +	/*
> +	 * Paired with barrier in wait_on_bit(). Check wake_up_bit() and
> +	 * waitqueue_active() for details.
> +	 */
> +	smp_mb__after_atomic();
>  	wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING);
>  	fscache_put_volume(volume, fscache_volume_put_create_work);
>  }

LGTM.

Actually I'm thinking if clear_and_wake_up_bit() could be used here.
Ditto for patch 1.

-- 
Thanks,
Jingbo

  reply	other threads:[~2023-01-12  4:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26 10:33 [PATCH v2 0/2] Fixes for fscache volume operations Hou Tao
2022-12-26 10:33 ` [PATCH v2 1/2] fscache: Use wait_on_bit() to wait for the freeing of relinquished volume Hou Tao
2023-01-12  3:47   ` Jingbo Xu
2023-01-12  6:14     ` Hou Tao
2022-12-26 10:33 ` [PATCH v2 2/2] fscache: Add the missing smp_mb__after_atomic() before wake_up_bit() Hou Tao
2023-01-12  4:34   ` Jingbo Xu [this message]
2023-01-12  6:17     ` Hou Tao
2023-01-11  4:03 ` [PATCH v2 0/2] Fixes for fscache volume operations Hou Tao
2023-01-11 16:06 ` [PATCH v2 1/2] fscache: Use wait_on_bit() to wait for the freeing of relinquished volume David Howells
2023-01-12  1:05   ` Hou Tao
2023-01-12  3:58   ` Jingbo Xu
2023-01-12  6:12     ` Hou Tao
2023-01-11 16:09 ` [PATCH v2 2/2] fscache: Add the missing smp_mb__after_atomic() before wake_up_bit() David Howells
2023-01-12  1:07   ` Hou Tao
2023-01-11 16:24 ` David Howells

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=8b0af045-25c1-9848-3c8c-de7da94d06da@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=dhowells@redhat.com \
    --cc=houtao1@huawei.com \
    --cc=houtao@huaweicloud.com \
    --cc=jlayton@kernel.org \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®