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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D41F3C433F5 for ; Mon, 25 Oct 2021 14:26:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBF7660EBB for ; Mon, 25 Oct 2021 14:26:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233539AbhJYO2m (ORCPT ); Mon, 25 Oct 2021 10:28:42 -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-Google-Smtp-Source: ABdhPJw1tQyM0wVdwMUOMrIgmjrbrmjI7F4R9FGcgAmNEuZGC3NNZA+IU7BqgOO63yxAXGZ3HmbepA== 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 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8704EC433FE for ; Mon, 25 Oct 2021 14:26:50 +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 4A45E60F46 for ; Mon, 25 Oct 2021 14:26:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4A45E60F46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AAt98caIe/YvQxRwzVpeMRl+jvYa5y35chzHTtFzZi8=; b=m1+yWNEUlVZRfw NkNztspBydb+MRS5XrrPY47lyZW2MrBP1Je17tZsQv1IsOlA9tSytvWLt16PwFNAjfUTVPjLvlNGI E4LwPZ88+mVGZqsN0Jhqs96Gkfqa7VDUkHvrWZHyveaC9ouwtqbd3QZQcU43M5XSYC0nCPLfeNH7m sNFamQKtESVHm8umE8UAIR38kJvSHaEZuOpQHjywONZ2TnWzLPWYaSF+BEzr5qi3TCnmzruJWk9ed F1YOVAtDRU/KLoZAlvtArw4zg2SuF6GjAkxlp2g9/qQAbpSidFbtNrOtbAjUX2APPLpVhkRETMz8C +mxeUr7eZ0IwQUrfSObw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf0vw-00GgL4-8W; Mon, 25 Oct 2021 14:26:40 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf0vW-00GgFv-Np for linux-riscv@lists.infradead.org; Mon, 25 Oct 2021 14:26:17 +0000 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-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-256-1jK8OXHYMmutRCIVq3Aujg-1; Mon, 25 Oct 2021 10:26:12 -0400 X-MC-Unique: 1jK8OXHYMmutRCIVq3Aujg-1 Received: by mail-ed1-f71.google.com with SMTP id f21-20020a0564021e9500b003dd77985601so761668edf.9 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=M9IRp0n7pNeU0gUZm8VvQxlaa59Bk8HGsyoaoWxuZcz+JYCn3vghnnh/ZRQcGS1E0W +vCzLg8Brvg9mU3jErk/MVmb1OGfEMvDnFIoCF4Izqcpf6Yb2v4U7R9vL3NFDNAGhTRI 9O+7MARG4hvNM/NrRk51PpEqYQ3xgygeLbtZu5/Q+5ayJ6Y1v/7zk9hknppRU92xlBF5 Q2p/jLFebAx46/lu68pSK3wBcaI/iak4b0XjbnB8d94KpecwEEMMVlT7YvhrlrajCVR6 /a1ePwhLYxaYT1h0WSrNYQMRDzitGFaWNFNrQvIWDgAJEtf7bBT0W6HZaa1Z8weJSLuO N6Eg== X-Gm-Message-State: AOAM530YM64vavMKUEh5XZqiYWDrHMduC0oQPEzPo78J8eUEhOwtI/Bs U9Wj3B6Dd3VK4OiW+hbQL1uatcBUNVUA7nejIl0CqcZM4d0ea8hU6VYjU79JlRdcnriMfj3GjNH /WjPwSp4pVMyqC43KJQkiXl7fpFOh X-Received: by 2002:a17:906:c0cf:: with SMTP id bn15mr21819137ejb.54.1635171971317; Mon, 25 Oct 2021 07:26:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1tQyM0wVdwMUOMrIgmjrbrmjI7F4R9FGcgAmNEuZGC3NNZA+IU7BqgOO63yxAXGZ3HmbepA== 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 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> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211025_072614_861647_785BD342 X-CRM114-Status: UNSURE ( 8.41 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D897C433FE for ; Mon, 25 Oct 2021 14:26:19 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id BFCBE60EE3 for ; Mon, 25 Oct 2021 14:26:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BFCBE60EE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 44CEB4B129; Mon, 25 Oct 2021 10:26:18 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X19+MIqELS+R; Mon, 25 Oct 2021 10:26:16 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C2C194B08F; Mon, 25 Oct 2021 10:26:16 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 442F74B08A for ; Mon, 25 Oct 2021 10:26:15 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SyI2oFKl4IWK for ; Mon, 25 Oct 2021 10:26:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 0F6384ACC9 for ; Mon, 25 Oct 2021 10:26:13 -0400 (EDT) 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-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-74-JsOVj5fQP0WKqs5E4FRIhw-1; Mon, 25 Oct 2021 10:26:12 -0400 X-MC-Unique: JsOVj5fQP0WKqs5E4FRIhw-1 Received: by mail-ed1-f69.google.com with SMTP id j17-20020aa7ca51000000b003dd395c0389so5232856edt.4 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=0IakIjSOLlIVCIj9FArwigvaPUXFUUtcLom0azo8C44JnWZE0Y9c8LC8Rx+Osqe9Tf LLKH4Bi4ju9t2PNMjnJQjly5CPKOFd4/JN19U6KWjSz7y95Syl7FDwaWScfFwgWsGbcj ZIbkN1BR0c2J0C7KzskrfrENy+wIUshkw86OLzYQ2hUSlNHYaIVtQkDr2Fuzhj1+xhDu y6QQDwVaKYVw6RfwEH77FTq+KRA761WvN4epmiULsv961Y1Qwc/5puBU8qzVOTyw1kR0 KXDE8+bqsMn1TXEFMRwmVm8pQr1aAEh3JZ825syKXXEnMVzIn4fBb4v8gVsty6ChQeCu QokQ== X-Gm-Message-State: AOAM531LkETV1TzTAPz3JawRDdFWzFaddXau2ka2TXb63tAv7NvgU6r6 zkJzUPCei8eImmkGYGVKNLpuYnNJTvZQRbm4ZqYWPAeB6XHfmpRJuE42esnfiYXiR8QISEapDoH UCLoChYOzPWVO8Fg+/b5XDVQI X-Received: by 2002:a17:906:c0cf:: with SMTP id bn15mr21819130ejb.54.1635171971316; Mon, 25 Oct 2021 07:26:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1tQyM0wVdwMUOMrIgmjrbrmjI7F4R9FGcgAmNEuZGC3NNZA+IU7BqgOO63yxAXGZ3HmbepA== 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 To: Sean Christopherson , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank 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> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Cc: Wanpeng Li , kvm@vger.kernel.org, David Hildenbrand , linux-kernel@vger.kernel.org, Atish Patra , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Joerg Roedel , kvm-ppc@vger.kernel.org, David Matlack , linux-arm-kernel@lists.infradead.org, Jim Mattson , Cornelia Huck , linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, Vitaly Kuznetsov X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A3BEC433F5 for ; Mon, 25 Oct 2021 14:27:43 +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 C95B060EE3 for ; Mon, 25 Oct 2021 14:27:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C95B060EE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=akIIXzKYBhfx6KKtItD2Bbe4QOjkmpmtasRcUxhWZQY=; b=co81NVLNzSrAYJ ioU3spiZx/rmpkeGoquiorP5MuYuB5aHgT/fGpQ5jne0m+yw744ewCQYweLZYgSDhdYhrjLXgFwwF oP2g36Zx88ErXEG7LcP2ycdZPkzMfUxILxyQ7a1VqQV4paZcXjBMN22QIM03PyCRf5quLWEc4o8NB qv9d7YrlsrAtxXUytNhV/ll7Xbg1zj8iRugwY+huDqduSlwOkvmdBtbfKS92B3T+BwcfrWsO5+j/R Kb6llbDmI2hEa/W2u71+n73lppJ5ILFF4jujRii2aCU2pNEQtXC5n4l3xy5PXcZHf9kfjAlc8wzTs 5fz8CaYKSxrGt7aA6GeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf0vk-00GgJD-KC; Mon, 25 Oct 2021 14:26:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf0vW-00GgFt-LR for linux-arm-kernel@lists.infradead.org; Mon, 25 Oct 2021 14:26:15 +0000 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-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-204-b0VGioBrNLiRO1hFHXPlCQ-1; Mon, 25 Oct 2021 10:26:12 -0400 X-MC-Unique: b0VGioBrNLiRO1hFHXPlCQ-1 Received: by mail-ed1-f69.google.com with SMTP id x13-20020a05640226cd00b003dd4720703bso4122260edd.8 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=00WHc5kQg+blQGUU/3dCpCsjW0WP7YndofhWxwJSeA9nvh2BlzA+pwkqt9QkvUE+zO MLVBtZBpCAe5wzqiwjZePvtGXL7Q+xIzopjtmhQ5X2dG7/FRzjiLyKFrpjAM34aAtyR0 D/IaJlIYR5pkOtln6zaaMCCLICvupaNLJGgJvcPtCqGeddalboFha5tLB912PuS6Dp3T YYOsgQu+qFWoOYFXArOl+8E1NxbeG74JNWAtbfLKgRSywaZtCYybw0zswAAfgqTopYKl 0d7DLLGP0LF4XrG4sQF8zJtsMBSsUMRR2l0JsdB31HHhctRBLnkvbnWXMFfLgBKs+jIu WgOQ== X-Gm-Message-State: AOAM530iHE9H1BPoOK5MGS5bF9c6I6nklrj99mkPx2sD+yByEwQy60kg rg5+gPHispSHMS5W9hpehP1ubhhhudv0DD4H1rkNDvUyy6XeapSyrFaoAr6R4I8u6tDLh7jALEK yy6SRQFiGBgE385kuq9IqTdtAkZz5TjCcqHU= X-Received: by 2002:a17:906:c0cf:: with SMTP id bn15mr21819142ejb.54.1635171971318; Mon, 25 Oct 2021 07:26:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1tQyM0wVdwMUOMrIgmjrbrmjI7F4R9FGcgAmNEuZGC3NNZA+IU7BqgOO63yxAXGZ3HmbepA== 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 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> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211025_072614_807382_0D3D9DE5 X-CRM114-Status: UNSURE ( 9.94 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Date: Mon, 25 Oct 2021 14:26:08 +0000 Subject: Re: [PATCH v2 16/43] KVM: Don't redo ktime_get() when calculating halt-polling stop/deadline Message-Id: <0072221e-02e8-4d60-9b0f-80d8c423bf4e@redhat.com> List-Id: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-17-seanjc@google.com> In-Reply-To: <20211009021236.4122790-17-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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