linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <n.borisov.lkml@gmail.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: introduce conditional wakeup helpers
Date: Thu, 8 Mar 2018 14:30:14 +0200	[thread overview]
Message-ID: <f92b1fbf-cec1-2e8c-a032-560bc7888730@gmail.com> (raw)
In-Reply-To: <96b9c7113ac06d981c3f69638762c4502651f6af.1520509627.git.dsterba@suse.com>



On  8.03.2018 13:49, David Sterba wrote:
> Add convenience wrappers for the waitqueue management that involves
> memory barriers to prevent deadlocks. The helpers will let us remove
> barriers and the necessary comments in several places.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/ctree.h | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index bf545e7552b8..c9827a1b676d 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -3748,4 +3748,27 @@ static inline int btrfs_is_testing(struct btrfs_fs_info *fs_info)
>  #endif
>  	return 0;
>  }
> +
> +static inline void cond_wake_up(struct wait_queue_head *wq)
> +{
> +	/*
> +	 * This implies a full smp_mb barrier, see comments for
> +	 * waitqueue_active why.
> +	 */
> +	if (wq_has_sleeper(wq))
> +		wake_up(wq);
> +}
> +
> +static inline void cond_wake_up_nomb(struct wait_queue_head *wq)
> +{
> +	/*
> +	 * Special case for conditional wakeup where the barrier required for
> +	 * waitqueue_active is implied by some of the preceding code. Eg. one
> +	 * of such atomic operations (atomic_dec_and_return, ...), or a
> +	 * unlock/lock sequence, etc.
> +	 */
> +	if (waitqueue_active(wq))
> +		wake_up(wq);
> +}
> +
>  #endif
> 

  reply	other threads:[~2018-03-08 12:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08 11:49 [PATCH 0/2] Cleanup waitqueue_active and barriers David Sterba
2018-03-08 11:49 ` [PATCH 1/2] btrfs: introduce conditional wakeup helpers David Sterba
2018-03-08 12:30   ` Nikolay Borisov [this message]
2018-03-08 11:49 ` [PATCH 2/2] btrfs: replace waitqueue_actvie with cond_wake_up David Sterba
2018-03-08 12:19   ` Nikolay Borisov
2018-03-08 16:47     ` David Sterba
2018-03-16 17:00       ` 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=f92b1fbf-cec1-2e8c-a032-560bc7888730@gmail.com \
    --to=n.borisov.lkml@gmail.com \
    --cc=dsterba@suse.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).