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=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 134ECC0650F for ; Tue, 30 Jul 2019 11:26:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DA0F3206A2 for ; Tue, 30 Jul 2019 11:26:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dA8PLMTU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA0F3206A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w7pv65DFFH6rO/u5td0mzNdmdHbFpoIKbCCTAs0JqYI=; b=dA8PLMTUydomx+ dHMYKnqWP1yKCdbQoPtgrzGcmQgVa2i66dNHIn+6fq12crZbZZReH7ahoGGnE84RhwLD8fYbcYzFE xPQ8n8PmPBDW38Xu3n4giaoEPQ0F4z2AW5Twz4MAh4DGM5tFjO9CeJT3n7pA2xml0ut1y6pLbXkmE wxA2ks9HRL0mgYWrajDz/yFhrQ5g+NqC8obOuX43MRdOtJuUmE50aRBYRke/VNSzrslVvsqM0zNLX Yx3H/qSwzgSTFmK9Hu0xkYMSxewVQBhYJNS0w7OxEgQgUtUFzXAFDrBpgUgp/059VCafiwsfVYgy0 axjj8P+QhGd+Svr3w4ew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsQHE-0007bI-Qe; Tue, 30 Jul 2019 11:26:44 +0000 Received: from mail-wm1-f67.google.com ([209.85.128.67]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hsQHC-0007al-OE for linux-riscv@lists.infradead.org; Tue, 30 Jul 2019 11:26:44 +0000 Received: by mail-wm1-f67.google.com with SMTP id s3so56768298wms.2 for ; Tue, 30 Jul 2019 04:26:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zRulNL5qCAi/81YynxGrimpN6FxyJ33F7yQYkhCyZlk=; b=WEj4FeqAi/IoEaxbce3EDcA6TQoe09lB5mhZgO19c2MOiYeOMSvAKIlmq3EtX0CM5N 5zVnU8A4O+6M36vOl4XbanaYlOIuBjxG0HVwiJEJF3pumyEvtlpL7tQNR8oBesFFUVU5 s9uHCZUWv0+4nJBvpZ95dMHDNnOU4TDGyFqDizd6O6m0JFQx+LMdyhfRP3UDhs1giI9P o5PRixJHCTnJ6CaNk2J4Y3rIjcygqyEM7sphK9eKvrhLk3fd1MCnu/GMbhUXdNjwF7A+ 4NlwQXxdOUkoY38A7uwi9QIno4PImu8BSfFdg/Lxv3y+qaV1nOqCnuaKgTJJ0i3M0jtd Sn8A== X-Gm-Message-State: APjAAAXUtkowIJB78rU3JZXRVFkRghkBhq05nAm24peBqruxl/h2nM6g z6Atm4Pf7RIjlkqoAPj5D7uxB3hMjYE= X-Google-Smtp-Source: APXvYqxo5UHLG3tyCvJ9QKdkC6ZVQFG9DiXwMjRxFm5zOjg0AFUbgZKXZO3dtvVP5tdG02WNBFwMlQ== X-Received: by 2002:a1c:e009:: with SMTP id x9mr103306392wmg.5.1564486001151; Tue, 30 Jul 2019 04:26:41 -0700 (PDT) Received: from [192.168.10.150] ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id 4sm146590471wro.78.2019.07.30.04.26.39 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jul 2019 04:26:40 -0700 (PDT) Subject: Re: [RFC PATCH 13/16] RISC-V: KVM: Add timer functionality To: Anup Patel , Palmer Dabbelt , Paul Walmsley , Radim K References: <20190729115544.17895-1-anup.patel@wdc.com> <20190729115544.17895-14-anup.patel@wdc.com> From: Paolo Bonzini Message-ID: Date: Tue, 30 Jul 2019 13:26:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190729115544.17895-14-anup.patel@wdc.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190730_042642_791211_9CB75C66 X-CRM114-Status: GOOD ( 10.45 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Le Moal , "kvm@vger.kernel.org" , Anup Patel , Daniel Lezcano , "linux-kernel@vger.kernel.org" , Christoph Hellwig , Atish Patra , Alistair Francis , Thomas Gleixner , "linux-riscv@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org On 29/07/19 13:57, Anup Patel wrote: > + if (delta_ns > VCPU_TIMER_PROGRAM_THRESHOLD_NS) { > + hrtimer_start(&t->hrt, ktime_add_ns(ktime_get(), delta_ns), I think the guest would prefer if you saved the time before enabling interrupts on the host, and use that here instead of ktime_get(). Otherwise the timer could be delayed arbitrarily by host interrupts. (Because the RISC-V SBI timer is relative only---which is unfortunate---guests will already pay a latency price due to the extra cost of the SBI call compared to a bare metal implementation. Sooner or later you may want to implement something like x86's heuristic to advance the timer deadline by a few hundred nanoseconds; perhaps add a TODO now). Paolo > + HRTIMER_MODE_ABS); > + t->is_set = true; > + } else > + kvm_riscv_vcpu_set_interrupt(vcpu, IRQ_S_TIMER); > + _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv