Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6076120rdb; Thu, 14 Dec 2023 07:47:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvXakV6mb8rNNxUjaxcCaGe7IoNnAdMklXemYFiArMbUQaiIKegZrrpyu3Kl7pxzzEzgBj X-Received: by 2002:a05:6a21:7882:b0:190:9280:7268 with SMTP id bf2-20020a056a21788200b0019092807268mr10938406pzc.57.1702568832751; Thu, 14 Dec 2023 07:47:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702568832; cv=none; d=google.com; s=arc-20160816; b=RJe2v7SpYdYlrGCvUPZ9I/Zo55c+o4hR9/OrX/Wlf7R4sdHex4Y+SMB68JGMANp1y3 AFX9vy1Qsi2anpLGGFscM83VAAbpXDNjydtuzP6rXjv4IZd+G78qwYtgzvwZmHjbnQUR dJcDl6kXLhtPh4NRa/KjQlLvvErx78FZ4AAmjqt+pdZHpGkMcZPl7EdPYzBcqUjYApeK f9ZNInajlLDV0xhq5/wd4i7q6WBgpsXy6MhkFqnBsvrKDDRVWw4EIdz5rFrr5aFNH4sl uK6ftkKe80jBSXBovAjHpicYIQAFJKwzoa3F/EycOkedSOMV3fRN/wPuddVLH53EGA4p hiOA== 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=QTLSA/5Au/MFq4YJd5jR9otFaawbNkkP53RJQOluPHw=; fh=w3yeO0Q+7yApRIBQ5jppSTwFcTlt1VKBrJmqR4dAHYY=; b=PcYgw3VZp9Q6KWR50fspZOmeezJJn3t1vem3JPBXwbddRuf5wDW++OPkrJIfmBCm3p M7fuTg8r6K1Co1RtmRyLXdGul0yHb0Gb7GParaxa/W7pf12PXILB431P34/epZ7gLGCw EdkA8DN02sbUSH1EF9Hxo442CMVeEntu1lXyAsvn2hWKELA2sYwtkWxFVq1/FJBlfen/ fbd0LSaP5aJTt/BLjH45NaZ3Kn0dKYRtbJKAYEP1Yn8rKFsEFpdakaeL30fuiu/VVpuY ATDXqXjd2fw+EEqcAmA5dKCrMtTUxKY9uRQD+zQHsf9aV72q5CnpzkSuR3Xa6dVOk/L/ QnDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Jl9Uri0H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t7-20020a63dd07000000b005c70983efd5si9055660pgg.629.2023.12.14.07.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 07:47:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Jl9Uri0H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 1418E807413A; Thu, 14 Dec 2023 07:47:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573871AbjLNPq5 (ORCPT + 99 others); Thu, 14 Dec 2023 10:46:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573886AbjLNPqz (ORCPT ); Thu, 14 Dec 2023 10:46:55 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2386115; Thu, 14 Dec 2023 07:46:59 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d0b2752dc6so74222935ad.3; Thu, 14 Dec 2023 07:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702568819; x=1703173619; 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=QTLSA/5Au/MFq4YJd5jR9otFaawbNkkP53RJQOluPHw=; b=Jl9Uri0HSnmy/7g0P9SS9HXK3oTraVXZMXk+ZtPvBA9o4WO19IsIC3wqSHNIK32fu7 srf1sjfXGkRSQSyu5aVaf803r3iq/Rpfpbhip33dGDPUDtE9/bFhK6H5O9L/xCYip/HS qxtRuIOXYGxmQGbudXmP5KcNT4dumoX+g4XFnoUbobWiIne4VcGBBOU8v4P8h8iZEOEW L3DBvcsk1LPXNxK5udc3OaQjji9o7eJke/OKyeYRjIfENd6oyJ3L6CZIIkZtvO/mN3B3 JO/dQE7uPHNx1lHBHBRfakC5mx5WgPR+fi8MuuY+FecyFfbrWA5Fp00We5sbsz9Nqaxr ku8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702568819; x=1703173619; 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=QTLSA/5Au/MFq4YJd5jR9otFaawbNkkP53RJQOluPHw=; b=IeOi32xEwNgQDY9xsOPNsMhaqH5905MZKr8eOQfxTbNOsi6M2fh2kYjdMXH8kIVjMz NMc/BSuVktwgYp0HYSr1pQdX21fSnnWGqmqw9Dk2rbO3pyWL2eQpX7VTE03arKbVxNjL w6+NS/yF3YbclOetjj+P5pYLmJrTgFLRZLjYdFvshEGoXMZHUw1P/ph0T9Bt4HwbJcuE lny+p2G/4Y+0PSZOrQEXPNAAyAAM0tVieE/CdKgr3Q9FGSmQiXjqCWVyf2sGSvYk91aA VbUa4cb3sAN3JWCOxeFvbxam/U+d9YoIs21s4Px+VHM09nDjHKDk14eXQ9ZEBRwBZDEB o9Nw== X-Gm-Message-State: AOJu0YyLPJ4A5F6wAxwGnqQi6olM5ClpCFaULUCIUMAJ6OqzAVLv2+xw 5eOOVS6k9woivKSrFL2nTKM= X-Received: by 2002:a17:903:2b0e:b0:1d3:6b17:5eb with SMTP id mc14-20020a1709032b0e00b001d36b1705ebmr1378286plb.49.1702568819340; Thu, 14 Dec 2023 07:46:59 -0800 (PST) Received: from rigel (60-241-235-125.tpgi.com.au. [60.241.235.125]) by smtp.gmail.com with ESMTPSA id r2-20020a1709028bc200b001bc6e6069a6sm1475008plo.122.2023.12.14.07.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 07:46:59 -0800 (PST) Date: Thu, 14 Dec 2023 23:46:54 +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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 14 Dec 2023 07:47:10 -0800 (PST) On Thu, Dec 14, 2023 at 11:34:44PM +0800, Kent Gibson wrote: > 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. > Hang on - patch 4 has to use a scoped_guard(), so are you ok for patch 1 to introduce a guard(), to avoid changing the indentation, only to replace it with a scoped_guard(), to perform the tests after releasing the lock, in patch 4? Cheers, Kent.