From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EE63C433DF for ; Tue, 21 Jul 2020 11:54:03 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B2AD2080D for ; Tue, 21 Jul 2020 11:54:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Vwe9SNSZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B2AD2080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jxqq2-00059T-Ho; Tue, 21 Jul 2020 11:53:38 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jxqq1-00059O-7U for xen-devel@lists.xenproject.org; Tue, 21 Jul 2020 11:53:37 +0000 X-Inumbo-ID: ce1484d4-cb48-11ea-a0a1-12813bfff9fa Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ce1484d4-cb48-11ea-a0a1-12813bfff9fa; Tue, 21 Jul 2020 11:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595332414; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=OOa+A3QfUb/+6qL6XytZeqbMeTi37eM1OfzxLLRcWaA=; b=Vwe9SNSZElLF8f0RAqIn3sQtcXZRjO1czz8wYB18YLWS3JApY3Ok9fMk oeJ/6maBPViXQDcAGxhD68Ka74zQFPVuSERl5zT71FjjK1VL48YHXCjc0 jpZByi9RRhhTKwcbms78r0K/VdLjf8/XPsbORUkjC3/UkvIoFSBzbgQqb k=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: KO5WVOrqDpuBC6xmtpaQupVrPLCkbWZrnuQJazzZZl5TqX8oxNBo54pyKkIF2e2SrBB65Ib7/n 2KIka1TIAnCGy5bDSVub2k/r1vhBp31cH/A61Ulzi3EcVFvEERgu6XuIxntv8dAAOn/LG6cbip Ry0c+Q7ffu3DB5h4OPpjJ9Uc2i4GfiPQjpuCWhx6rCuK4zKRDGFsUDYDMZxroP3bTU0rzsOgGN j9A8Tg7GqXxBkLX7i4j0TlK/dRPNeZGyE676+RlzlNVBuU1iXyw7oIVGShd/QnroPQqJnyqSj0 0j0= X-SBRS: 2.7 X-MesageID: 23160386 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,378,1589256000"; d="scan'208";a="23160386" Date: Tue, 21 Jul 2020 13:53:27 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Subject: Re: vPT rework (and timer mode) Message-ID: <20200721115327.GO7191@Air-de-Roger> References: <20200701090210.GN735@Air-de-Roger> <007a01d65363$9ab7c1d0$d0274570$@xen.org> <20200706083131.GA735@Air-de-Roger> <007c01d65373$ad3c4140$07b4c3c0$@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <007c01d65373$ad3c4140$07b4c3c0$@xen.org> X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: 'Andrew Cooper' , Igor Druzhinin , 'Wei Liu' , 'Jan Beulich' , xen-devel@lists.xenproject.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Mon, Jul 06, 2020 at 09:58:53AM +0100, Paul Durrant wrote: > > -----Original Message----- > > From: Roger Pau Monné > > Sent: 06 July 2020 09:32 > > To: paul@xen.org > > Cc: 'Andrew Cooper' ; 'Jan Beulich' ; xen- > > devel@lists.xenproject.org; 'Wei Liu' > > Subject: Re: vPT rework (and timer mode) > > > > On Mon, Jul 06, 2020 at 08:03:50AM +0100, Paul Durrant wrote: > > > > -----Original Message----- > > > > From: Andrew Cooper > > > > Sent: 03 July 2020 16:03 > > > > To: Jan Beulich ; Roger Pau Monné > > > > Cc: xen-devel@lists.xenproject.org; Wei Liu ; Paul Durrant > > > > Subject: Re: vPT rework (and timer mode) > > > > > > > > On 03/07/2020 15:50, Jan Beulich wrote: > > > > > On 01.07.2020 11:02, Roger Pau Monné wrote: > > > > >> It's my understanding that the purpose of pt_update_irq and > > > > >> pt_intr_post is to attempt to implement the "delay for missed ticks" > > > > >> mode, where Xen will accumulate timer interrupts if they cannot be > > > > >> injected. As shown by the patch above, this is all broken when the > > > > >> timer is added to a vCPU (pt->vcpu) different than the actual target > > > > >> vCPU where the interrupt gets delivered (note this can also be a list > > > > >> of vCPUs if routed from the IO-APIC using Fixed mode). > > > > >> > > > > >> I'm at lost at how to fix this so that virtual timers work properly > > > > >> and we also keep the "delay for missed ticks" mode without doing a > > > > >> massive rework and somehow keeping track of where injected interrupts > > > > >> originated, which seems an overly complicated solution. > > > > >> > > > > >> My proposal hence would be to completely remove the timer_mode, and > > > > >> just treat virtual timer interrupts as other interrupts, ie: they will > > > > >> be injected from the callback (pt_timer_fn) and the vCPU(s) would be > > > > >> kicked. Whether interrupts would get lost (ie: injected when a > > > > >> previous one is still pending) depends on the contention on the > > > > >> system. I'm not aware of any current OS that uses timer interrupts as > > > > >> a way to track time. I think current OSes know the differences between > > > > >> a timer counter and an event timer, and will use them appropriately. > > > > > Fundamentally - why not, the more that this promises to be a > > > > > simplification. The question we need to answer up front is whether > > > > > we're happy to possibly break old OSes (presumably ones no-one > > > > > ought to be using anymore these days, due to their support life > > > > > cycles long having ended). > > > > > > > > The various timer modes were all compatibility, and IIRC, mostly for > > > > Windows XP and older which told time by counting the number of timer > > > > interrupts. > > > > > > > > Paul - you might remember better than me? > > > > > > I think it is only quite recently that Windows has started favouring enlightened time sources rather > > than counting ticks but an admin may still turn all the viridian enlightenments off so just dropping > > ticks will probably still cause time to drift backwards. > > > > Even when not using the viridian enlightenments, Windows should rely > > on emulated time counters (or the TSC) rather than counting ticks? > > Microsoft implementations... sensible... two different things. > > > > > I guess I could give it a try with one of the emulated Windows versions > > that we test on osstest. > > > > Pick an old-ish version. I think osstest has copy of Windows 7. Tried on Windows 7 (with viridian disabled) setting timer_mode="one_missed_tick_pending" and limiting the capacity of the domain to 1 (1% CPU utilization) in order to start missing ticks, and the clock does indeed start lagging behind. When not using one_missed_tick_pending mode and limiting the capacity to 1 the clock also lags a bit (I guess with 1% CPU utilization delayed ticks accumulate too much), but the clock doesn't seem to be skewed that much. Both modes will catch up at some point, I assume Windows does sync time periodically with the wallclock, but I don't think we want to resort to that. I will draft a plan about how to proceed in order to fix the emulated timers event delivery while keeping the accumulated ticks mode and send it to the list, as I would like to fix this. Roger.