From: Darren Hart <dvhltc@us.ibm.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "lkml, " <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
Eric Dumazet <eric.dumazet@gmail.com>,
Dinakar Guniguntala <dino@in.ibm.com>,
"Stultz, John" <johnstul@us.ibm.com>
Subject: Re: [PATCH] RFC: futex: make futex_lock_pi interruptible
Date: Fri, 30 Oct 2009 09:23:12 -0700 [thread overview]
Message-ID: <4AEB12F0.9090006@us.ibm.com> (raw)
In-Reply-To: <200910301013.46923.arnd@arndb.de>
Arnd Bergmann wrote:
> On Friday 30 October 2009, Darren Hart wrote:
>> Darren Hart wrote:
>> This appears to work fine. Can anyone think of a reason why this is an unsafe
>> thing to do? I'll have to create a much more elaborate test case and review
>> the glibc code of course to make sure the glibc mutex state isn't compromised.
>
> The only reason I can see against it is the need to use one of the
> rt signal numbers from library code, which may conflict with other
> users of the signal. Being able to avoid a signal altogether would
> be really nice, as in the futex_cancel extension you mentioned.
For the reason you mention, consumption of a signal number, the
futex_cancel extension was how I originally set out to tackle this.
However, Thomas and Peter both seemed to feel that the signal approach
was a more standard way of interrupting a unix system call. One trick to
the futex_cancel approach will be identifying which thread to cancel -
since no other futex operation is thread specific. I suspect just
overloading one of the argument to pass a TID would address that nicely.
This would allow us to return ECANCELED from the kernel, which I think
is a much more direct implementation.
Peter and Thomas, could you comment on why the signal approach might be
preferred over the futex_cancel extension?
>> /* Need some kind of per-thread variable here */
>> jmp_buf env;
>> pthread_mutex_t mutex;
>
> Maybe instead of per-thread variables (which should work
> fine), you could do
>
> typedef struct {
> jmp_buf env;
> pthread_mutex_t mutex;
> } interruptible_mutex_t;
I don't quite follow. There will be a 1:many relationship between
mutex:threads, but there should be a 1:1 relationship between
threads:env. Since multiple threads can block on one mutex, the above
struct wouldn't provide the necessary number of env to set the jmp point
for each one.... am I misunderstanding your suggestion?
>> /* ensure the child has blocked on the lock */
>> sleep(1);
>
> In a real application, you might want to add some logic to avoid
> this kind of race. For the test case, you probably need to do it
> with the sleep.
This would likely need to be handled within glibc, just as it manages
the sequence counters for the condvars to deal with wake-up races.
--
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team
next prev parent reply other threads:[~2009-10-30 16:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-27 0:26 [PATCH] RFC: futex: make futex_lock_pi interruptible Darren Hart
2009-10-27 0:32 ` Darren Hart
2009-10-29 8:39 ` Arnd Bergmann
2009-10-30 1:19 ` Darren Hart
2009-10-30 1:45 ` Darren Hart
2009-10-30 9:13 ` Arnd Bergmann
2009-10-30 16:23 ` Darren Hart [this message]
2009-10-30 17:39 ` Arnd Bergmann
2009-10-30 17:55 ` Chris Friesen
2009-10-31 0:31 ` Darren Hart
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=4AEB12F0.9090006@us.ibm.com \
--to=dvhltc@us.ibm.com \
--cc=arnd@arndb.de \
--cc=dino@in.ibm.com \
--cc=eric.dumazet@gmail.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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