Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6058317rdb; Thu, 14 Dec 2023 07:19:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIo/JeQK9J6hFROUNfL4AI+4aG463xmfnUEvfX+e0BojTGjkRWjZBStltMvxnK+ich7PXq X-Received: by 2002:a05:6358:728e:b0:170:3ef2:de12 with SMTP id w14-20020a056358728e00b001703ef2de12mr7966980rwf.46.1702567168039; Thu, 14 Dec 2023 07:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702567168; cv=none; d=google.com; s=arc-20160816; b=JJol0MjnRJk307w1TKhjJCxq5wymoBYwzM90mDpxjy9U7AsOyq05QOii5oSFg1OvVA vqc5oP+iVJs5EqPVU7aaOxQRI+kos0e+lq9MzFuhYFbFCF54X+9qdDz6yGJ+ukDII0ib G3sC6MrEJ2J2k6NzyhwPYFp492wYSdxI9VnmQP36+kfjaOyyAx7vQA7xtQAyI5s4ifj5 HOOoBnVr9VnyOUlF/THHdeC1BJ5m2BEbGjPukU8/wxDxs1BWBS+rb1vUXKS8LJPeQrCx i1HKEdjGxlMEAyBAsyQi2ZXwd2PdaYTb5JGjpdyQlOG5sRFH33olepGyktxGRpuQoRog x7Ww== 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=aC0Vwy99mfVjbtuk8/GEuj53wgtxvnchwsBrLMjXyKY=; fh=w3yeO0Q+7yApRIBQ5jppSTwFcTlt1VKBrJmqR4dAHYY=; b=0p86Vybu5CTasFUiIjSHIbN2mtPwOF1p8cB27AqyRiA0CEEDAKyQ8TaxXak6HvQlB7 rfD5m99Yc+EEGOC2OGMZD7n4DWJE6XD3XDL+7P1D8cHSKEoWkxrvf8q4Nu68ORYBP4ol lMVRqirD4QxuN6tWkgAWM5gTFW0LAlXGSPPqxEuGd26PCmF25u/l8USUNZkMGkjs5EIX O2e99DZwhG8wzK2r7HarbcgsDR+zlIzT1jW0Y4KFo2hkJ0owrqp+vB2TWdUtBLSq/2vY RgYfM9MTgFVpZ+xqWSVN9j1ftrtC3GjphmW5x/rJuhAS/GaGsSGc0oWJPbTjKU7AktVE sc4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cf9E8AhX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bx2-20020a056a02050200b005a9fde46fa0si11603652pgb.130.2023.12.14.07.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 07:19:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cf9E8AhX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 96D55829AA3C; Thu, 14 Dec 2023 07:19:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573678AbjLNPTC (ORCPT + 99 others); Thu, 14 Dec 2023 10:19:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbjLNPTA (ORCPT ); Thu, 14 Dec 2023 10:19:00 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB09121; Thu, 14 Dec 2023 07:19:07 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6ce94f62806so4727308b3a.1; Thu, 14 Dec 2023 07:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702567147; x=1703171947; 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=aC0Vwy99mfVjbtuk8/GEuj53wgtxvnchwsBrLMjXyKY=; b=cf9E8AhX0zA0azW9BBxszMMFQJGctV/Nqrp065u/TvimU/93s9+yi9aW3L2HVq4yDV mDct23K57xBKChp88GsNRWu5Or4gpYV8ilFKokkVv/sTCcA46ll+sSZ80yXzJbdwLi3i iX0K2YE3MaP7iyo1JChvMNlFsV97q6RKnt2TV2yxgghxmMmKc0QBOALsoLhE/8nu+2gF GLVW0nUfQ2aJMpJ1P5oRrDFmV+fQA+Zx1zPCVCIWCqdTP8dKJdea71iI/t0R7J3Zxkqo TxQMn2ZE46FNLEbnXNw5dWYQcDl4YWPNL2+oCO1DzvHeetGyNsvrAs0VEjz1qLkBGekS QwNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702567147; x=1703171947; 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=aC0Vwy99mfVjbtuk8/GEuj53wgtxvnchwsBrLMjXyKY=; b=oP5ugUQ6Q6GRbgs00/a7OBdLi1c+X+zKmNtFwcI3beonDWbjmRi85Wl0iQ1aoYTXSK hcoOM4ijqYYUFL8ByFgOZf0kbHmONTU6BqPyOiqGyLCScZZEp9PuyAEdUYmOxJOou0KG HUlNkJmybAuXqmy0mGsrpLThOfa4/c7SDBkYB8cA3t4hCL2vl62Nhr3xdxBwbfWr/WoD /C9w7hjB2y0wv+Y9uzLqy/wSpWvo3j41Dh0d8vHIOROs5SpFgG/FXPsIYXIDy4KLjYCj GptP8y+fJTXEr59qF/oeYEwBlH5SnwOC+IZFezVLCrCl2ULYTXI9xi3Qo5TAuNl2vzCe ezAA== X-Gm-Message-State: AOJu0YwyanPCT/BihyTY54DfFKYAVyGavrzUY8PQrfYQzmEQKTfhDKeT 2n2O8Q5Fk4drCM0uY1x/D98KSkgdLes= X-Received: by 2002:a05:6a00:1487:b0:6ce:3584:b634 with SMTP id v7-20020a056a00148700b006ce3584b634mr6366823pfu.48.1702567146683; Thu, 14 Dec 2023 07:19:06 -0800 (PST) Received: from rigel (60-241-235-125.tpgi.com.au. [60.241.235.125]) by smtp.gmail.com with ESMTPSA id u10-20020a62d44a000000b006cde1cef719sm12288678pfl.152.2023.12.14.07.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 07:19:06 -0800 (PST) Date: Thu, 14 Dec 2023 23:19:01 +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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 14 Dec 2023 07:19:16 -0800 (PST) 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. Can do it in 1 if you are happy with the flags declaration being removed in patch 1 and restored in 4. Cheers, Kent.