From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751863AbdJZHHu (ORCPT ); Thu, 26 Oct 2017 03:07:50 -0400 Received: from bmailout2.hostsharing.net ([83.223.90.240]:39815 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750997AbdJZHHr (ORCPT ); Thu, 26 Oct 2017 03:07:47 -0400 X-Greylist: delayed 557 seconds by postgrey-1.27 at vger.kernel.org; Thu, 26 Oct 2017 03:07:47 EDT Date: Thu, 26 Oct 2017 08:58:28 +0200 From: Lukas Wunner To: =?us-ascii?B?PT9VVEYtOD9xP1JvbmFsZD0yMFRzY2hhbD1DMz1BNHI/PQ==?= Cc: Marcel Holtmann , Gustavo Padovan , Johan Hedberg , Dean Jenkins , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] Bluetooth: hci_ldisc: Allow sleeping while proto locks are held. Message-ID: <20171026065828.GB6487@wunner.de> References: <20171026051453.GA15910@innovation.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171026051453.GA15910@innovation.ch> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 25, 2017 at 10:14:53PM -0700, =?UTF-8?q?Ronald=20Tschal=C3=A4r?= wrote: > Commit dec2c92880cc5435381d50e3045ef018a762a917 ("Bluetooth: hci_ldisc: > Use rwlocking to avoid closing proto races") introduced locks in > hci_ldisc that are held while calling the proto functions. These locks > are rwlock's, and hence do not allow sleeping while they are held. > However, the proto functions that hci_bcm registers use mutexes and > hence need to be able to sleep. [...] > We can't replace the mutex in hci_bcm, because there are other calls > there that might sleep. Therefore this replaces the rwlock's in > hci_ldisc with rw_semaphore's (which allow sleeping). This is a safer > approach anyway as it reduces the restrictions on the proto callbacks. > Also, because acquiring write-lock is very rare compared to acquiring > the read-lock, the percpu variant of rw_semaphore is used. The percpu_rw_semaphore is unusual (if fine I guess), it's only used by cgroups, uprobes and ext4 so far and I was unaware of its existence. I don't have the hardware to test this but the rationale and patch itself LGTM, so: Reviewed-by: Lukas Wunner