public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: valdis.kletnieks@vt.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/staging/exfat: Replace binary semaphores for mutexes
Date: Tue, 29 Oct 2019 09:05:21 +0100	[thread overview]
Message-ID: <20191029080521.GA494993@kroah.com> (raw)
In-Reply-To: <20191028024519.32344-1-dave@stgolabs.net>

On Sun, Oct 27, 2019 at 07:45:19PM -0700, Davidlohr Bueso wrote:
> At a slight footprint cost (24 vs 32 bytes), mutexes are more optimal
> than semaphores; it's also a nicer interface for mutual exclusion,
> which is why they are encouraged over binary semaphores, when possible.
> There is also lockdep support.
> 
> For both v_sem and z_sem, their semantics imply traditional lock
> ownership; that is, the lock owner is the same for both lock/unlock
> operations and nothing is done in irq context. Therefore it is safe
> to convert.
> 
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
> This is part of further reducing semaphore users in the kernel.
> 
>  drivers/staging/exfat/exfat.h       |  2 +-
>  drivers/staging/exfat/exfat_super.c | 84 ++++++++++++++++++-------------------
>  2 files changed, 43 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h
> index 6c12f2d79f4d..95c02f55de60 100644
> --- a/drivers/staging/exfat/exfat.h
> +++ b/drivers/staging/exfat/exfat.h
> @@ -618,7 +618,7 @@ struct fs_info_t {
>  	u32 dev_ejected;	/* block device operation error flag */
>  
>  	struct fs_func *fs_func;
> -	struct semaphore v_sem;
> +	struct mutex v_mutex;
>  
>  	/* FAT cache */
>  	struct buf_cache_t FAT_cache_array[FAT_CACHE_SIZE];
> diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
> index 5f6caee819a6..c0b09b2dbe96 100644
> --- a/drivers/staging/exfat/exfat_super.c
> +++ b/drivers/staging/exfat/exfat_super.c
> @@ -283,7 +283,7 @@ static const struct dentry_operations exfat_dentry_ops = {
>  	.d_compare      = exfat_cmp,
>  };
>  
> -static DEFINE_SEMAPHORE(z_sem);
> +static DEFINE_MUTEX(z_mutex);
>  
>  static inline void fs_sync(struct super_block *sb, bool do_sync)
>  {
> @@ -352,11 +352,11 @@ static int ffsMountVol(struct super_block *sb)
>  
>  	pr_info("[EXFAT] trying to mount...\n");
>  
> -	down(&z_sem);
> +        mutex_lock(&z_mutex);

No tabs?  :(


  reply	other threads:[~2019-10-29  8:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28  2:45 [PATCH] drivers/staging/exfat: Replace binary semaphores for mutexes Davidlohr Bueso
2019-10-29  8:05 ` Greg KH [this message]
2019-10-30 14:49   ` [PATCH v2] " Davidlohr Bueso
2019-10-30 15:40     ` Valdis Klētnieks

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=20191029080521.GA494993@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=dave@stgolabs.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=valdis.kletnieks@vt.edu \
    /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