From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 08/31] nVMX: Fix local_vcpus_link handling Date: Tue, 17 May 2011 16:35:20 +0300 Message-ID: <4DD27998.1040105@redhat.com> References: <1305575004-nyh@il.ibm.com> <201105161948.p4GJm1as001742@rice.haifa.ibm.com> <20110517131918.GA3809@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "Nadav Har'El" , kvm@vger.kernel.org, gleb@redhat.com To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:46204 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752017Ab1EQNf0 (ORCPT ); Tue, 17 May 2011 09:35:26 -0400 In-Reply-To: <20110517131918.GA3809@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 05/17/2011 04:19 PM, Marcelo Tosatti wrote: > > +/* > > + * Maintain the vcpus_on_cpu and saved_vmcss_on_cpu lists of vcpus and > > + * inactive saved_vmcss on nested entry (L1->L2) or nested exit (L2->L1). > > + * > > + * nested_maintain_per_cpu_lists should be called after the VMCS was switched > > + * to the new one, with parameters giving both the new on (after the entry > > + * or exit) and the old one, in that order. > > + */ > > +static void nested_maintain_per_cpu_lists(struct vcpu_vmx *vmx, > > + struct saved_vmcs *new_vmcs, > > + struct saved_vmcs *old_vmcs) > > +{ > > + /* > > + * When a vcpus's old vmcs is saved, we need to drop it from > > + * vcpus_on_cpu and put it on saved_vmcss_on_cpu. > > + */ > > + if (old_vmcs->cpu != -1) { > > + list_del(&vmx->local_vcpus_link); > > + list_add(&old_vmcs->local_saved_vmcss_link, > > + &per_cpu(saved_vmcss_on_cpu, old_vmcs->cpu)); > > + } > > This new handling of vmcs could be simplified (local_vcpus_link must be > manipulated with interrupts disabled, BTW). > > What about having a per-CPU VMCS list instead of per-CPU vcpu list? > "local_vmcs_link" list node could be in "struct saved_vmcs" (and > a current_saved_vmcs pointer in "struct vcpu_vmx"). > > vmx_vcpu_load would then add to this list at > > if (per_cpu(current_vmcs, cpu) != vmx->vmcs) { > per_cpu(current_vmcs, cpu) = vmx->vmcs; > vmcs_load(vmx->vmcs); > } Right, that's the easiest thing to do. Perhaps even easier (avoids duplication): struct raw_vmcs { u32 revision_id; u32 abort; char data[0]; }; struct vmcs { struct raw_vmcs *raw_vmcs; struct list_head local_vmcs_link; }; struct vcpu_vmx { ... struct vmcs *vmcs; /* often points at l1_vmcs */ struct vmcs l1_vmcs; ... }; static DEFINE_PER_CPU(struct list_head, vmcss_on_cpu); -- error compiling committee.c: too many arguments to function