From: Rusty Russell <rusty@rustcorp.com.au>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andi Kleen <ak@muc.de>
Subject: [PATCH 2/6] lguest tsc fix
Date: Wed, 06 Jun 2007 00:56:36 +1000 [thread overview]
Message-ID: <1181055396.14054.38.camel@localhost.localdomain> (raw)
In-Reply-To: <1181055308.14054.36.camel@localhost.localdomain>
In recent -mm kernels, the TSC capability cannot be disabled,
resulting in a divide by zero error in the normal sched_clock.
The correct fix is to have a special lguest sched_clock
implementation: this is as simple as it gets.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/lguest/lguest.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
===================================================================
--- a/drivers/lguest/lguest.c
+++ b/drivers/lguest/lguest.c
@@ -351,11 +351,18 @@ static void lguest_time_irq(unsigned int
update_process_times(user_mode_vm(get_irq_regs()));
}
+static u64 sched_clock_base;
static void lguest_time_init(void)
{
set_irq_handler(0, lguest_time_irq);
hcall(LHCALL_TIMER_READ, 0, 0, 0);
+ sched_clock_base = jiffies_64;
enable_lguest_irq(0);
+}
+
+static unsigned long long lguest_sched_clock(void)
+{
+ return (jiffies_64 - sched_clock_base) * (1000000000 / HZ);
}
static void lguest_load_esp0(struct tss_struct *tss,
@@ -494,6 +501,7 @@ __init void lguest_init(void *boot)
paravirt_ops.time_init = lguest_time_init;
paravirt_ops.set_lazy_mode = lguest_lazy_mode;
paravirt_ops.wbinvd = lguest_wbinvd;
+ paravirt_ops.sched_clock = lguest_sched_clock;
hcall(LHCALL_LGUEST_INIT, __pa(&lguest_data), 0, 0);
@@ -507,8 +515,6 @@ __init void lguest_init(void *boot)
cpu_detect(&new_cpu_data);
/* Math is always hard! */
new_cpu_data.hard_math = 1;
-
- tsc_disable = 1;
#ifdef CONFIG_X86_MCE
mce_disabled = 1;
next prev parent reply other threads:[~2007-06-05 15:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-05 14:55 [PATCH 1/6] lguest example launcher fix Rusty Russell
2007-06-05 14:56 ` Rusty Russell [this message]
2007-06-05 14:58 ` [PATCH 3/6] lguest suppress IDE probing Rusty Russell
2007-06-05 15:00 ` [PATCH 4/6] lguest don't signal like crazy, use LHREQ_BREAK command Rusty Russell
2007-06-05 15:02 ` [PATCH 5/6] lguest use TSC Rusty Russell
2007-06-05 15:09 ` [PATCH 6/6] lguest use hrtimers Rusty Russell
2007-06-05 15:34 ` [PATCH 4/6] lguest don't signal like crazy, use LHREQ_BREAK command Matt Mackall
2007-06-06 0:07 ` Rusty Russell
2007-06-06 1:00 ` Matt Mackall
2007-06-05 15:32 ` [PATCH 3/6] lguest suppress IDE probing Matt Mackall
2007-06-05 16:07 ` Alan Cox
2007-06-05 16:10 ` Jeff Garzik
2007-06-05 17:09 ` James Morris
2007-06-06 1:10 ` Rusty Russell
2007-06-06 10:23 ` Alan Cox
2007-06-07 2:13 ` Rusty Russell
2007-06-07 14:45 ` Matt Mackall
2007-06-05 18:15 ` [PATCH 2/6] lguest tsc fix Andi Kleen
2007-06-06 0:25 ` Rusty Russell
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=1181055396.14054.38.camel@localhost.localdomain \
--to=rusty@rustcorp.com.au \
--cc=ak@muc.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®