Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp440966pxb; Mon, 25 Oct 2021 11:14:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx4rTzVmskQaAqZM1Ajnby4aEVl8hOzBW0usPkJ3gXtvQ+DdBaFQ64Qy6ZkxFsEv+rfH1N X-Received: by 2002:a17:907:1c9e:: with SMTP id nb30mr15303170ejc.141.1635185698715; Mon, 25 Oct 2021 11:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635185698; cv=none; d=google.com; s=arc-20160816; b=DjQB0a6IEkxAAa5YVCA8ErV77WHMFfnQhx7uWRQ35Wf/9BVg03KbuTrxHhSJW1nNxM 6iI3Ymcw8DDcVpVK18zemmmcQt+366QytCG20RgbILcTD2Zx9h5bK5GJ835WFV5z3Vxu 0l8ACgYbUOSPEwkhPV37fRgMPnkEw5C1CRoPw8jhhlnBO81oNFDQ0/hYJrMw9SXg42WW TWPBNhMweNwFf15627ioq7xaF8Sxhyq2xC6DE6yRzyaXDRn9nn4kfey8Ce2Tw9sv0yhE /H5pi4EI1Io7sxyRLEUU8HaEP9pbgN3p5uZugGwVAagqqyK9zI3p78O/ERFFduZt8sOg zDLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=bye7ObUVwxXJ2WkSXV7ATW6vdQkdYkTKPDS9mWywO4k=; b=pZROHqi7icn0fM2HsvubPfRAKf8wVZQclMz3kcUIymNGDSwjTLtvK8xlyW/YSkNpkU 2mLCvZqh63v74mUaXP4Z8gB3Qu84Mh9w03RcP8SuMxewTd+4+aapSSpYcv6DGu76fIRx dYXRLaUbsprfIPtzzNudHYo/Au4i5t2KYoSHiZTNIKQrUZLNbJe99b4/U//xH7vE8DdJ /ZkuGSMzI/HCMjFKsYkVMtkGwRPBRF3w6g8NjH2Xhu4DPA599uZ4E8sc/V4Pkh7VOfNd VGRHApS1XFFHZeVSTrP+zaNCWHjgzif/gDcOgBg5Tw832AvmfD2cbDk3wwgBuIde4SAf gRPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VG20wsfW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp6si1518734ejc.765.2021.10.25.11.14.34; Mon, 25 Oct 2021 11:14:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VG20wsfW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233544AbhJYO2i (ORCPT + 99 others); Mon, 25 Oct 2021 10:28:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39066 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233535AbhJYO2g (ORCPT ); Mon, 25 Oct 2021 10:28:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635171973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bye7ObUVwxXJ2WkSXV7ATW6vdQkdYkTKPDS9mWywO4k=; b=VG20wsfW81XXPKqAw5GP7sPzbhA4Uz7GMRjfobhJBnMpVfvvUHWtqpsDWNV2Ht62lM784j pmJYBcOfQP8oznAKfuriTSHgRiFZxel+Z5PdBLZkPiya2ceE8r5gdUcHnnS6TYFTDxslEe 4hEwvDnnw9gXIQwLAumNBYRTW6lPNLM= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-huTX48CpPe-5tWAWj6CobQ-1; Mon, 25 Oct 2021 10:26:12 -0400 X-MC-Unique: huTX48CpPe-5tWAWj6CobQ-1 Received: by mail-ed1-f70.google.com with SMTP id w7-20020a056402268700b003dd46823a18so4196683edd.18 for ; Mon, 25 Oct 2021 07:26:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=bye7ObUVwxXJ2WkSXV7ATW6vdQkdYkTKPDS9mWywO4k=; b=Frw/UvfWDBvnqJF7Y3mPBKkkA48U3vV/Qz8E8UI7ei4UjLxNDns1BsMk1sEZSR2M0s RIisGZ8I2fBQMpjjmfXQ9wrLoNG9u/ymF0r3MR16n0gxkzYfDKFBNux9/kjiZ8uXdXOu khJJJAcNKkXiUgwlk6LzR2K4DCjCoya15eQxdpln/bFsVdYAbiioF2xddOWj9PfyLy0K +hGskY33PFWf80rJMDwsQRil23a9a6OrZ8JHh98rDiKv677mHebRRtqS5G7XA8c+z7EJ 6rJpiJpKXMsMVhn8JuytrD7AnF94KOz5xJlMCerhXkgSnnD2GXwTwjyJlrcw/Z2BMStY maYw== X-Gm-Message-State: AOAM5323a0xUZB0MnbfclEBXZiKgBLC9ojr8yRSpmWBeqL4+nolQQvbS 3zLHNIBrK9txodQ8swF6rSywzNR8Ns4AYdH65jwDFLEuEicX9JQPf3FGB2chAIYl/3373ExDz6f SPWIjeyzaIFt7woOVeRrepHF2 X-Received: by 2002:a17:906:c0cf:: with SMTP id bn15mr21819122ejb.54.1635171971316; Mon, 25 Oct 2021 07:26:11 -0700 (PDT) X-Received: by 2002:a17:906:c0cf:: with SMTP id bn15mr21819096ejb.54.1635171971137; Mon, 25 Oct 2021 07:26:11 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id g14sm5171403edp.31.2021.10.25.07.26.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Oct 2021 07:26:10 -0700 (PDT) Message-ID: <0072221e-02e8-4d60-9b0f-80d8c423bf4e@redhat.com> Date: Mon, 25 Oct 2021 16:26:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH v2 16/43] KVM: Don't redo ktime_get() when calculating halt-polling stop/deadline Content-Language: en-US To: Sean Christopherson , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , Oliver Upton , Jing Zhang References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-17-seanjc@google.com> From: Paolo Bonzini In-Reply-To: <20211009021236.4122790-17-seanjc@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10/21 04:12, Sean Christopherson wrote: > Calculate the halt-polling "stop" time using "cur" instead of redoing > ktime_get(). In the happy case where hardware correctly predicts > do_halt_poll, "cur" is only a few cycles old. And if the branch is > mispredicted, arguably that extra latency should count toward the > halt-polling time. > > In all likelihood, the numbers involved are in the noise and either > approach is perfectly ok. Using "start" makes the change even more obvious, so: Calculate the halt-polling "stop" time using "start" instead of redoing ktime_get(). In practice, the numbers involved are in the noise (e.g., in the happy case where hardware correctly predicts do_halt_poll and there are no interrupts, "start" is probably only a few cycles old) and either approach is perfectly ok. But it's more precise to count any extra latency toward the halt-polling time. Paolo