From: "Jan Beulich" Subject: [PATCH] linux/x86: fix long timeout handling in stop_hz_timer() Date: Thu, 18 Feb 2010 17:07:03 +0000 Message-ID: <4B7D81C70200007800030289@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Other than for HYPERVISOR_set_timer_op, zero doesn't mean "no timeout" for VCPUOP_set_singleshot_timer (but should be retained rather than adjusted by NS_PER_TICK/2 for the former). Also properly cancel the singleshot timer is start_hz_timer(). Signed-off-by: Jan Beulich --- a/arch/i386/kernel/time-xen.c +++ b/arch/i386/kernel/time-xen.c @@ -939,7 +939,10 @@ static void stop_hz_timer(void) j =3D jiffies + 1; } =20 - singleshot.timeout_abs_ns =3D jiffies_to_st(j) + NS_PER_TICK/2; + singleshot.timeout_abs_ns =3D jiffies_to_st(j); + if (!singleshot.timeout_abs_ns) + return; + singleshot.timeout_abs_ns +=3D NS_PER_TICK / 2; singleshot.flags =3D 0; rc =3D HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, cpu, = &singleshot); #if CONFIG_XEN_COMPAT <=3D 0x030004 @@ -953,7 +956,17 @@ static void stop_hz_timer(void) =20 static void start_hz_timer(void) { - cpu_clear(smp_processor_id(), nohz_cpu_mask); + unsigned int cpu =3D smp_processor_id(); + int rc =3D HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, = NULL); + +#if CONFIG_XEN_COMPAT <=3D 0x030004 + if (rc) { + BUG_ON(rc !=3D -ENOSYS); + rc =3D HYPERVISOR_set_timer_op(0); + } +#endif + BUG_ON(rc); + cpu_clear(cpu, nohz_cpu_mask); } =20 void raw_safe_halt(void)