[Lguest] [PATCH] Provide timespec to guests rather than jiffies clock.

Andrew Morton akpm at linux-foundation.org
Fri Jul 27 14:26:51 EST 2007


On Fri, 27 Jul 2007 13:42:52 +1000 Rusty Russell <rusty at rustcorp.com.au> wrote:

> A non-periodic clock_event_device and the "jiffies" clock don't mix well:
> tick_handle_periodic() can go into an infinite loop.
> 
> Currently lguest guests use the jiffies clock when the TSC is
> unusable.  Instead, make the Host write the current time into the lguest
> page on every interrupt.  This doesn't cost much but is more precise
> and at least as accurate as the jiffies clock.  It also gets rid of
> the GET_WALLCLOCK hypercall.
> 
> Also, delay setting sched_clock until our clock is set up, otherwise
> the early printk timestamps can go backwards (not harmful, just ugly).
> 
> Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
> 
> ---
>  tmp/lguest/linux-2.6.23-rc1/drivers/lguest/hypercalls.c           |   21 ++--
>  tmp/lguest/linux-2.6.23-rc1/drivers/lguest/interrupts_and_traps.c |    7 +
>  tmp/lguest/linux-2.6.23-rc1/drivers/lguest/lg.h                   |    1 
>  tmp/lguest/linux-2.6.23-rc1/drivers/lguest/lguest.c               |   52 ++++++----
>  tmp/lguest/linux-2.6.23-rc1/include/linux/lguest.h                |    4 
>  5 files changed, 60 insertions(+), 25 deletions(-)

your diffstats are funny

> --- linux-2.6.23-rc1/drivers/lguest/hypercalls.c
> +++ /tmp/lguest/linux-2.6.23-rc1/drivers/lguest/hypercalls.c

because the headers are funny.

> +
> +/* This routine supplies the Guest with time: it's used for wallclock time at
> + * initial boot and as a rough time source if the TSC isn't available. */
> +void write_timestamp(struct lguest *lg)
> +{
> +	struct timespec now;
> +	ktime_get_real_ts(&now);
> +	if (put_user(now, &lg->lguest_data->time))
> +		kill_guest(lg, "Writing timestamp");
> +}

This seems a rather generic name for a kernel-wide symbol.  Can I do
s/write_timestamp/lguest_write_timestamp/g?





More information about the Lguest mailing list