Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp923727ybp; Thu, 17 Oct 2019 05:40:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6O8mhIEeHtSOOyxfqshnBLBxhcoPE7Zk6mJFbRt1MxRWY2z8zrgNWme3sVSDX79MF1OW/ X-Received: by 2002:a50:f395:: with SMTP id g21mr3420865edm.223.1571316024040; Thu, 17 Oct 2019 05:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571316024; cv=none; d=google.com; s=arc-20160816; b=Z/BOfn4xl/TL5pVVGThvSwpluyVh8iJheEuEhL8qQUVdB+WHslPZT5/5PhQTfChdaJ tm4PSlH8/1IrXmua+TcONFZl/WwFpT7ctuSqsZAh6WyPFxRyBcVIybf9fzEQzKFCqJ7a C9v+2TP+b13mwLtOHuNGFFiHWESAsCiZO5pDnxAe2f1+zWurF5+ugr8tjfpcsmKhGoEY euJ9LxcRLCmN7ea+208Svx/Azs/ml4JOjs35bcr7xpqbs+lllyBsKY866C2ruTBWmB+i bmUKohwoyKE3bp6AIJox8BoG9x67T5dxw02ylkd0KeuPlg+OJ6b4r/AE/AieZ1LIxwjg PqEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=upYwB/N4xOr/Zf5KHa95URT+5bIQEUVNJJQrCk7v8M8=; b=tozdH3TBNgjH9glLU6jsO/gZULL7va6tFHl+4W6DlZ1JErdMmaBzukXtWbs8gW3rmA 3gBu6svoXiyVfyPdMGI8jUKL0np1TVgUQisZnQDGZPreXlQALhJG0mgaazZQbQiSYrPg 1UHRjt/iqMmZTnwqOF80CIWRM7Q+UGb2yi6nMExIg6urBV8WcNw+ocGl/8HumR/hStaC t9RUjfoGzvXz+vu3vhA+rrtdgpwrQz0rJc5AYOFZ2dps37blnQwk11jtgFtP2xrDx/qo JaYtzMjM+S04DhsNgAGr7yKwK1JvvBnDamlrXNoqmEVpY9+ny0zMg6RWZn4T0DIo4sb3 M0Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b56si1462139edb.418.2019.10.17.05.40.01; Thu, 17 Oct 2019 05:40:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406563AbfJPRB1 (ORCPT + 99 others); Wed, 16 Oct 2019 13:01:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45608 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406545AbfJPRB1 (ORCPT ); Wed, 16 Oct 2019 13:01:27 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D0457FDF6 for ; Wed, 16 Oct 2019 17:01:26 +0000 (UTC) Received: by mail-wr1-f70.google.com with SMTP id j7so12048544wrx.14 for ; Wed, 16 Oct 2019 10:01:26 -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:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=upYwB/N4xOr/Zf5KHa95URT+5bIQEUVNJJQrCk7v8M8=; b=iXH475cr5wlwzmbU88FIx4i0VtrKkSgjdi42Dg20+BdWYilbuBgU2FFgd9Xo+4dveE lvWtpNDSf61lhsHIjwFGuaN9CYEwqPkJbplIz+m0uQ/GraNaSrAzhu80ZRVN1U+udnbg Xb6mOS3pV/H1X9tdEfL69329WVXKWkwPTLHThYeQGzwnaVspVObokCttbJbFHKd6i4w/ ycC06BZ0iJ5vWDk2kAp5BwXpvqPpDtTyn6egsypvh00kMZdEOHyP1kMlWKjI4SU7DJf+ 9bQcng+/FXW6BhFrdBvgGVyqEau/ZYfeq3pB5biDdEnMjjAvZE/6dSuru4+roFNWTMYo 2V3w== X-Gm-Message-State: APjAAAXaPyLn2gR3v5xuU82IVkH1GPi71n/GHcgka5uXqAHmm8/66Cno p0Iws0BSqIb1qgBlG2syLAJLtFnBoDcBJ6Y4Uc9lUEWFfY/39xlZrinpfQ6+p6jQ/lg/kySQDOu uOM5Z4dSad45r5SIkJvneS4yY X-Received: by 2002:adf:e488:: with SMTP id i8mr3608234wrm.302.1571245285026; Wed, 16 Oct 2019 10:01:25 -0700 (PDT) X-Received: by 2002:adf:e488:: with SMTP id i8mr3608206wrm.302.1571245284676; Wed, 16 Oct 2019 10:01:24 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:d001:591b:c73b:6c41? ([2001:b07:6468:f312:d001:591b:c73b:6c41]) by smtp.gmail.com with ESMTPSA id v6sm4038429wma.24.2019.10.16.10.01.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Oct 2019 10:01:24 -0700 (PDT) Subject: Re: [PATCH 12/14] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers To: Andrea Arcangeli Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Vitaly Kuznetsov , Sean Christopherson References: <20190928172323.14663-1-aarcange@redhat.com> <20190928172323.14663-13-aarcange@redhat.com> <933ca564-973d-645e-fe9c-9afb64edba5b@redhat.com> <20191015164952.GE331@redhat.com> <870aaaf3-7a52-f91a-c5f3-fd3c7276a5d9@redhat.com> <20191015203516.GF331@redhat.com> <20191015234229.GC6487@redhat.com> <27cc0d6b-6bd7-fcaf-10b4-37bb566871f8@redhat.com> <20191016165057.GJ6487@redhat.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <0e290a9d-9d26-d24a-ba01-9fda4826a5ac@redhat.com> Date: Wed, 16 Oct 2019 19:01:25 +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: <20191016165057.GJ6487@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/10/19 18:50, Andrea Arcangeli wrote: >> It still doesn't add up. 0.3ms / 5 is 1/15000th of a second; 43us is >> 1/25000th of a second. Do you have multiple vCPU perhaps? > > Why would I run any test on UP guests? Rather then spending time doing > the math on my results, it's probably quicker that you run it yourself: I don't know, but if you don't say how many vCPUs you have, I cannot do the math and review the patch. >> The number of vmexits doesn't count (for HLT). What counts is how long >> they take to be serviced, and as long as it's 1us or more the >> optimization is pointless. > > Please note the single_task_running() check which immediately breaks > the kvm_vcpu_check_block() loop if there's even a single other task > that can be scheduled in the runqueue of the host CPU. > > What happen when the host is not idle is quoted below: > > w/o optimization with optimization > ---------------------- ------------------------- > 0us vmexit vmexit > 500ns retpoline call vmexit handler directly > 600ns retpoline kvm_vcpu_check_block() > 700ns retpoline schedule() > 800ns kvm_vcpu_check_block() > 900ns schedule() > ... > > Disclaimer: the numbers on the left are arbitrary and I just cut and > pasted them from yours, no idea how far off they are. Yes, of course. But the idea is the same: yes, because of the retpoline you run the guest for perhaps 300ns more before schedule()ing, but does that really matter? 300ns * 20000 times/second is a 0.6% performance impact, and 300ns is already very generous. I am not sure it would be measurable at all. Paolo > To be clear, I would find it very reasonable to be requested to proof > the benefit of the HLT optimization with benchmarks specifics for that > single one liner, but until then, the idea that we can drop the > retpoline optimization from the HLT vmexit by just thinking about it, > still doesn't make sense to me, because by thinking about it I come to > the opposite conclusion. > > The lack of single_task_running() in the guest driver is also why the > guest cpuidle haltpoll risks to waste some CPU with host overcommit or > with the host loaded at full capacity and why we may not assume it to > be universally enabled. > > Thanks, > Andrea >