Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4170259pxb; Mon, 27 Sep 2021 10:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE9KYdOmNqqTboAhWSFf0jn1kX4UyTJ9Kdm9MNAgIRWumu5V/hZLyBZHNZaNd3xtXK6/od X-Received: by 2002:a17:90b:1d05:: with SMTP id on5mr385542pjb.204.1632765010467; Mon, 27 Sep 2021 10:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632765010; cv=none; d=google.com; s=arc-20160816; b=CNIaNDSOfU93joexQxneH8kX075b5pq7CS3pwW2i+bu8BIf/ihbMAacdt2aVyQYy/G GEK9aMJiz0KpA3k39VutP5FyY7HTukeXLG1rwwoZ+JlOdEYa8XUYULvBD2zRfzR40gjK NSSz0qR03ed+lbTTw4PsHaSgAb2eQHazpPqVlogGcBjC+2PlgVw9uI0mrtPJRug+27s7 E1HfYhf8sbSvzdxykWZs05tlodjOvwwoyY/iKVkzlyqtw2vw4UgO5iH2fpqzXSeBpMov A2gP0POcZW3Wbv+Z/IWfQsKpHjcPtXpTTQNfn9asA0YaEpXPsGtrcVrU2M45Rbg/5HxY HNUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QVPOqaNlq7I3lDhzzEE0LSlmqb5BJv1DMZ8alEx/1nI=; b=rGdt9JGpQVLbAiSE8syA5A0Wx5faLhNlhTU9JKfFRUbFZXuMcrL8Y+hPJ2ze7tUsaG R5AifOT1KmmhfVR6yd/PPEkadoH5X/HkxfeyghU7pjKHwbHuUzdGM5HP0j9HjfJNoy/c GtFNR44vCetgBxRBX2qm0X+Y65ZSkQ3lpUW2xb4dKaBcBS/TwY8HcYSaQv5N194K5Nkh n70GiRjZU8E/LMC7psuSNRH3mDDywScU4rIjkNC/W0X4qPYMP8lIdZ2u1rmEXuNqUbkC h7zHRM8D0/uEOSeoQURId7quRs+xY3DNRve0GXpO9YekOMpXxOrDFGqXXSBNFuvMUQd8 nDpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=d285SG2v; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h193si21078743pgc.497.2021.09.27.10.49.57; Mon, 27 Sep 2021 10:50:10 -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=@google.com header.s=20210112 header.b=d285SG2v; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236995AbhI0Rrz (ORCPT + 99 others); Mon, 27 Sep 2021 13:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236679AbhI0Rrp (ORCPT ); Mon, 27 Sep 2021 13:47:45 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178ECC06176D for ; Mon, 27 Sep 2021 10:33:46 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id w11so12235595plz.13 for ; Mon, 27 Sep 2021 10:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QVPOqaNlq7I3lDhzzEE0LSlmqb5BJv1DMZ8alEx/1nI=; b=d285SG2vMoj7fWGLcc6kCiR/YbFmwFZ0r8FCUF/olwvOpdIeZoqHfRZvaCPNzDsw+I DXfTdpdYvY1o3+xwclpJFqsOx9rx8gXxXILEPFDMXqDFGp4BJoLLTpbwH1u1XP+r1Qam 5szAUX8Uoct9SyiacXSLIaEMZeN1EKkEAgcpyL12gNGSfsGKRyH2m+hvt+6VnU5P+65Q 0VTTYCcD9hk6ReQ9O9Swq7+ugPD0ecGhrBD3WfyuwTtr/uZVPNTBMwKAB7m8BgvxcC2+ 1ahXM7yNRUThnsg8QBfYfkaFmzHfumEXxhUu0VeZLeiCqPy+iDDU2pSUPBkNE2SVw6+C hGgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QVPOqaNlq7I3lDhzzEE0LSlmqb5BJv1DMZ8alEx/1nI=; b=TRyYTZCvkUExJ1wkwbdXjkoyNCikuLtyOHb6UzJUUiTOJbRYI0L4PNAbl9bgrCtsV2 aGsAlLiBdjjtBuwbjtSwK6F9I4BPURN2qi1/CIHABYeZveYz5bV6H5ueRmY4IarT/cv4 btgjwBmLX8iiZxMceXZ4dJe8ANEvVx9PM5lyMtzuQWG2LYf92CIoaptdm7cVDcyBtiga o9PyFnI5FuQ5RGOxFhiyZ19wq5IQeyAJyEjOreIr6i5rKm2FgHhV+YUhv3t4YK1ClM7f s6hzXGJpSIG7Au0jQ8Z/AkM079sg1YeISeZkScKaxCOt8SNqRURzLUSbhiM8h/bgo7ya DMJA== X-Gm-Message-State: AOAM532ht2NwknLmpoYgXeIwhZO5MsDZnFs21zg3qoNu76Wfin2lgHqo ILgH0I3faiFFVlHrAICqSqkzHw== X-Received: by 2002:a17:90b:224b:: with SMTP id hk11mr253513pjb.231.1632764025351; Mon, 27 Sep 2021 10:33:45 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id o17sm18385346pfp.126.2021.09.27.10.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 10:33:44 -0700 (PDT) Date: Mon, 27 Sep 2021 17:33:41 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: Christian Borntraeger , David Matlack , Jon Cargille , Jim Mattson , James Morse , Alexandru Elisei , Suzuki K Poulose , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , linux-arm-kernel , KVM ARM , "open list:MIPS" , kvm , kvm-ppc , "Kernel Mailing List, Linux" , Jing Zhang , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Janosch Frank Subject: Re: disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Message-ID: References: <20210925005528.1145584-1-seanjc@google.com> <03f2f5ab-e809-2ba5-bd98-3393c3b843d2@de.ibm.com> <43e42f5c-9d9f-9e8b-3a61-9a053a818250@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 27, 2021, Paolo Bonzini wrote: > On Mon, Sep 27, 2021 at 5:17 PM Christian Borntraeger > wrote: > > > So I think there are two possibilities that makes sense: > > > > > > * track what is using KVM_CAP_HALT_POLL, and make writes to halt_poll_ns follow that > > > > what about using halt_poll_ns for those VMs that did not uses KVM_CAP_HALT_POLL and the private number for those that did. > > Yes, that's what I meant. David pointed out that doesn't allow you to > disable halt polling altogether, but for that you can always ask each > VM's userspace one by one, or just not use KVM_CAP_HALT_POLL. (Also, I > don't know about Google's usecase, but mine was actually more about > using KVM_CAP_HALT_POLL to *disable* halt polling on some VMs!). I kinda like the idea if special-casing halt_poll_ns=0, e.g. for testing or in-the-field mitigation if halt-polling is broken. It'd be trivial to support, e.g. @@ -3304,19 +3304,23 @@ void kvm_vcpu_halt(struct kvm_vcpu *vcpu) update_halt_poll_stats(vcpu, start, poll_end, !waited); if (halt_poll_allowed) { + max_halt_poll_ns = vcpu->kvm->max_halt_poll_ns; + if (!max_halt_poll_ns || !halt_poll_ns) <------ squish the max if halt_poll_ns==0 + max_halt_poll_ns = halt_poll_ns; + if (!vcpu_valid_wakeup(vcpu)) { shrink_halt_poll_ns(vcpu); - } else if (vcpu->kvm->max_halt_poll_ns) { + } else if (max_halt_poll_ns) { if (halt_ns <= vcpu->halt_poll_ns) ; /* we had a long block, shrink polling */ else if (vcpu->halt_poll_ns && - halt_ns > vcpu->kvm->max_halt_poll_ns) + halt_ns > max_halt_poll_ns) shrink_halt_poll_ns(vcpu); /* we had a short halt and our poll time is too small */ - else if (vcpu->halt_poll_ns < vcpu->kvm->max_halt_poll_ns && - halt_ns < vcpu->kvm->max_halt_poll_ns) - grow_halt_poll_ns(vcpu); + else if (vcpu->halt_poll_ns < max_halt_poll_ns && + halt_ns < max_halt_poll_ns) + grow_halt_poll_ns(vcpu, max_halt_poll_ns); } else { vcpu->halt_poll_ns = 0; }