From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Thierry Reding <thierry.reding@gmail.com>
Subject: Re: GPIOLIB locking is broken and how to fix it
Date: Sun, 10 Dec 2023 21:28:08 +0800 [thread overview]
Message-ID: <ZXW86Ad4MOq4IFsn@rigel> (raw)
In-Reply-To: <ZXUjx5UTgC9tvkp9@rigel>
On Sun, Dec 10, 2023 at 10:34:47AM +0800, Kent Gibson wrote:
> > >
> >
> > We still need to connect linereq with its "parent" gpio_chardev_data
> > somehow and make this link weak so that it can survive one or the
> > other being destroyed. Maybe a notifier in linereq to which
> > gpio_chardev_data would subscribe? It would send out notifications on
> > changes to debounce_period which gpio_chardev_data could store. When
> > linereq goes out of scope it sends a corresponding notification
> > allowing gpio_chardev_data to unsubscribe before linereq is freed,
> > while when gpio_chardev_data goes out of scope first, it unsubscribes
> > when being released.
> >
>
> No, there has to be a link between both and the supplemental info.
> For gpio_chardev_data that is to create lineinfo, and for the linereq it
> is to keep the value reported in lineinfo mirroring the current value.
> Below I suggested making the supplemental info a reference counted
> object, with chip scope, referenced by both gpio_chardev_data and the
> linereq. So last one out turns off the lights.
>
> Having the shadow copy allows most usage to avoid the tree lookup and any
> associated locking (assuming the tree isn't inherently thread safe and
> requires a spinlock to prevent modification during a lookup).
> It is only populating the lineinfo or updating the value that would
> require the lookup, and neither are a hot path (if there is such a thing
> in cdev).
>
> Hmmm, the radix_tree allocates a page of entries at a time, which might
> be a bit of overkill per-chip, so maybe a global is the way to go?
> Or something other than a radix_tree, say a rbtree?
>
> All this is getting rather complicated just to relocate one field, so I'm
> starting to reconsider whether the desc was the right place for it after
> all. ¯\_(ツ)_/¯
>
> OTOH, I've partially coded my suggestion, to the point of skeletons for
> the supplemental info, so if you like I'm happy to finish that off and
> provide patches. Though what remains is probably 90% of the work...
>
Bah, just ignore me wrt the supplemental info per chip.
That solution only works for the chip fd used to request the lines.
If you close the chip and re-open it there will be no connection between
the new gpio_chardev_data and the existing line requests or the
supplemental info.
So it would have to be a global indexed by desc as you suggested.
Well that sucks.
Cheers,
Kent.
next prev parent reply other threads:[~2023-12-10 13:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 16:00 GPIOLIB locking is broken and how to fix it Bartosz Golaszewski
2023-11-24 17:27 ` Andy Shevchenko
2023-11-24 17:33 ` Andy Shevchenko
2023-11-24 20:55 ` Bartosz Golaszewski
2023-11-24 23:20 ` Linus Walleij
2023-11-25 1:29 ` Kent Gibson
2023-11-25 20:13 ` Bartosz Golaszewski
2023-11-26 0:05 ` Kent Gibson
2023-11-28 10:47 ` Bartosz Golaszewski
2023-12-07 18:37 ` Bartosz Golaszewski
2023-12-08 1:01 ` Kent Gibson
2023-12-08 8:13 ` Bartosz Golaszewski
2023-12-08 8:38 ` Kent Gibson
2023-12-08 9:52 ` Bartosz Golaszewski
2023-12-08 10:27 ` Kent Gibson
2023-12-08 18:54 ` Bartosz Golaszewski
2023-12-09 1:56 ` Kent Gibson
2023-12-09 19:24 ` Bartosz Golaszewski
2023-12-10 2:34 ` Kent Gibson
2023-12-10 13:28 ` Kent Gibson [this message]
2023-12-11 15:10 ` Bartosz Golaszewski
2023-12-12 0:47 ` Kent Gibson
2023-12-08 13:12 ` Linus Walleij
2023-12-08 13:56 ` Thierry Reding
2023-12-08 14:47 ` Bartosz Golaszewski
2023-12-08 16:40 ` Thierry Reding
2023-12-08 18:30 ` Bartosz Golaszewski
2023-12-11 10:55 ` Thierry Reding
2023-12-11 15:49 ` Bartosz Golaszewski
2023-12-12 10:12 ` Aaro Koskinen
2023-12-12 11:00 ` Bartosz Golaszewski
2023-12-12 14:32 ` Aaro Koskinen
2023-12-12 15:15 ` Bartosz Golaszewski
2023-12-08 13:53 ` Thierry Reding
2023-11-28 11:05 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZXW86Ad4MOq4IFsn@rigel \
--to=warthog618@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=geert@linux-m68k.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.