From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752078AbbIOMyz (ORCPT ); Tue, 15 Sep 2015 08:54:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48097 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751558AbbIOMyy (ORCPT ); Tue, 15 Sep 2015 08:54:54 -0400 Subject: Re: [PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid To: Wanpeng Li References: <1442313034-14243-1-git-send-email-wanpeng.li@hotmail.com> Cc: Jan Kiszka , Bandan Das , Wincy Van , kvm@vger.kernel.org, linux-kernel@vger.kernel.org From: Paolo Bonzini Message-ID: <55F81515.8090405@redhat.com> Date: Tue, 15 Sep 2015 14:54:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/09/2015 12:30, Wanpeng Li wrote: > + if (!nested) { > + vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS); > + if (vpid < VMX_NR_VPIDS) { > vmx->vpid = vpid; > __set_bit(vpid, vmx_vpid_bitmap); > + } > + } else { > + vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS); > + if (vpid < VMX_NR_VPIDS) { > + vmx->nested.vpid02 = vpid; > + __set_bit(vpid, vmx_vpid_bitmap); > + } Messy indentation, and a lot of duplicate code. Can you instead have (which I think was Jan's suggestion too): static int allocate_vpid(void); static void free_vpid(int vpid); That said, I like the simple solution to the "too many VPIDs for each L1 VCPU" processor. Paolo