Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp889166pxb; Wed, 27 Oct 2021 14:31:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzcJ8RCI8bIIef2MOkkaULV2rky1sASdgSMArDehjY0f86l2MotX5L0aeDhEq0mNYQ6XPx X-Received: by 2002:a17:906:6a21:: with SMTP id qw33mr98089ejc.560.1635370205636; Wed, 27 Oct 2021 14:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370205; cv=none; d=google.com; s=arc-20160816; b=pRCv7Ukc2hvxQbqvhf74v8GhrDDTiO1+dx9g9OW3QuRf8h/M0L2/3ekuxCJkwG1FMT BoWH1AzaPNK9m5R/uJ4kDiwpwhyFGrSaak+LVyjUVesexv+IoyeRRQYqHSGjWfG/9gR9 00tmAsPRXL+4CknSfXhvCYTcIN7BYwWQEUsN0kvBCC1QaAHuEQGLezyZ1mT5KxSv65Gc fQnqqXDvZ4P7O7II5bwa1d/jFMVCRQzItq9pLIM4mkvYDMj+x/233cTNxVBANlw33JBu Szhi+uBrG3imZaK9G3XjQ0/tvqIkLUPNppSwf+vjuBuOjl9FHxFW/oSu3fj+TGpYGTCC 0lbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=0gXXVZ1M1SPzD/8mviUXXiKMlrNVIcsqsHOKxhlwRek=; b=NN/kS9E+3jOO8hgSrugNB7aIYvhcE3Wh9RNXH7UpF26Fms7s+JpO29hApQFs7VJlgy HUVrO8JhMiu7hXaxwu13E/Ls/YnbUdLQNmOnB1PPdtfABSS4LS4jbggsVDSX0uWm+D01 q1yHzMLbk2azYkO0ntZKICCy1FTAio09QuMjQ8tFz2zTt0LNnBR1cnUw9D5bN5F5PaAS i4R4aFfxkAoPubHqhJF6gb0TSdS7LUEnXk/SkZcxq0/vhv3yC0VjwEqbEhftRchWgn7u C70+SkEEuD5SApgmCqsrEfWCRDt/6nCRDDaiZPZo4/vtYfbdbWZ0A2sWbiG7sNwwJrec x3jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=c4F+9GIt; 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 h15si1234556ejj.98.2021.10.27.14.29.40; Wed, 27 Oct 2021 14:30:05 -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=c4F+9GIt; 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 S237738AbhJ0OjR (ORCPT + 97 others); Wed, 27 Oct 2021 10:39:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47690 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238800AbhJ0OjQ (ORCPT ); Wed, 27 Oct 2021 10:39:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635345410; 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=0gXXVZ1M1SPzD/8mviUXXiKMlrNVIcsqsHOKxhlwRek=; b=c4F+9GIthu5ISpXu3Nm2pmZ/veI+Hq1JYJWG1+Eh9JjFtthMAsuzAdi585aR4TosBzppBa 1pdyaOJsfWTwOxT9C96H8Z7e+EDVAB4MHTvsVIjqaNu29Md1CeLZqs3ckV4JiXvTD7rTJQ m71vTaLzaMK+EnDIS7DpxH2KvOudwjU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-UU3N_ykSOO6SiL7u12Utfg-1; Wed, 27 Oct 2021 10:36:46 -0400 X-MC-Unique: UU3N_ykSOO6SiL7u12Utfg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1095C112C391; Wed, 27 Oct 2021 14:35:56 +0000 (UTC) Received: from starship (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83585794A9; Wed, 27 Oct 2021 14:35:46 +0000 (UTC) Message-ID: <3a0c3397302d59ea313e079435a18bf1b9a43474.camel@redhat.com> Subject: Re: [PATCH v2 16/43] KVM: Don't redo ktime_get() when calculating halt-polling stop/deadline From: Maxim Levitsky To: Paolo Bonzini , 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 Date: Wed, 27 Oct 2021 17:35:45 +0300 In-Reply-To: <0072221e-02e8-4d60-9b0f-80d8c423bf4e@redhat.com> References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-17-seanjc@google.com> <0072221e-02e8-4d60-9b0f-80d8c423bf4e@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-10-25 at 16:26 +0200, Paolo Bonzini wrote: > 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 > Agreed. Reviewed-by: Maxim Levitsky