diff mbox

[RFC,PATCHv8,05/30] aio / timers: Add prctl(PR_SET_TIMERSLACK, 1, ...) to reduce timer slack

Message ID 1375998147-24292-6-git-send-email-alex@alex.org.uk
State New
Headers show

Commit Message

Alex Bligh Aug. 8, 2013, 9:42 p.m. UTC
Where supported, called prctl(PR_SET_TIMERSLACK, 1, ...) to
set one nanosecond timer slack to increase precision of timer
calls.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
---
 qemu-timer.c |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Stefan Hajnoczi Aug. 9, 2013, 8:53 a.m. UTC | #1
On Thu, Aug 08, 2013 at 10:42:02PM +0100, Alex Bligh wrote:
> Where supported, called prctl(PR_SET_TIMERSLACK, 1, ...) to
> set one nanosecond timer slack to increase precision of timer
> calls.
> 
> Signed-off-by: Alex Bligh <alex@alex.org.uk>
> ---
>  qemu-timer.c |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/qemu-timer.c b/qemu-timer.c
> index 5e81935..9eb6db8 100644
> --- a/qemu-timer.c
> +++ b/qemu-timer.c
> @@ -41,6 +41,10 @@
>  #include <poll.h>
>  #endif
>  
> +#ifdef CONFIG_PRCTL_PR_SET_TIMERSLACK

The ./configure change should also be in this patch.  I think it crept
into another patch by mistake.
Alex Bligh Aug. 9, 2013, 2:10 p.m. UTC | #2
On 9 Aug 2013, at 09:53, Stefan Hajnoczi wrote:

> The ./configure change should also be in this patch.  I think it crept
> into another patch by mistake.

Oops - I will fix.
diff mbox

Patch

diff --git a/qemu-timer.c b/qemu-timer.c
index 5e81935..9eb6db8 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -41,6 +41,10 @@ 
 #include <poll.h>
 #endif
 
+#ifdef CONFIG_PRCTL_PR_SET_TIMERSLACK
+#include <sys/prctl.h>
+#endif
+
 /***********************************************************/
 /* timers */
 
@@ -507,6 +511,9 @@  void init_clocks(void)
         vm_clock = qemu_clock_new(QEMU_CLOCK_VIRTUAL);
         host_clock = qemu_clock_new(QEMU_CLOCK_HOST);
     }
+#ifdef CONFIG_PRCTL_PR_SET_TIMERSLACK
+    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
+#endif
 }
 
 uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts)