From: Michael Kerrisk <mtk-manpages@gmx.net>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: "Ulrich Drepper" <drepper@redhat.com>,
geoff@gclare.org.uk, lkml <linux-kernel@vger.kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Christoph Hellwig" <hch@lst.de>,
"Jonathan Corbet" <corbet@lwn.net>,
"Randy Dunlap" <rdunlap@xenotime.net>,
vda.linux@googlemail.com,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Lee Schermerhorn" <Lee.Schermerhorn@hp.com>,
"David Härdeman" <david@hardeman.nu>
Subject: Re: RFC: A revised timerfd API
Date: Sat, 22 Sep 2007 15:12:41 +0200 [thread overview]
Message-ID: <46F514C9.5010208@gmx.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0709180936480.22956@alien.or.mcafeemobile.com>
Davide, Andrew, Linus, et al.
At the start of this thread
(http://thread.gmane.org/gmane.linux.kernel/581115 ), I proposed 4
alternatives to Davide's original timerfd API. Based on the feedback in
that thread (and one or two earlier comments):
Let's dismiss option (a), since it is an unlovely multiplexing interface.
Option (b) seems a viable. The most notable concern was from Thomas
Gleixner, that we might end up duplicating code from the POSIX timers API
within the timerfd API -- some eventual refactoring might mitigate this
problem.
Option (c) seems overly complex. In addition, David Härdeman pointed out
that option (c) (and, I realised afterwards, option (d)) require the
userland programmer to maintain a mapping between timerfd file descriptors
and POSIX timer IDs. Thomas Gleixner proposed an API that: attempts to
avoid that problem; mixes features of options (c) and (d); and probably
helps avoid redundancy of kernel code between the timerfd system and the
POSIX timers system. I'll flesh out that API now as I understand it:
====> e) Integrate timerfd() with the POSIX timers API in such a way that
the POSIX timers API understands timerfd file descriptors.
Under the POSIX timers API, a new timer is created using:
int timer_create(clockid_t clockid, struct sigevent *evp,
timer_t *timerid);
When making this call, we would specify evp.sigev_notify to a new flag
value SIGEV_TIMERFD, to inform the system that this timer will deliver
notification via a timerfd file descriptor.
We would then have a timerfd() call that returns a file descriptor
for the newly created 'timerid':
fd = timerfd(timer_t timerid);
(A variant here would be to have timer_create() directly return a file
descriptor when SIGEV_TIMERFD is specified, although this breaks the
traditional semantics that timer_create() only returns 0 on success.)
We could then use the POSIX timers API to operate on the timer
(start it / modify it / fetch timer value):
int timer_settime(timer_t timerid, int flags,
const struct itimerspec *value,
struct itimerspec *ovalue);
int timer_gettime(timer_t timerid, struct itimerspec *value);
The difference here is that 'timerid' could be either:
1) the timerid value returned from timer_create(); or
2) the value (fd | POSIX_TIMER_FD), where POSIX_TIMER_FD is a
flag (perhaps the topmost bit set on) that indicates that
the rest of the value is a file descriptor. With this
information, the kernel can do a lookup to find the
corresponding timerfd and perform the required operation
on it.
Advantages:
1. Userland programs don't need to maintain a mapping between
timer IDs and file descriptors.
2. Adds just a single system call.
Disadvantages:
1. This design stretches the POSIX timers API in strange
ways. My option (d) also did this to a lesser extent,
and that felt slightly uncomfortable. Option (e)
makes more uncomfortable still. As David Härdeman
pointed out, overloading file descriptors with flags looks
ugly, and I can't thing of any other syscall that does
that. In addition this idea probably breaks POSIX, since
'timer_t' is only required to be an arithmetic type: it
need not specifically be an integer type (although it is
on Linux).
=====
The upshot is that of the 5 alternatives, I favor option (b). David
Härdeman also expressed a preference for option (b) and it was Davide's
least disliked alternative ;-).
So I'm inclined to implement option (b), unless someone has strong
objections. Davide, could I persuade you to help?
Cheers,
Michael
--
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7
Want to help with man page maintenance? Grab the latest tarball at
http://www.kernel.org/pub/linux/docs/manpages/
read the HOWTOHELP file and grep the source files for 'FIXME'.
next prev parent reply other threads:[~2007-09-22 13:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-18 7:27 RFC: A revised timerfd API Michael Kerrisk
2007-09-18 7:30 ` Michael Kerrisk
2007-09-18 8:05 ` David Härdeman
2007-09-18 9:01 ` Michael Kerrisk
2007-09-18 9:27 ` Thomas Gleixner
2007-09-18 9:10 ` Thomas Gleixner
2007-09-18 9:30 ` Michael Kerrisk
2007-09-18 9:42 ` Thomas Gleixner
2007-09-18 11:08 ` Michael Kerrisk
2007-09-18 11:30 ` Thomas Gleixner
2007-09-18 13:13 ` David Härdeman
2007-09-22 13:03 ` Michael Kerrisk
2007-09-18 16:51 ` Davide Libenzi
2007-09-22 13:12 ` Michael Kerrisk [this message]
2007-09-22 14:32 ` Bernd Eckenfels
2007-09-22 16:07 ` Michael Kerrisk
2007-09-22 17:05 ` Thomas Gleixner
2007-09-22 23:37 ` David Härdeman
2007-09-22 17:10 ` Thomas Gleixner
2007-09-22 21:07 ` Davide Libenzi
2007-09-22 21:26 ` Thomas Gleixner
2007-09-22 23:21 ` Davide Libenzi
2007-09-23 17:33 ` Michael Kerrisk
2007-09-23 18:33 ` Davide Libenzi
2007-09-23 18:41 ` Davide Libenzi
2007-09-23 19:03 ` Michael Kerrisk
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=46F514C9.5010208@gmx.net \
--to=mtk-manpages@gmx.net \
--cc=Lee.Schermerhorn@hp.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=david@hardeman.nu \
--cc=davidel@xmailserver.org \
--cc=drepper@redhat.com \
--cc=geoff@gclare.org.uk \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@xenotime.net \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vda.linux@googlemail.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.