Received: by 2002:ab2:7104:0:b0:1f7:f6c3:9cb1 with SMTP id z4csp41634lql; Tue, 7 May 2024 09:15:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5SF/zMovGQUlpQZNnE5sSkmkMD++GbkrKI9BgDdpqu/LJrUvyfMlBwuziwk6y4Ys6KM3UeuvJCvVP78FI06c5WuRwNr+09zAWSoUijg== X-Google-Smtp-Source: AGHT+IEcDOVY69CrauAhU007e2KFYIosopIv9DbXXum+qEJjxyqYZJWbO4+p4BcTXWbHcXRaHGMo X-Received: by 2002:a17:902:d512:b0:1e4:8eb3:26f5 with SMTP id d9443c01a7336-1eeb03a1ea0mr1226625ad.38.1715098501680; Tue, 07 May 2024 09:15:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715098501; cv=pass; d=google.com; s=arc-20160816; b=VEOhdTx+3htpKgBh4HKLW4rYKYWbzIR4B4Vb2EB2CfNHlrCPRDk4V8Pn5L5PkumZSQ s4N0+dFokv95oJuEx+9VRrGZj6YSuhgk+OGwGuvCmU1ZQ5+rvmk3CV+5tE/F8VKMcvZm 35evjzbYAugr5AwiOgLPIJL2mcWWYhu1hapS9Vs7kQJZ2kHhCtF8bfmol8d4iBsfsdgy MrERHQW/UPddy7EqQ8lWrLeXS2xLSuy0ZE7W2gO2hrBfsy31UGd6L0FF7A5yX5dfcYll jRQk+lWjZpw7eIMRZEjIYw6acWa+BMjzokI6cYJq2O+Pg97thGhKQ5ahNn5qKfRT2kD/ aHYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/BdMPb0BQtqj8RB+dUrDfKTzE/1RLp4QxkHJnkD0Vsc=; fh=o00fS5S/Am0TyW6Ypo1eda2iER1XBFYx8yYi8PnMwqY=; b=ImD3YDU/JbuTC00qlvJ4xkOpqmw5usty0AsDrAr8AqL+jUlC5Kb9/os++ljG50k0pn 5N36MCFakj9W3uLdbUCczlQaXrRfIZEXYOn4JQvyU8moDykhYr+zRuD7Nw0iYfU7hkwi rCKMFXaLZVNnIxh5pg7XWYYo8gZaty40ZeSy3roso5MDGymzzUc135+kbHkABliMauSq mlBPcV6Wt24NpQir4RYLlJ1wRyj9JdJPklCzqNLmA7STPBHr/Olln3IE1KFoVW0roetd Xgsc1JxKirY29/o5Yaj3vHRGc7uHfB8CM+gyZegql29/DQAkIABT87T1ZoHlHZ0O2hDc 45BQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SpwgShI5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-171762-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p9-20020a1709027ec900b001e41c66599fsi10007224plb.478.2024.05.07.09.15.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 09:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171762-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SpwgShI5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-171762-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DC03028CC85 for ; Tue, 7 May 2024 16:06:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 320D516D303; Tue, 7 May 2024 16:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SpwgShI5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55FE516C6A0; Tue, 7 May 2024 16:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715097718; cv=none; b=U4FFjgYGZO/iKStcb+Al6PYS25cYl9GlTL9P81GMnRSxcLtEwykrmDUcbYZAC8eZV/sWrUyUyanzbQBosHe3GQgs0Kovo3Z2KZf5abzinf9E2rzK5bvF+1oUUW6IQmh5ttsclq2Fz29X5o2jg8DLWl7lzy7iD+r7vGPWAif+B4o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715097718; c=relaxed/simple; bh=VZJ8+RLe61gK9PUlD/myRLomOS9W7a54C8toInBF7gE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rDPsN3bn7F/NwAq6Cs3+qWQgfpaWca7qhQ1K8ueIfj1D3B4k2iAf6DSr2LJh27wiAwysGyl95lUNgtAXHN3CHqYVUJYkWGkRHW1gTYu2dljQ3lCBRZC7U9ZHw19IWSVeUY75Eb8VZk/ZnZz6X2qzjKIk0pvYk1BpoIhcE3tJtc4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SpwgShI5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBED5C2BBFC; Tue, 7 May 2024 16:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715097717; bh=VZJ8+RLe61gK9PUlD/myRLomOS9W7a54C8toInBF7gE=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=SpwgShI5wIUMTdUWl1AeFmLRRDMtdEx/ZrTwMcKYxc9Qf5PMou/bpLvF2mHuXtYsh afCaX30hHxu15qEi2zpYsZX8K4knnxrSaMaU/dJjEnHU5aM2AlfKoLJtEJTnPUyPPk Q9bWlJuTMbPzN2ljhYFoVjyCeSJqn+cYuoiOFFGHwZxBQLtUdY1NicXRZ13uUFKgCs 0vLEuwJ+XnjC0wwho324ZcrX/8TuCng5HZHv6vypkOQvg9UPE+KsLQPJgHY0ES+syw D6NqFfQoNjQ0wbTZM6zvuxdVST6Du/tMSl405yFVrj67Swyj885sRcp3iilJoGGF6j zE5RSniEqZUGA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 86E8BCE14CC; Tue, 7 May 2024 09:01:57 -0700 (PDT) Date: Tue, 7 May 2024 09:01:57 -0700 From: "Paul E. McKenney" To: Bartosz Golaszewski Cc: Kent Gibson , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , Neil Armstrong Subject: Re: [PATCH] gpiolib: fix the speed of descriptor label setting with SRCU Message-ID: <1e9042a9-f8ba-4ca9-a5e3-5eed1a02e1ca@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240507121346.16969-1-brgl@bgdev.pl> <597f5da2-71be-4144-a570-fdc4f06c4cc6@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, May 07, 2024 at 04:48:04PM +0200, Bartosz Golaszewski wrote: > On Tue, May 7, 2024 at 4:24 PM Paul E. McKenney wrote: > > > > On Tue, May 07, 2024 at 02:13:46PM +0200, Bartosz Golaszewski wrote: > > > From: Bartosz Golaszewski > > > > > > Commit 1f2bcb8c8ccd ("gpio: protect the descriptor label with SRCU") > > > caused a massive drop in performance of requesting GPIO lines due to the > > > call to synchronize_srcu() on each label change. Rework the code to not > > > wait until all read-only users are done with reading the label but > > > instead atomically replace the label pointer and schedule its release > > > after all read-only critical sections are done. > > > > > > To that end wrap the descriptor label in a struct that also contains the > > > rcu_head struct required for deferring tasks using call_srcu() and stop > > > using kstrdup_const() as we're required to allocate memory anyway. Just > > > allocate enough for the label string and rcu_head in one go. > > > > > > Reported-by: Neil Armstrong > > > Closes: https://lore.kernel.org/linux-gpio/CAMRc=Mfig2oooDQYTqo23W3PXSdzhVO4p=G4+P8y1ppBOrkrJQ@mail.gmail.com/ > > > Fixes: 1f2bcb8c8ccd ("gpio: protect the descriptor label with SRCU") > > > Suggested-by: Paul E. McKenney > > > Signed-off-by: Bartosz Golaszewski > > > > Looks good to me! > > > > Acked-by: Paul E. McKenney > > > > One semi-related question... Why the per-descriptor srcu_struct? > > > > If the srcu_struct was shared among all of these, you could just do one > > synchronize_srcu() and one cleanup_srcu_struct() instead of needing to > > do one per gdev->desc[] entry. > > > > You might be able to go further and have one srcu_struct for all the > > gpio devices. > > > > Or did you guys run tests and find some performance problem with sharing > > srcu_struct structures? (I wouldn't expect one, but sometimes the > > hardware has a better imagination than I do.) > > > > I guess my goal was not to make synchronize_srcu() for descriptor X > wait for read-only operations on descriptor Y. But with that gone, I > suppose you're right, we can improve this patch further by switching > to a single SRCU descriptor. > > I'll send a v2. My guess is that a separate patch for each of the two changes would be best, but I must defer to you guys on that. Thanx, Paul