Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2235493pxb; Thu, 3 Feb 2022 02:17:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdqxoKQJiiAdHCwpsL/3nlICj7ewcXwrH5Ny5uEbAixsIGJlm79OMg2JuXufNb1CoCjcnm X-Received: by 2002:a17:907:6e05:: with SMTP id sd5mr28290116ejc.170.1643883439274; Thu, 03 Feb 2022 02:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643883439; cv=none; d=google.com; s=arc-20160816; b=MxKcBhcOZ4oou3GushJX/xN+HAQVv5Bf2QNw0oaoGj10yBQbDHAZctQCJDypVxRSqu c0mpmfj4c59tg++05ZIeEvyOFaP2QXvIPOH+lcqTrrYzdJ8OOo0H8AV/vEvDigS6bU2r hdm33yyVbo3OAz5DSHC8LOqar74grVZhh7Vaqaj/SxFHMMg1tdhIN6551gkegGzbZyhq 5ZsAno7rbKYqAYsP06vKQpG95bPQFixmpeCYx5fRwYZoHRfsX7qGmsppihIk/uSotym0 4dGBQEY3eBMkmarmo0w/Ba3Zp8uis10HFDdGhp+TaLlOKRfYfM6OpS54YU47SSLjFd4R 6SHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gmPaQg3ZV/NzjWszRhN/vx7xYoj6dJ6Nz9nhp20TkY0=; b=yx9flKT9c+IDHhFvdqKTb9+8lTebcQsvBDUnrTVqeYt0lbE3r+9ihkkk51Kqr7aGzp M4kvyTSjU5YXFrUHno/qs7kiQFdsGwJr2VA0/fuDFWcfRhydSqky9/nEYPeFAhm1mLVB 6xnRRjDpHThHwSQvOjSjodHJXSF6koqvmozS3RfeNuSFeAbPAE+mX9u87KvzvD0tsPUS tp+LrFuLmxn9R5yjQOYtZerZ389bwJ3n70Pvpb0Z0Obi2NNYyuTHyUbyTyqjal+IOYaW G5LvO7Mnx/e0uBpKVXY7x16JPRdoQ0LZkuJ4/SVCHHrLTT+AZkAXMlCjghLuMxnJHlGN V+YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kxws1Bm7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd3si11534125ejc.915.2022.02.03.02.16.54; Thu, 03 Feb 2022 02:17:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kxws1Bm7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238958AbiBAN5c (ORCPT + 99 others); Tue, 1 Feb 2022 08:57:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237337AbiBAN5a (ORCPT ); Tue, 1 Feb 2022 08:57:30 -0500 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964AFC061714; Tue, 1 Feb 2022 05:57:30 -0800 (PST) Received: by mail-yb1-xb31.google.com with SMTP id r65so51086903ybc.11; Tue, 01 Feb 2022 05:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gmPaQg3ZV/NzjWszRhN/vx7xYoj6dJ6Nz9nhp20TkY0=; b=kxws1Bm7isRqI/ht4fr4+gcveANEX49JWqnYr8dQe7mNzd+IDdPb5AmSwscJwZ6Ona qbIhviualk8JNHmt5RwpviIdNsuOAJxoQ3Gcs7UJnuzqiB9XPwUAZeJSv21PCc9/JLQn WtHo1LKNcmbc/M90TAUUx7pBQ4Zw1pkjUOoOJ25sjwYonIGGXCtXcbT74gfw8o406Eg+ UyvxoAEQNjK2yATWp0pn+c7uIynv/ohql2a3DY1H2g9DdhquMvJV3JlMlQODBYDmhrP9 RCGAaVGOjY56g0NQtBx2iHYGBp/qv6t4aGaAe1hI3b1sxTQLt2rm6oWtcHN3R89dLHl6 R4Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gmPaQg3ZV/NzjWszRhN/vx7xYoj6dJ6Nz9nhp20TkY0=; b=2+NmE9aQeDCRgteaPZL37+O0vbmefkgEguml+afe7rm0BWAo+pFxHaIkZureURBFYV oYXpdfqLAPjEyFMirpE0MEiLIK7PV+haEuJ8cFxpLSFYJ/y+5iKpljNSssq5Q83+UXYg EiiZtZ9NjJC1SMjqnFfYcA1tuYY/2+CZcqEO5r1YqB8Chn1ET77QF8wsJCsMaP9BnRdt Vb7xJEFGVeKr3+760kjp1Rat5JpLArejaWonmpp99kMhneKDm+/8CyXtvB41oWD/2V0q MBkhKufJdQQ9UUk8De45SMbSwygVtW5tD1OVp288lgA2RuOMUtaLazfKXM3A31r6y15e fRPg== X-Gm-Message-State: AOAM532J0IaQyr5fBdhVOGGkhJ3JO7+6hTJRbg0sSSQG8p+KYmt2kEoU 0JFIzbUYMFGEHBX4D74usX9/FwP+CNVZIax0dD8= X-Received: by 2002:a25:b88:: with SMTP id 130mr34680074ybl.199.1643723849842; Tue, 01 Feb 2022 05:57:29 -0800 (PST) MIME-Version: 1.0 References: <1643112538-36743-1-git-send-email-wanpengli@tencent.com> In-Reply-To: From: Wanpeng Li Date: Tue, 1 Feb 2022 21:57:19 +0800 Message-ID: Subject: Re: [PATCH RESEND v2] KVM: LAPIC: Enable timer posted-interrupt when mwait/hlt is advertised To: Paolo Bonzini Cc: LKML , kvm , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Aili Yao Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 1 Feb 2022 at 20:11, Paolo Bonzini wrote: > > On 1/25/22 13:08, Wanpeng Li wrote: > > As commit 0c5f81dad46 (KVM: LAPIC: Inject timer interrupt via posted interrupt) > > mentioned that the host admin should well tune the guest setup, so that vCPUs > > are placed on isolated pCPUs, and with several pCPUs surplus for*busy* housekeeping. > > It is better to disable mwait/hlt/pause vmexits to keep the vCPUs in non-root > > mode. However, we may isolate pCPUs for other purpose like DPDK or we can make > > some guests isolated and others not, we may lose vmx preemption timer/timer fastpath > > due to not well tuned setup, and the checking in kvm_can_post_timer_interrupt() > > is not enough. Let's guarantee mwait/hlt is advertised before enabling posted-interrupt > > interrupt. vmx preemption timer/timer fastpath can continue to work if both of them > > are not advertised. > > Is this the same thing that you meant? > > -------- > As commit 0c5f81dad46 ("KVM: LAPIC: Inject timer interrupt via posted interrupt") > mentioned that the host admin should well tune the guest setup, so that vCPUs > are placed on isolated pCPUs, and with several pCPUs surplus for *busy* housekeeping. > In this setup, it is preferrable to disable mwait/hlt/pause vmexits to > keep the vCPUs in non-root mode. > > However, if only some guests isolated and others not, they would not have > any benefit from posted timer interrupts, and at the same time lose > VMX preemption timer fast paths because kvm_can_post_timer_interrupt() > returns true and therefore forces kvm_can_use_hv_timer() to false. > > By guaranteeing that posted-interrupt timer is only used if MWAIT or HLT > are done without vmexit, KVM can make a better choice and use the > VMX preemption timer and the corresponding fast paths. > -------- Looks better, thanks Paolo! :) Wanpeng