From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751240AbdEaPGu (ORCPT ); Wed, 31 May 2017 11:06:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52718 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751000AbdEaPGs (ORCPT ); Wed, 31 May 2017 11:06:48 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D07E880048 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vkuznets@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D07E880048 From: Vitaly Kuznetsov To: Jork Loeser Cc: "x86\@kernel.org" , "devel\@linuxdriverproject.org" , "linux-kernel\@vger.kernel.org" , "KY Srinivasan" , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Steven Rostedt , Simon Xiao , Andy Lutomirski , Andy Shevchenko Subject: Re: [PATCH v5 09/10] x86/hyper-v: support extended CPU ranges for TLB flush hypercalls References: <20170530113424.15687-1-vkuznets@redhat.com> <20170530113424.15687-10-vkuznets@redhat.com> Date: Wed, 31 May 2017 17:06:38 +0200 In-Reply-To: (Jork Loeser's message of "Tue, 30 May 2017 19:13:23 +0000") Message-ID: <8737bl12wx.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 May 2017 15:06:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jork Loeser writes: >> -----Original Message----- >> From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com] >> Sent: Tuesday, May 30, 2017 04:34 >> To: x86@kernel.org; devel@linuxdriverproject.org >> Cc: linux-kernel@vger.kernel.org; KY Srinivasan ; Haiyang >> Zhang ; Stephen Hemminger >> ; Thomas Gleixner ; Ingo >> Molnar ; H. Peter Anvin ; Steven >> Rostedt ; Jork Loeser ; >> Simon Xiao ; Andy Lutomirski ; Andy >> Shevchenko >> Subject: [PATCH v5 09/10] x86/hyper-v: support extended CPU ranges for TLB >> flush hypercalls >> >> Hyper-V hosts may support more than 64 vCPUs, we need to use >> HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX/LIST_EX hypercalls in this case. > >> +static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex *flush, >> + const struct cpumask *cpus) >> +{ >> + int cpu, vcpu, vcpu_bank, vcpu_offset, cur_bank, nr_bank = 0; >> + bool has_cpus; >> + >> + /* >> + * We can't be sure that translated vCPU numbers will always be >> + * in ascending order, so iterate over all possible banks and >> + * check all vCPUs in it instead. >> + */ >> + for (cur_bank = 0; cur_bank < ms_hyperv.max_vp_index/64; >> cur_bank++) { >> + has_cpus = false; >> + for_each_cpu(cpu, cpus) { >> + vcpu = hv_cpu_number_to_vp_number(cpu); >> + vcpu_bank = vcpu / 64; >> + vcpu_offset = vcpu % 64; >> + >> + if (vcpu_bank != cur_bank) >> + continue; >> + __set_bit(vcpu_offset, (unsigned long *) >> + &flush->hv_vp_set.bank_contents[nr_bank]); >> + if (!has_cpus) { >> + __set_bit(vcpu_bank, (unsigned long *) >> + &flush->hv_vp_set.valid_bank_mask); >> + has_cpus = true; >> + } >> + } >> + if (has_cpus) >> + nr_bank++; >> + } >> + >> + return nr_bank; >> +} > > Note that the HV_VP_SET may contain empty banks. As such, consider > enabling all (5) bits in the valid_bank_mask, and a single > for_each(cpu, cpus) pass - setting the bits as per > hv_cpu_number_to_vp_number(cpu). > Oh, I didn't know that! I'll switch to doing a single pass. Unfortunately I have no Hyper-V setup with > 64 vCPUs so I can't really test if it works or not (I mean empty banks, *_EX hypercalls work). -- Vitaly