Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp277666iob; Mon, 2 May 2022 19:34:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYzguOSoJLWj1GHtAueS8LCf9DQAJWLytsrwIEJlNDSJQyYO7p9ox3Bsuu46iIgCcnAQEl X-Received: by 2002:a63:d50c:0:b0:39d:61df:ad7b with SMTP id c12-20020a63d50c000000b0039d61dfad7bmr12267295pgg.47.1651545250657; Mon, 02 May 2022 19:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651545250; cv=none; d=google.com; s=arc-20160816; b=Dzq0gsnk6TfMMn33MDg1YBkt/6zQmaRu7dkBrs8L5Y5vX0qbkq+TDL4qAXQgXCRJbX 5haZmeTaLN1x6tX8OJ6uGCLaIfR6Pr2sUiy+/GlCLj3Wp5znfn3n1uoWXfVTXXTmwgPV 62rwzcX5EJeDr0rpyFdEu/o3lKyNJiWj6Jdl+2vDGxUQLpNVq01S+Ra3Ors+NznwOg3f FD6FG5jDHNVRhUla8hibopbe5+RbER5auFjn9GHEpjjsXQuWQao+glillOKq2dIdgcZ2 t9YbJX+xIcQ/Xnd4T7CbhVv73MCIp1B/OyVlP35m+e+owyhefB8l7fWaWWRtyoyokAYO pIPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=V5k6/X+zm29OV2yPzgzM38kaPqodvTLQkw4ALvCcyZU=; b=DYIZIgvMiJz0Tr7VFcusCXhLNb2gkiGkwEQ1uuIQPFJ9nw//o0dYyuc2s8kv4LaaON oYIUBEqh9pqKEe2KotEvAT0pZJ3Twb8gxAkt65ZQfJ3FOZb6D4kwllazErMdUEBYjJx5 DvaslEzVhIBYERA8MMd3RXzwtvD8rW2X87gwmOyWUaZp+B8eBMPuFHvcQuDbl+/AaXzU yydRkvzMGYBiWzMQ+hPAu6qB2irlLcy00uGXq4AClXqcRX5TLXDh5Gtu/gxV+pVLDphU V9uq//HNUdpX4J0xoUhCDPs+IzjzOOkDerCiaLR4C1bthFs7iGDjGZ7T733x9O4/Y93a QnCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BD8ZuEts; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z11-20020a17090ab10b00b001c69ee187d0si860552pjq.171.2022.05.02.19.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 19:34:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BD8ZuEts; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CAD0C3616C; Mon, 2 May 2022 19:34:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbiECChc (ORCPT + 99 others); Mon, 2 May 2022 22:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbiECCh1 (ORCPT ); Mon, 2 May 2022 22:37:27 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 103D135DE4; Mon, 2 May 2022 19:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651545237; x=1683081237; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=WBUjd94GFESloMTPlC1yOxm2mtL52euUFtKl5bmWLdM=; b=BD8ZuEtshTqwIFD3b+ZMmM3kSI8aPZpKaoBeDIjJIg+ZjWxLIAwHGI0B qfPA/++ls+PUDMu4VA7ORMimlRvls8CievPCTHaxkjOK9OfNw5Wq/LAMH gKRaaawxUbGXIP9rUaZgnOZB2qUlz6E5skXmx4DDtUkv5vLNHXc7mGF2o uI4YXsByMxPPkbk1wwe+eo/L7SALbrAjydjMgKjU0khi9w6Pky+Hkajb1 iTNRrhh9qU6S20iiPn3rJ1Eu5daQC/i6J8YSwaH2URxr1qXbnMww+Ju21 cVx0Ec2tD2HVjnfgQdODmoTZfbfzdLUyAdUN3KCEEYiyaUmoDZwW38FmJ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10335"; a="249362984" X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="249362984" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 19:33:56 -0700 X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="584005365" Received: from zengguan-mobl1.ccr.corp.intel.com (HELO [10.252.188.134]) ([10.252.188.134]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 19:33:51 -0700 Message-ID: Date: Tue, 3 May 2022 10:33:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v9 8/9] KVM: x86: Allow userspace set maximum VCPU id for VM Content-Language: en-US To: Paolo Bonzini , "Christopherson,, Sean" , 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" Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "Hu, Robert" , "Gao, Chao" References: <20220419154444.11888-1-guang.zeng@intel.com> From: Zeng Guang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/3/2022 12:07 AM, Paolo Bonzini wrote: > On 4/19/22 17:44, Zeng Guang wrote: >> +Userspace is able to calculate the limit to APIC ID values from designated CPU >> +topology. This capability allows userspace to specify maximum possible APIC ID >> +assigned for current VM session prior to the creation of vCPUs. By design, it >> +can set only once and doesn't accept change any more. KVM will manage memory >> +allocation of VM-scope structures which depends on the value of APIC ID. >> + >> +Calling KVM_CHECK_EXTENSION for this capability returns the value of maximum APIC >> +ID that KVM supports at runtime. It sets as KVM_MAX_VCPU_IDS by default. > Better: > > This capability allows userspace to specify maximum possible APIC ID > assigned for current VM session prior to the creation of vCPUs, saving > memory for data structures indexed by the APIC ID. Userspace is able > to calculate the limit to APIC ID values from designated > CPU topology. > > The value can be changed only until KVM_ENABLE_CAP is set to a nonzero > value or until a vCPU is created. Upon creation of the first vCPU, > if the value was set to zero or KVM_ENABLE_CAP was not invoked, KVM > uses the return value of KVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPU_ID) as > the maximum APIC ID. > >> case KVM_CAP_MAX_VCPU_ID: >> - r = KVM_MAX_VCPU_IDS; >> + if (!kvm->arch.max_vcpu_ids) >> + r = KVM_MAX_VCPU_IDS; >> + else >> + r = kvm->arch.max_vcpu_ids; > I think returning the constant KVM_CAP_MAX_VCPU_IDS is better. > > Paolo Thanks. I will change as you suggested.