Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5007884pxb; Thu, 14 Oct 2021 16:59:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx49cWzLZfYajd41tr8nBJgVs6nduc5IDMY39yq30VoI7MD0ekVOUe3ItfaIv7t5S5de8cC X-Received: by 2002:a17:906:2c53:: with SMTP id f19mr2849817ejh.326.1634255945161; Thu, 14 Oct 2021 16:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634255945; cv=none; d=google.com; s=arc-20160816; b=0TCnGJW4E0ZyG+AW77jrQaegTjl3VhhbhbaWqjXcvwLbKIuohChzbxRVKGrybBmhXh 0K/IVqQbOmGKua8/dhXyA5m2RKPWQEvCzy4V/GD95QL9c6bq7FX3cim9bvspMCGnWQB0 BwjV5UR7pJEFcfAWb084FnQmOJggwKG5snGoI05rbv/vIE7md9LPALSdtFYoqRAc7sxT gGlmsQ0GL6cUgs6WjGiwAjN+lngTdXjM6lUIjYyxWf3CJ+V6a0Tq7PrONP3jlEqh2sOK 21cdEEpRRmKf71y7cSy7Lh4VLwzDQ3oVt4bwIddo+AG6fBt+dpsQFE/maFelSNJUqt3G IXHg== 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=3LreHgy6pHRdcseTPTu+FzR1hmJaWzkUvsg5FgfF3CA=; b=DYKE0RFr6H+hIsv0ah2FsMrxcSHOfSAJ50YBrBRmFDs0pzR7Tsz9xSJrvqWiv9+akb LONfaXKdU6HLjFnurywzFXC9oN+4ZSeGmKTvz56wxvqkyGp0BvxLD9C+q+TRzqIndAs2 CC6T+bF1nOUK/Sw4O/Yvhf296cdCBUTi1ubsI4reY9ntSZEim7Ua3W1rMdi+oc5YV0i7 W0VBdNmbGHHmhjfLv/gLWSfBzLoW3QzwVdRuTSJDVH0/YKvY07B2V/vN21ctosOxQUna zm90n7BTVrICVHj3fE+YMz3LlLd3vCJLreQMi6LlZEC6/dDyS1qqr8tDnTxBEOIsNcZQ vTnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GFz74yUs; 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 c12si7315996edx.280.2021.10.14.16.58.40; Thu, 14 Oct 2021 16:59: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=@google.com header.s=20210112 header.b=GFz74yUs; 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 S232461AbhJNS6r (ORCPT + 99 others); Thu, 14 Oct 2021 14:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbhJNS6p (ORCPT ); Thu, 14 Oct 2021 14:58:45 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5199C061570 for ; Thu, 14 Oct 2021 11:56:40 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id g5so4810923plg.1 for ; Thu, 14 Oct 2021 11:56:40 -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=3LreHgy6pHRdcseTPTu+FzR1hmJaWzkUvsg5FgfF3CA=; b=GFz74yUstAHcFh6DyYBis3Z+O3ExBYfbqiA8cVzf4trKTw/XAD6WldBEmIQtcXgJ8q JWbd/8AaVIeRFfX0xTH5WdB2TRI4Fg29XVuHnCDvS7Nut+QJftZFi5x/o2/+S6iBGz7m TyDNJ1vtFqhVeXjeOBCLtKI4NTzA+XyraoFVDxELUvFV9BHgawN6vrj7y5aa4oSwBsq7 BO5OaE2H2LtCbupNdTa7HNpF5N8PjvzJQtSF7V+MThKXCpzDEve66bvs/Lt0FwLAUQLw 6WHUEx7fHCC1rD/QVVdqffAJ+aOhtWF5IsNkZYmLgZiAlsh44KQgW+8nt12huSOGzqHd kWEQ== 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=3LreHgy6pHRdcseTPTu+FzR1hmJaWzkUvsg5FgfF3CA=; b=A//WD6UqWSSPYE5CdjFP8w+3IHuhoD1l4Ys9T4wHrUBAAV3g+x3/1wuiHBG7EpuyTG IwLH0zTGfVJFZbZXAL0JTM/fC33betT1/AwrTwUzhAlE5NjjPr5gGVjNaKUVAkdsB7xH W5wSNcX22bZcHsjY0wRPmljp+eLuHcMjskRNwRvKM03QEISWRugmL+TlK/jNKE8X40Oi 4DUCwgTcEDVW48NeYx7jUAldZb462MMLvyrd/u+M2cXV5HqIsp4pvWmfzFyzqP2jdyC2 I997qvln7WkwzCqOQaZ+X0YwXqoC3YzINkBDcPcQbSIEbNOVf9RnKD5A8r8ly58XlWQ2 ERhg== X-Gm-Message-State: AOAM532t20iWBoFX1K1pCLNzfV4PhbGru8PM4eJJRhdo2VemzZiHIxT4 nqoADp/ExkZlUtTzFJ7Si5NCmw== X-Received: by 2002:a17:90a:a581:: with SMTP id b1mr21972732pjq.21.1634237799882; Thu, 14 Oct 2021 11:56:39 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id u1sm2938419pje.47.2021.10.14.11.56.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 11:56:39 -0700 (PDT) Date: Thu, 14 Oct 2021 18:56:35 +0000 From: Sean Christopherson To: Zeng Guang Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , "kvm@vger.kernel.org" , Dave Hansen , "Luck, Tony" , Kan Liang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Kim Phillips , Jarkko Sakkinen , Jethro Beekman , "Huang, Kai" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "Hu, Robert" , "Gao, Chao" Subject: Re: [PATCH v4 6/6] KVM: VMX: enable IPI virtualization Message-ID: References: <20210809032925.3548-1-guang.zeng@intel.com> <20210809032925.3548-7-guang.zeng@intel.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 Sat, Sep 18, 2021, Zeng Guang wrote: > On 9/11/2021 7:55 AM, Sean Christopherson wrote: > > On Fri, Sep 10, 2021, Sean Christopherson wrote: > > > On Mon, Aug 09, 2021, Zeng Guang wrote: > > > > + if (!pages) > > > > + return -ENOMEM; > > > > + > > > > + to_kvm_vmx(kvm)->pid_table = (void *)page_address(pages); > > > > + to_kvm_vmx(kvm)->pid_last_index = KVM_MAX_VCPU_ID; > > > I don't see the point of pid_last_index if we're hardcoding it to KVM_MAX_VCPU_ID. > > > If I understand the ucode pseudocode, there's no performance hit in the happy > > > case, i.e. it only guards against out-of-bounds accesses. > > > > > > And I wonder if we want to fail the build if this grows beyond an order-1 > > > allocation, e.g. > > > > > > BUILD_BUG_ON(PID_TABLE_ORDER > 1); > > > > > > Allocating two pages per VM isn't terrible, but 4+ starts to get painful when > > > considering the fact that most VMs aren't going to need more than one page. For > > > now I agree the simplicity of not dynamically growing the table is worth burning > > > a page. > > Ugh, Paolo has queued a series which bumps KVM_MAX_VCPU_ID to 4096[*]. That makes > > this an order-3 allocation, which is quite painful. One thought would be to let > > userspace declare the max vCPU it wants to create, not sure if that would work for > > xAPIC though. > > > > [*] https://lkml.kernel.org/r/1111efc8-b32f-bd50-2c0f-4c6f506b544b@redhat.com > Thus we keep current design as no change. Not necessarily. I was pointing out that the current design is already problematic from a memory allocation perspective. Burning a few pages per vCPU isn't the end of the world, but 32kb of _contiguous_ memory is rough, especially when 28kb is unlikely to be used in many cases.