Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6068892rdb; Thu, 14 Dec 2023 07:35:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGTM3yOSDrEJ/3mclFEysTOLHIqrh/uiGAPOjwbWxwwMlDffH4Wa0osLzPucrPDv4Vi01t X-Received: by 2002:a17:90b:2792:b0:285:8d5c:9114 with SMTP id pw18-20020a17090b279200b002858d5c9114mr6972143pjb.19.1702568100575; Thu, 14 Dec 2023 07:35:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702568100; cv=none; d=google.com; s=arc-20160816; b=PgxgM4GSRcwR0KAqA8DRJEIZskCCeZ57rD/+qVe1xo2h7NLKwIga+v8D1BEc89S8Yq ZONl/nnmvuUxiEiWC7rkSiVNO+h3gOwRAd9BWOCZ/SCeFJZpdBUm5gJ8e48rUIQrMDB6 GqQ91t9Wvhf/u3KIJ6mdhryFeGyaaMOtDEesNSXUaSpqvIkHNia1DsqRQNEx8Lbsw72v pXPIosXOsx0v+9ITx2q4DnfxIqEoYvLKTDPudz/HM/OXB2VCUjfFYTGmeBAYwYMYu/3C LMlv2Z4eseNHVRgKQyu3jGG60i+qjnewgyLzRvNo5YPUIqfVK3j0t0yty4295qt5t8h1 gl4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4wBI1ds+dJ8NsQvuIecgk+p/aVllpdk4KE/JP6rxRYk=; fh=w3yeO0Q+7yApRIBQ5jppSTwFcTlt1VKBrJmqR4dAHYY=; b=ybnIg+B1uOnTVLu+101H9VW1EjIRNE/fv2KKAzMLbMHpfZq0oIQ5Xcohv9xJSwNkXV 5sv3hljGBnKdhZgNbl2lH3m2p1ESVgf7IOk4ADbtYT5QoyoAplX1HJQ+eKA9O+s9rKuZ QJsxW9/XueqANFPpVXd98rldi/9QOnWxHg3IsNgIwz10+qEftsP6VRSfEaNiS5J68vtU uYtVwxc5tzOScn9I5yIqTYQsCla9BRdGxFnrnWtPsBCzFAlMPyXZ1Mj8EMhrjaNg+TKm 2LCRolFxQCDHeSj+JseiN87eS6m9ApgzOW0bKJFfb5hUjLSEWkFJzQqB4iezAxrDiqg7 iEFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RJuFBuJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id a24-20020a17090ad81800b0028acdc91d4esi4009440pjv.73.2023.12.14.07.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 07:35:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RJuFBuJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 37FB5817C3C6; Thu, 14 Dec 2023 07:34:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573801AbjLNPeo (ORCPT + 99 others); Thu, 14 Dec 2023 10:34:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573777AbjLNPen (ORCPT ); Thu, 14 Dec 2023 10:34:43 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D29C198; Thu, 14 Dec 2023 07:34:49 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-28694702c18so8020096a91.3; Thu, 14 Dec 2023 07:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702568089; x=1703172889; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4wBI1ds+dJ8NsQvuIecgk+p/aVllpdk4KE/JP6rxRYk=; b=RJuFBuJFqLNGm2xOQxH3VyipMfTVZ/V4XRlVPkgreFpxYUR0kWLghNNgsXS5CRNGkY Cy5mbI66mR4MzwJOsbpFjQp0Yrq10/jqE0Dy+Z5DRp4scuDWSq4HDUQzm/zK3Pp+pLNi AGcxPQXrJpSRNxVJc5iclIPabRX0U7XpVx9hxphSQ8wAtqrTX7CH7a67cB2LYvbMoSWV ITpCKXzFsSYKAPDmp89EKBX+29jOOMYZCs9ZM0WmQtF/Vt3B7coNDhDhR1xop2or5s6o ji8uDgy3vj2Cdf7yguqIgomE0coJ5roQgxbaccmj9+vHcqII6fUmf3GCUe/Pgz5ZAiK4 O7cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702568089; x=1703172889; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4wBI1ds+dJ8NsQvuIecgk+p/aVllpdk4KE/JP6rxRYk=; b=ubKDSiP3P66QQ+KoiX+FQSYkOfsTWLBMHbfDtUBLTAveuzMKdoztBMG3Z53GmBFa+z veU0JXuHiP2H8JLQDg5ytRIZO2ZVsTwN9jWvxSSTEiJh9h9ZgbFu0v6HvS9UxzgLjUGt Dv1bHuOYTmw0/tBnvALBoT++oPOOvAoT2F0x4gNfNMUutDXKuWK/9q3MXoq3pQJC3HIL 4/hNn4mTxg0lX/0gFgkArpz1mcb+YWO7Xc6EcebzE9mbnF6I4s59pj2LEAqn7Fo1r/6r tykDBKJwWT0Yl2yu1a+MLIfCJBkrWnauzIognA9957/lTE7UsmFfngR/y8GmKZJzK7gi 4JKA== X-Gm-Message-State: AOJu0Yw13vPFxzaFD1TWtITGX83u5ZrC0OL8kkQ7O9Qtqvl1z2SeI9yR 8RAzt/09W1PEiE/4G6Gs5tc= X-Received: by 2002:a17:90b:ec8:b0:28b:c4e:9378 with SMTP id gz8-20020a17090b0ec800b0028b0c4e9378mr664954pjb.46.1702568089269; Thu, 14 Dec 2023 07:34:49 -0800 (PST) Received: from rigel (60-241-235-125.tpgi.com.au. [60.241.235.125]) by smtp.gmail.com with ESMTPSA id nb11-20020a17090b35cb00b0028017a2a8fasm13426949pjb.3.2023.12.14.07.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 07:34:49 -0800 (PST) Date: Thu, 14 Dec 2023 23:34:44 +0800 From: Kent Gibson To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org Subject: Re: [PATCH v2 4/5] gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo() Message-ID: References: <20231214095814.132400-1-warthog618@gmail.com> <20231214095814.132400-5-warthog618@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Dec 2023 07:34:57 -0800 (PST) On Thu, Dec 14, 2023 at 05:27:29PM +0200, Andy Shevchenko wrote: > On Thu, Dec 14, 2023 at 11:19:01PM +0800, Kent Gibson wrote: > > On Thu, Dec 14, 2023 at 05:10:23PM +0200, Andy Shevchenko wrote: > > > On Thu, Dec 14, 2023 at 05:58:13PM +0800, Kent Gibson wrote: > > > > Reduce the time holding the gpio_lock by snapshotting the desc flags, > > > > rather than testing them individually while holding the lock. > > > > > > > > Accept that the calculation of the used field is inherently racy, and > > > > only check the availability of the line from pinctrl if other checks > > > > pass, so avoiding the check for lines that are otherwise in use. > > ... > > > > > - spin_lock_irqsave(&gpio_lock, flags); > > > > > > Shouldn't this be covered by patch 1 (I mean conversion to scoped_guard() > > > instead of spinlock)? > > > > > > > Read the cover letter. > > Doing that made the change larger, as flags gets removed then restored. > > I had also thought the flag tests would get indented then unindented, but > > if we use guard() the indentation should remain unchanged. > > I'm fine with that as I pointed out (have you received that mail? I had > problems with my mail server) the dflags is better semantically, so restoration > with _different_ name is fine. > I have noted that some of your replies have been delayed, and I can't be sure of what I might not've received. I can't say I've seen one that mentions the dflags name being preferable. I prefer the plain flags name, if there is only one flag variable in the function. > > Can do it in 1 if you are happy with the flags declaration being > > removed in patch 1 and restored in 4. > > Definitely. > Ok will re-arrange in v3. Cheers, Kent.