lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191029080521.GA494993@kroah.com>
Date:   Tue, 29 Oct 2019 09:05:21 +0100
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Davidlohr Bueso <dave@...olabs.net>
Cc:     valdis.kletnieks@...edu, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers/staging/exfat: Replace binary semaphores for
 mutexes

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@...olabs.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?  :(

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ