Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3344657ioa; Tue, 26 Apr 2022 01:40:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWklrqskh7oMiZ9Yi0HIH8+riXxkWIBYRsmZlVbhnSxJK20XB9Jr0AHOkreIKpzSvxNTgi X-Received: by 2002:a17:906:3c09:b0:6f3:9aff:e1a0 with SMTP id h9-20020a1709063c0900b006f39affe1a0mr7374109ejg.453.1650962411884; Tue, 26 Apr 2022 01:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650962411; cv=none; d=google.com; s=arc-20160816; b=Hdtdf9xcQJ48YLsELav69Eyve0mcXFP54tq6MvdAvaJRv1I2HfZvPtL2ll6SyEm5JE J9IPt3lNfYElnhTFjv1DXMadhkdUQ3qPQeGWFEol/wN3rW0S3U0G8zYT+0BrNa0D8h4p XMYNCYZICCH2uBOOgWIFbaStY9RZNzOOCQ8esmCTandQyoNg9uvpsoOCKrl5z7BwgkN3 3K7ji482UdSP8n+rF92CUI4OFx7MMBnQuplfHWnVGSa2YsfOa8Drasi/JeYt1dhpm8wo iRVQk+KvUbzqP2RbnNpaM0sh1JySNsL/tkO0fD6g+f0IhgkdBufYBHZmLL+5N6QB0aY7 NWVA== 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; bh=cBpdPQJ7wszPSXm9zoUkYMS/1hvm3QA6jlS+0ipL0V0=; b=aFgXHLyTNO+1M4xIEM5dgzriEdMt/vqjJ1bkrk3zEAi0cgsnsTYSehtxKiSkyiRJ0D 0MfasW6hSSQUiz0heSQ7Yn9KgnBtBN2+L0HJ1EiNFoDzwI2ZgF8JtO/H8Wv/DmxSAEBn tlKCIBrXbl1AqC1ZdfBl2b8b5E9Dl4NpjZGFeZLX4IDwDZ0rZG+vANdO4wFR3nrC9TH5 eDUuCZDORHGH+uEW3xTjtgnXzbQEOBzoqSnWWaax/v4nMUxaKyBDoSbKh9IgA3KSHMQM kvv55/6RmOvoIG/T7m7eCFTkI4+exW3UqWGAcC12uaFUzVfUG+XulQH78G/Ba2Ec1XdE 7teA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v20-20020a056402349400b00423fb5cb330si17262539edc.187.2022.04.26.01.39.48; Tue, 26 Apr 2022 01:40:11 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244895AbiDYTTc (ORCPT + 99 others); Mon, 25 Apr 2022 15:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbiDYTTa (ORCPT ); Mon, 25 Apr 2022 15:19:30 -0400 Received: from smtp.smtpout.orange.fr (smtp07.smtpout.orange.fr [80.12.242.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16DA6387BB for ; Mon, 25 Apr 2022 12:16:16 -0700 (PDT) Received: from [192.168.1.18] ([86.243.180.246]) by smtp.orange.fr with ESMTPA id j4BrnYRN3jXpHj4BrnJm6d; Mon, 25 Apr 2022 21:16:15 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Mon, 25 Apr 2022 21:16:15 +0200 X-ME-IP: 86.243.180.246 Message-ID: <19a812b3-73b4-7e5a-8885-ec652598a5ce@wanadoo.fr> Date: Mon, 25 Apr 2022 21:16:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 07/34] x86/hyperv: Introduce HV_MAX_SPARSE_VCPU_BANKS/HV_VCPUS_PER_SPARSE_BANK constants Content-Language: fr To: Vitaly Kuznetsov , kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220414132013.1588929-1-vkuznets@redhat.com> <20220414132013.1588929-8-vkuznets@redhat.com> From: Christophe JAILLET In-Reply-To: <20220414132013.1588929-8-vkuznets@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Le 14/04/2022 à 15:19, Vitaly Kuznetsov a écrit : > It may not come clear from where the magical '64' value used in > __cpumask_to_vpset() come from. Moreover, '64' means both the maximum > sparse bank number as well as the number of vCPUs per bank. Add defines > to make things clear. These defines are also going to be used by KVM. > > No functional change. > > Signed-off-by: Vitaly Kuznetsov > --- > include/asm-generic/hyperv-tlfs.h | 5 +++++ > include/asm-generic/mshyperv.h | 11 ++++++----- > 2 files changed, 11 insertions(+), 5 deletions(-) > > diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h > index fdce7a4cfc6f..020ca9bdbb79 100644 > --- a/include/asm-generic/hyperv-tlfs.h > +++ b/include/asm-generic/hyperv-tlfs.h > @@ -399,6 +399,11 @@ struct hv_vpset { > u64 bank_contents[]; > } __packed; > > +/* The maximum number of sparse vCPU banks which can be encoded by 'struct hv_vpset' */ > +#define HV_MAX_SPARSE_VCPU_BANKS (64) > +/* The number of vCPUs in one sparse bank */ > +#define HV_VCPUS_PER_SPARSE_BANK (64) > + > /* HvCallSendSyntheticClusterIpi hypercall */ > struct hv_send_ipi { > u32 vector; > diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h > index c08758b6b364..0abe91df1ef6 100644 > --- a/include/asm-generic/mshyperv.h > +++ b/include/asm-generic/mshyperv.h > @@ -214,9 +214,10 @@ static inline int __cpumask_to_vpset(struct hv_vpset *vpset, > { > int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1; > int this_cpu = smp_processor_id(); > + int max_vcpu_bank = hv_max_vp_index / HV_VCPUS_PER_SPARSE_BANK; > > - /* valid_bank_mask can represent up to 64 banks */ > - if (hv_max_vp_index / 64 >= 64) > + /* vpset.valid_bank_mask can represent up to HV_MAX_SPARSE_VCPU_BANKS banks */ > + if (max_vcpu_bank >= HV_MAX_SPARSE_VCPU_BANKS) > return 0; > > /* > @@ -224,7 +225,7 @@ static inline int __cpumask_to_vpset(struct hv_vpset *vpset, > * structs are not cleared between calls, we risk flushing unneeded > * vCPUs otherwise. > */ > - for (vcpu_bank = 0; vcpu_bank <= hv_max_vp_index / 64; vcpu_bank++) > + for (vcpu_bank = 0; vcpu_bank <= max_vcpu_bank; vcpu_bank++) > vpset->bank_contents[vcpu_bank] = 0; and here: bitmap_clear(vpset->bank_contents, 0, hv_max_vp_index); or maybe even if it is safe to do so: bitmap_zero(vpset->bank_contents, hv_max_vp_index); CJ > > /* > @@ -236,8 +237,8 @@ static inline int __cpumask_to_vpset(struct hv_vpset *vpset, > vcpu = hv_cpu_number_to_vp_number(cpu); > if (vcpu == VP_INVAL) > return -1; > - vcpu_bank = vcpu / 64; > - vcpu_offset = vcpu % 64; > + vcpu_bank = vcpu / HV_VCPUS_PER_SPARSE_BANK; > + vcpu_offset = vcpu % HV_VCPUS_PER_SPARSE_BANK; > __set_bit(vcpu_offset, (unsigned long *) > &vpset->bank_contents[vcpu_bank]); > if (vcpu_bank >= nr_bank)