WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH] xen: always handle VIRQ_TIMER first.

To: Keir Fraser <keir@xxxxxxx>
Subject: [Xen-devel] Re: [PATCH] xen: always handle VIRQ_TIMER first.
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Fri, 15 Oct 2010 14:11:47 -0700
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 15 Oct 2010 14:12:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C8DE5C49.2627A%keir@xxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <C8DE5C49.2627A%keir@xxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Lightning/1.0b3pre Thunderbird/3.1.4
 On 10/15/2010 11:30 AM, Keir Fraser wrote:
> On 15/10/2010 18:18, "Jeremy Fitzhardinge" <jeremy@xxxxxxxx> wrote:
>
>>  On 10/15/2010 03:52 AM, Ian Campbell wrote:
>>> This ensures that system is updated before calling any hard irq
>>> handlers after a long period of ticklessness. If we do not do this
>>> then hardirq will see a jiffies from before the period of ticklessness
>>> and make intcorrect decisions regarding timer expiry etc.
>>>
>>> This resolves issues e.g. with USB keyboard timer repeats.
>>>
>>> Based on a patch by Keir Fraser.
>> I talked about this with James, and it makes no sense to me at all.
> When guest resumes execution after a long period blocked, the unblocking
> interrupt may be handled before the inevitable timer interrupt which

Why "inevitable"?  What if the next timer event is still some time in
the future?  Or are you assuming the timer is driven by the default Xen
100Hz timer?

> actually syncs up jiffies to current system time. The unblocking interrupt
> sees old jiffies -- most hardirq handlers really don't care about time, but
> it happens that USB keyboard repeat is handled at that level -- it sees the
> key pressed at old jiffies and not released until new jiffies plus small
> delta. The difference between old and new jiffies can easily be enough to
> cause phantom key repeats.

Yes, but...

If the system is idle and has disabled timer ticks, and the next
interrupt is from a piece of hardware, then jiffies will be out of date,
but there won't necessarily be a pending timer tick.  If a device
interrupt handler is allowed to rely on jiffies, then there must be some
generic mechanism to update jiffies before calling any interrupt
handler.  This situation doesn't seem like it is in any way Xen
dependent, and AFAIK there's no general requirement that timer
interrupts be handled first. 

I'm guessing that this particular problem in the forward-port Xen kernel
as a side-effect of its bespoke time handling code (including
IDLE_NO_HZ) which is not doing something that the core time
infrastructure would normally do.  (I don't see why the forward-port
kernels couldn't use the existing Xen time support in mainline rather
than replacing it.)

Or perhaps there is a real bug here, but again, I don't think it is
Xen-specific, or be addressed in Xen code.

> One question of course is whether the same hardirq key repeat mechanism can
> be foxed simply be involuntary preemption of the guest. I suppose it could,
> but it's vastly more unlikely than the systematic deterministic race
> introduced by resume-from-block. Also we would hope that a runnable guest
> would not be descheduled for as long periods as a guest can be voluntarily
> blocked (bit arm waving that one I'll admit ;-).

I've seen unexpected key repeats in guests when using kvm keyboards.

    J

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel