From: Kent Gibson <warthog618@gmail.com>
To: brgl@bgdev.pl
Cc: linux-gpio@vger.kernel.org
Subject: Re: [BUG] gpiolib: cdev: can't read RELEASED event for last line
Date: Fri, 26 May 2023 08:45:38 +0800 [thread overview]
Message-ID: <ZHABMhDmcLY78EB+@sol> (raw)
In-Reply-To: <ZG9g1N1Jbm0aB4ST@sol>
On Thu, May 25, 2023 at 09:21:24PM +0800, Kent Gibson wrote:
> On Thu, May 25, 2023 at 03:46:12PM +0800, Kent Gibson wrote:
> > On Thu, May 25, 2023 at 03:09:26PM +0800, Kent Gibson wrote:
> > > On Thu, May 25, 2023 at 11:09:52AM +0800, Kent Gibson wrote:
> > > > Hi Bart,
> > > >
> > > I can also confirm that receiving the event using a blocking read() on the
> > > fd still works, it is a poll() on the fd followed by a read() that fails.
> > >
> >
> > Hmmm, so it occurred to me that gpionotify does the poll()/read(), so it
> > should exhibit the bug. But no, it doesn't.
> >
> > So it could be my code doing something boneheaded??
> > Or there is some other variable at play.
> > I'll try to write a test for it with libgpiod and see I can reproduce
> > it. But I might put it on the back burner - this one isn't terribly
> > high priority.
> >
>
> Bisect result:
>
> [bdbbae241a04f387ba910b8609f95fad5f1470c7] gpiolib: protect the GPIO device against being dropped while in use by user-space
>
> So, the semaphores patch.
> The Rust test gets the timings right to hit a race/order of events issue?
>
Well that throws some new light on the problem.
One of the differentiators of the Rust test from the other ways I was
trying to reproduce the problem is that the Rust test is multithreaded.
This being semaphore related makes other weirdness I was seeing make
sense.
The original form of that test was locking up when the bg thread
released the line. The drop never returned and the fg thread never
received a RELEASED event. That wasn't a problem with the drop, or an
event being lost, as I assumed, that was a DEADLOCK.
The current form of the test uses message passing to coordinate the
threads, so that deadlock condition doesn't occur any more.
(That change was because of my concern that the lack of buffering of info
changed events in the kernel could result in lost events - and the goal of
the test was to test my iterator, not the kernel...)
I'll revert that test case to see if I can reproduce the deadlock case.
But it looks like those semaphores have problems. At least one path
might lead to deadlock and another leads to an inconsistent state.
Cheers,
Kent.
next prev parent reply other threads:[~2023-05-26 0:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 3:09 [BUG] gpiolib: cdev: can't read RELEASED event for last line Kent Gibson
2023-05-25 7:09 ` Kent Gibson
2023-05-25 7:46 ` Kent Gibson
2023-05-25 13:21 ` Kent Gibson
2023-05-26 0:45 ` Kent Gibson [this message]
2023-05-26 6:51 ` Kent Gibson
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=ZHABMhDmcLY78EB+@sol \
--to=warthog618@gmail.com \
--cc=brgl@bgdev.pl \
--cc=linux-gpio@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox