x86/xen: Add "xen_timer_slop" command line option
authorRyan Thibodeaux <ryan.thibodeaux@starlab.io>
Fri, 22 Mar 2019 18:29:57 +0000 (14:29 -0400)
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>
Tue, 23 Apr 2019 15:06:26 +0000 (11:06 -0400)
Add a new command-line option "xen_timer_slop=<INT>" that sets the
minimum delta of virtual Xen timers. This commit does not change the
default timer slop value for virtual Xen timers.

Lowering the timer slop value should improve the accuracy of virtual
timers (e.g., better process dispatch latency), but it will likely
increase the number of virtual timer interrupts (relative to the
original slop setting).

The original timer slop value has not changed since the introduction
of the Xen-aware Linux kernel code. This commit provides users an
opportunity to tune timer performance given the refinements to
hardware and the Xen event channel processing. It also mirrors
a feature in the Xen hypervisor - the "timer_slop" Xen command line
option.

[boris: updated comment describing TIMER_SLOP]

Signed-off-by: Ryan Thibodeaux <ryan.thibodeaux@starlab.io>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Documentation/admin-guide/kernel-parameters.txt
arch/x86/xen/time.c

index 2b8ee90..2623749 100644 (file)
                        with /sys/devices/system/xen_memory/xen_memory0/scrub_pages.
                        Default value controlled with CONFIG_XEN_SCRUB_PAGES_DEFAULT.
 
+       xen_timer_slop= [X86-64,XEN]
+                       Set the timer slop (in nanoseconds) for the virtual Xen
+                       timers (default is 100000). This adjusts the minimum
+                       delta of virtualized Xen timers, where lower values
+                       improve timer resolution at the expense of processing
+                       more timer interrupts.
+
        xirc2ps_cs=     [NET,PCMCIA]
                        Format:
                        <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]]
index 6e29794..befbdd8 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "xen-ops.h"
 
-/* Xen may fire a timer up to this many ns early */
+/* Minimum amount of time until next clock event fires */
 #define TIMER_SLOP     100000
 
 static u64 xen_sched_clock_offset __read_mostly;
@@ -212,7 +212,7 @@ static int xen_timerop_set_next_event(unsigned long delta,
        return 0;
 }
 
-static const struct clock_event_device xen_timerop_clockevent = {
+static struct clock_event_device xen_timerop_clockevent __ro_after_init = {
        .name                   = "xen",
        .features               = CLOCK_EVT_FEAT_ONESHOT,
 
@@ -273,7 +273,7 @@ static int xen_vcpuop_set_next_event(unsigned long delta,
        return ret;
 }
 
-static const struct clock_event_device xen_vcpuop_clockevent = {
+static struct clock_event_device xen_vcpuop_clockevent __ro_after_init = {
        .name = "xen",
        .features = CLOCK_EVT_FEAT_ONESHOT,
 
@@ -570,3 +570,17 @@ void __init xen_hvm_init_time_ops(void)
        x86_platform.set_wallclock = xen_set_wallclock;
 }
 #endif
+
+/* Kernel parameter to specify Xen timer slop */
+static int __init parse_xen_timer_slop(char *ptr)
+{
+       unsigned long slop = memparse(ptr, NULL);
+
+       xen_timerop_clockevent.min_delta_ns = slop;
+       xen_timerop_clockevent.min_delta_ticks = slop;
+       xen_vcpuop_clockevent.min_delta_ns = slop;
+       xen_vcpuop_clockevent.min_delta_ticks = slop;
+
+       return 0;
+}
+early_param("xen_timer_slop", parse_xen_timer_slop);