Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4052702ybg; Tue, 29 Oct 2019 01:10:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkn+9FO5P3GRUf7R/s7VpZcf9jj7ru+6z1GjhuccsO71JsTwOjz8zVF12Sp7WySgXdY+cz X-Received: by 2002:a17:906:8046:: with SMTP id x6mr1887745ejw.221.1572336627027; Tue, 29 Oct 2019 01:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572336627; cv=none; d=google.com; s=arc-20160816; b=irQKiC+IKXNy0nHrLpuxShsfZEC0w0Zy9I2GapvdRo9sLnOJouR8Ywy5tpAdHQkq+Z 5UPvpgUfPI2DvBwGo2VKXPNCmx7bnVJA2MPRvw/Im+2cCR8Zrk9kiwPWfaVhBsb5G1rv tfvVCZC6LDIxMxSt+rxq8teB8+gHRYB8OdFz+GYhwyV5WU2Gv+jJ7A8+w5BpwClnZBD1 0eihi305CdFLpQjG4jldCYSXrZK7E2ER0weX7pMV8y5qf7b2RJbXTAhyLMjygivGlZ21 vk2eiefZ/4oQBWiL7OIpr3Oq96gIBfik/OlNjbrwAJ4gk14LBexp2thGje4IrqMrGIP8 S6Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Fs9nvgVT16rICzDAQ+sVyIP1r+5MXvxD126YhPDBVuQ=; b=a/LMNhXd76NAODu3C+AK3aSSOgvvlbCsHbAt3Fxuft76duCmHZBun420MB0aVeP4Ih xFJwBnASwvOWxKB5dG8WwgbhOQTkVi6wCSGnztEEoTEhzeEMzSjUz4QDEFPFMNZDoIB6 3ipAAuJMLWHqywXtzSyKIrMziUEZxJmG4TsCR4gLTDzS5RTsAe5WBpV5NNwwKd863hgf 4fzeAQLXqoMzA7KZobtzkRu6QNcA6XfLuH94/CW2P3yqcUfMFgNwufdOtX8eEKczI/7/ sFR01KXNz1+LoPyUeHvqiNe10uLXkM4HZHTP5xhLWaNrq8TEwUOQiXFbYRkxMT2xiTGD VSnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jq5pWBJu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z16si7855111edd.314.2019.10.29.01.10.03; Tue, 29 Oct 2019 01:10:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jq5pWBJu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728113AbfJ2IFZ (ORCPT + 99 others); Tue, 29 Oct 2019 04:05:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:51178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726246AbfJ2IFY (ORCPT ); Tue, 29 Oct 2019 04:05:24 -0400 Received: from localhost (unknown [91.217.168.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 22C7920663; Tue, 29 Oct 2019 08:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572336323; bh=PzbAw7ISADxFPEJ9RJkaVCHPc13ZdrvlPsM1FCf0Vrg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Jq5pWBJu1F+2yAGQV7dYZ/v6bc4lLymodWJGH1+K+rEJcwDsdhuaBb/mTDfdmmQ9C NcV1Kt7CayhtdCN12x+FPv9v/RW8OP4JghN97AgOxAM7l0CDImanG3O8nZm2wM9DpM aeluFiM2mK0sCKSZisn+PEzpALwvoXMJKv3P+EUI= Date: Tue, 29 Oct 2019 09:05:21 +0100 From: Greg KH To: Davidlohr Bueso Cc: valdis.kletnieks@vt.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drivers/staging/exfat: Replace binary semaphores for mutexes Message-ID: <20191029080521.GA494993@kroah.com> References: <20191028024519.32344-1-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191028024519.32344-1-dave@stgolabs.net> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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? :(