From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 01/15] KVM: PPC: Make register read/write wrappers always work Date: Mon, 08 Mar 2010 16:06:45 +0200 Message-ID: <4B950475.1020106@redhat.com> References: <1267807842-3751-1-git-send-email-agraf@suse.de> <1267807842-3751-2-git-send-email-agraf@suse.de> <4B94FE41.1040904@redhat.com> <4B94FF56.9060200@suse.de> <4B9500B2.7030708@redhat.com> <4B950174.7010709@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Alexander Graf Return-path: In-Reply-To: <4B950174.7010709-l3A5Bk7waGM@public.gmane.org> Sender: kvm-ppc-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: kvm.vger.kernel.org On 03/08/2010 03:53 PM, Alexander Graf wrote: > >> So do it the other way around. Always load the registers (of course, >> do nothing if already loaded) and then access them in just one way. I >> assume during emulation the registers will always be loaded? >> > During emulation we're always in VCPU_RUN, so the vcpu is loaded. > > Do you mean something like: > > read_register(num) { > vcpu_load(); > read register from PACA(num); > vcpu_put(); > } > > ? Does vcpu_load incur overhead when it doesnt' need to do anything? > If the vcpu is always loaded, this would be redundant, no? The situation is that a piece of data is in one of two places. Instead of checking and loading it from either, force it to the place where it normally is, and load it from there. So instead of if (x) y = p1; else y = p2; in a zillion places, just do force_to_p2(); // the common case anyway y = p2; which results in cleaner code. Assuming that you have a common case of course. -- error compiling committee.c: too many arguments to function