From: ebiederm@xmission.com (Eric W. Biederman)
To: Clemens Ladisch <clemens@ladisch.de>
Cc: markh@compro.net, Mai Daftedar <mai.daftedar@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: Signal from kernel space to user space
Date: Thu, 03 Dec 2009 06:36:58 -0800 [thread overview]
Message-ID: <m17ht4ktth.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <4B165D71.5010408@ladisch.de> (Clemens Ladisch's message of "Wed\, 02 Dec 2009 13\:28\:33 +0100")
Clemens Ladisch <clemens@ladisch.de> writes:
> Mark Hounschell wrote:
>> Clemens Ladisch wrote:
>> > kill_pid_(info) is to be preferred over send_sig_info because it ensures
>> > that the destination process has the same identity (a plain pid number
>> > might have wrappend around and be in use by another process).
>>
>> Does that mean I can't assume my process pid will unique for the life of the process?
>
> The pid _does_ uniquely identify your process. However, after the
> process has died, it could be used for some new process, and
> send_sig_info would happily kill the new process.
send_sig_info isn't that bad as it takes a task struct.
Plain pid_t's are just broken to use.
A pid_t uniquely identifies a process within a pid namespace, not within
all of the pid namespaces present on the kernel.
>> > However, why are you using a signal? What information are you trying to
>> > send, and why wouldn't eventfd or a plain device thaz becomes readable
>> > be a better solution?
>>
>> If no "information" is required, which of these are the fastest, say
>> from an interrupt handler?
>
> If there really is no information, doing nothing would be fastest. ;-)
That or simply waking up the task.
> If you want to tell userland that some event has happened, the various
> mechanisms are not much different as far as the kernel is concerned,
> as long as you don't have many thousands of events per seconds; the
> biggest problems for event delivery are scheduling the userland process
> for execution and handling of the event.
>
> Signals handlers interrupt any other userland code and therefore are
> not allowed to do much; therefore, I would strongly prefer to use
> some file handle that can be waited on with poll(). Furthermore,
> poll() allows to wait for multiple handles, and does not have the
> complexities of signal delivery and blocking. I would use signals only
> if the handler must interrupt any other running code, and if the signal
> can be handled completely without running into reentrancy problems.
Plus signals have all kinds of weird latency and overhead.
Outside of core kernel code, or subsystems where they are already used I
would be surprised if signals could be done correctly and usefully. pid
rollover isn't the only hidden gotcha.
Eric
prev parent reply other threads:[~2009-12-03 14:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-01 11:07 Signal from kernel space to user space Mai Daftedar
2009-12-01 13:30 ` Clemens Ladisch
2009-12-01 15:18 ` Mark Hounschell
2009-12-01 18:05 ` Davide Libenzi
[not found] ` <2cd4ff050912020309j6e7c0ae9n89c011889b09f3e1@mail.gmail.com>
2009-12-02 11:26 ` Mai Daftedar
2009-12-02 12:28 ` Clemens Ladisch
2009-12-03 14:36 ` Eric W. Biederman [this message]
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=m17ht4ktth.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=clemens@ladisch.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mai.daftedar@gmail.com \
--cc=markh@compro.net \
/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