login
Header Space

 
 

Re: [patch 1/3] new timerfd API - new timerfd API

Previous thread: Xen kernel 2.6.23-rc7 bug at xen_mc_flush (arch/i386/xen/multicalls.c:68) by osth on Sunday, September 23, 2007 - 5:55 pm. (5 messages)

Next thread: [patch 2/3] new timerfd API - wire the new timerfd API to the x86 family by Davide Libenzi on Sunday, September 23, 2007 - 6:49 pm. (5 messages)
To: Linux Kernel Mailing List <linux-kernel@...>
Cc: Michael Kerrisk <mtk-manpages@...>, Thomas Gleixner <tglx@...>, Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>
Date: Sunday, September 23, 2007 - 6:49 pm

This is the new timerfd API as it is implemented by the following patch:

int timerfd_create(int clockid);
int timerfd_settime(int ufd, int flags,
		    const struct itimerspec *utmr,
		    struct itimerspec *otmr);
int timerfd_gettime(int ufd, struct itimerspec *otmr);

The timerfd_create() API creates an un-programmed timerfd fd. The "clockid"
parameter can be either CLOCK_MONOTONIC or CLOCK_REALTIME.
The timerfd_settime() API give new settings by the timerfd fd, by optionally
retrieving the previous expiration time (in case the "otmr" parameter is not NULL).
The time value specified in "utmr" is absolute, if the TFD_TIMER_ABSTIME bit
is set in the "flags" parameter. Otherwise it's a relative time.
The timerfd_gettime() API returns the next expiration time of the timer, or {0, 0}
if the timerfd has not been set yet.
Like the previous timerfd API implementation, read(2) and poll(2) are supported
(with the same interface).
Here's a simple test program I used to exercise the new timerfd APIs:

http://www.xmailserver.org/timerfd-test2.c



Signed-off-by: Davide Libenzi &lt;davidel@xmailserver.org&gt;


- Davide


---
 fs/compat.c              |   32 ++++++-
 fs/timerfd.c             |  199 ++++++++++++++++++++++++++++++-----------------
 include/linux/compat.h   |    7 +
 include/linux/syscalls.h |    7 +
 4 files changed, 168 insertions(+), 77 deletions(-)

Index: linux-2.6.mod/fs/timerfd.c
===================================================================
--- linux-2.6.mod.orig/fs/timerfd.c	2007-09-23 15:18:09.000000000 -0700
+++ linux-2.6.mod/fs/timerfd.c	2007-09-23 15:25:55.000000000 -0700
@@ -23,15 +23,17 @@
 
 struct timerfd_ctx {
 	struct hrtimer tmr;
+	int clockid;
 	ktime_t tintv;
 	wait_queue_head_t wqh;
 	int expired;
+	u64 ticks;
 };
 
 /*
  * This gets called when the timer event triggers. We set the "expired"
  * flag, but we do not re-arm the timer (in case it's necessary,
- * tintv.tv64 != 0) until the timer is read.
+ * tintv.tv64 != 0) until...
To: Davide Libenzi <davidel@...>
Cc: Linux Kernel Mailing List <linux-kernel@...>, Michael Kerrisk <mtk-manpages@...>, Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>
Date: Monday, September 24, 2007 - 4:26 am

Davide,


Can you please restructure the struct in a way which does not result in
padding by the compiler ?

struct timerfd_ctx {
	struct hrtimer tmr;
	ktime_t tintv;
	wait_queue_head_t wqh;
	u64 ticks;
	int expired;
	int clockid;

You need to use ctx-&gt;tmr.base-&gt;get_time() here, otherwise you might read

You really can avoid the goto here.

	tglx


-
To: Thomas Gleixner <tglx@...>
Cc: Linux Kernel Mailing List <linux-kernel@...>, Michael Kerrisk <mtk-manpages@...>, Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>
Date: Monday, September 24, 2007 - 11:42 am

Is the particular position of hrtimer_cb_get_time() in the code that would 
break here? Because function was added by your patch ;)

Ack.



- Davide


-
To: Davide Libenzi <davidel@...>
Cc: Linux Kernel Mailing List <linux-kernel@...>, Michael Kerrisk <mtk-manpages@...>, Andrew Morton <akpm@...>, Linus Torvalds <torvalds@...>
Date: Monday, September 24, 2007 - 11:53 am

For non high res systems we speed up the access to now by storing the
current time when we start to process the hrtimer softirq callbacks.

hrtimer_cb_get_time(timer) reads timer-&gt;base-&gt;now

For high resolution systems hrtimer_cb_get_time() resolves to
timer-&gt;base-&gt;get_time().

In the timerfd case we are not in softirq context and we read at any
given later time. Also on SMP the base-&gt;now variable might be changed by
the softirq running on the other CPU.

	tglx


-
Previous thread: Xen kernel 2.6.23-rc7 bug at xen_mc_flush (arch/i386/xen/multicalls.c:68) by osth on Sunday, September 23, 2007 - 5:55 pm. (5 messages)

Next thread: [patch 2/3] new timerfd API - wire the new timerfd API to the x86 family by Davide Libenzi on Sunday, September 23, 2007 - 6:49 pm. (5 messages)
speck-geostationary