lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 7 May 2024 18:03:41 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: paulmck@...nel.org
Cc: Kent Gibson <warthog618@...il.com>, Linus Walleij <linus.walleij@...aro.org>, 
	linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, Neil Armstrong <neil.armstrong@...aro.org>
Subject: Re: [PATCH] gpiolib: fix the speed of descriptor label setting with SRCU

On Tue, May 7, 2024 at 6:01 PM Paul E. McKenney <paulmck@...nel.org> wrote:
>
> 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 <paulmck@...nelorg> wrote:
> > >
> > > On Tue, May 07, 2024 at 02:13:46PM +0200, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > > >
> > > > 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 <neil.armstrong@...aro.org>
> > > > 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 <paulmck@...nel.org>
> > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> > >
> > > Looks good to me!
> > >
> > > Acked-by: Paul E. McKenney <paulmck@...nel.org>
> > >
> > > 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

Ok, makes sense, I'll apply this and send a follow-up.

Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ