From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBCF5CA0FE0 for ; Thu, 31 Aug 2023 22:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236702AbjHaWll (ORCPT ); Thu, 31 Aug 2023 18:41:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232660AbjHaWlj (ORCPT ); Thu, 31 Aug 2023 18:41:39 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BA78C0 for ; Thu, 31 Aug 2023 15:41:36 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4RcGNt3PWDz5s; Fri, 1 Sep 2023 00:41:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693521694; bh=f49rXeOsX2+k9JH8576CfFzxX9BrcwLU5e1ZJ9FXWtI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d8FHZZkfnpd890D4wjfVSBQyn4Q+ADxpoHIb0MCXAEDSP2tezkNB/UrX2U+/ggh/T IlFQ9ehxtjuPIZA3cTjFMFSrntf9VhcQz7W2KyKnFKHTPxqRXfUfjFdnrceH8Ld+fj ToZz8o5QOCXag3SVwS+v8L9m/o1Cd/euSXcdBSFeMGijl2jWVy3Yw9v6n5LWgMp6zD wCXp91gfU442Ns9kRcO7jdQ4ZrDZR6u2ybFvOycGprMUNI51mvs0qtV9mUFjNBOVuM U3K1pnONHprcFFjLfFZMkIUKSYJuvUtHxgIvFNgpnEU+HQR98ZcAPWudG4npO2T4Q/ gu93s0QjQu1Og== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Fri, 1 Sep 2023 00:41:32 +0200 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Doug Anderson Cc: Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, Stephen Boyd Subject: Re: [PATCH v2 3/7] regulator/core: regulator_lock_nested: simplify nested locking Message-ID: References: <56ae0bf828d942c92ca867afb3aae95fcabd5498.1693416477.git.mirq-linux@rere.qmqm.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 30, 2023 at 01:54:21PM -0700, Doug Anderson wrote: > On Wed, Aug 30, 2023 at 10:35 AM Michał Mirosław > wrote: > > > > Simplify regulator locking by removing locking around locking. > > rdev->ref check when unlocking is moved inside the critical section. > > > > This patch depends on commit 12235da8c80a ("kernel/locking: Add context > > to ww_mutex_trylock()"). > > > > Note: return -EALREADY is removed as no caller depends on it and in that > > case the lock count is incremented anyway. > > > > Reviewed-by: Douglas Anderson > > Signed-off-by: Michał Mirosław > > --- > > drivers/regulator/core.c | 23 ++++++----------------- > > 1 file changed, 6 insertions(+), 17 deletions(-) > > Note that I didn't actually provide a Reviewed-by on this patch in v1. > I was hoping for something in the commit message that explained why > commit 12235da8c80a ("kernel/locking: Add context to > ww_mutex_trylock()") meant that we didn't need the extra lock. You > responded to the v1, but didn't add anything to the commit message > about it. > > Looking at your response to v1, I'm not sure it helps enlighten me on > why adding the context removed the need for the extra lock. Can you > add more words? Pretend I don't know anything about ww_mutex, which is > not far from the truth since every time I look at ww_mutex I have to > re-learn how it works. :-P Specifically, what would actually have been Thanks for all your (and Stephen's) questions and comments! I had a bit more of thinking and reading time about the W/W mutex and how it works. It turns out I can remove some noise from this commit. The commit 12235da8c80a dependency is due to text changes: the original code would need a bit of reordering, all not much different than the two previous patches. If ww_mutex_lock() was able to return -EALREADY with NULL ww_ctx, regulator_lock_nested() could be made even simpler. Best Regards, Michał Mirosław