From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTaIl-0007ad-Ez for qemu-devel@nongnu.org; Fri, 28 Mar 2014 13:10:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTaIf-0005O6-2t for qemu-devel@nongnu.org; Fri, 28 Mar 2014 13:10:43 -0400 Received: from cantor2.suse.de ([195.135.220.15]:58203 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTaIe-0005Nl-SB for qemu-devel@nongnu.org; Fri, 28 Mar 2014 13:10:36 -0400 Message-ID: <5335AD0A.8060705@suse.de> Date: Fri, 28 Mar 2014 18:10:34 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1396021744-29942-1-git-send-email-afaerber@suse.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH qom-cpu for-2.0] cpu: Avoid QOM casts for CPU() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Laurent Desnogues , Paolo Bonzini , QEMU Developers Am 28.03.2014 16:52, schrieb Peter Maydell: > On 28 March 2014 15:49, Andreas F=C3=A4rber wrote: >> CPU address spaces touching load and store helpers as well as the >> movement of (almost) all fields from CPU_COMMON to CPUState have led t= o >> a noticeable increase of CPU() usage in "hot" paths for both TCG and K= VM. >> >> While CPU()'s OBJECT_CHECK() might help detect development errors, i.e= . in >> form of crashes due to QOM vs. non-QOM mismatches rather than QOM type >> mismatches, it is not really needed at runtime since mostly used in >> CPU-specific paths, coming from a target-specific CPU subtype. If that >> pointer is damaged, other errors are highly likely occur elsewhere any= way. "to occur" >> >> Keep the CPU() macro for a consistent developer experience and "and for" >> flexibility to exchange its implementation, but turn it into a pure >> C cast for now. >> >> Reported-by: Laurent Desnogues >> Suggested-by: Paolo Bonzini >> Signed-off-by: Andreas F=C3=A4rber >> --- >> include/qom/cpu.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/qom/cpu.h b/include/qom/cpu.h >> index f99885a..0aa1bdc 100644 >> --- a/include/qom/cpu.h >> +++ b/include/qom/cpu.h >> @@ -53,7 +53,7 @@ typedef uint64_t vaddr; >> >> #define TYPE_CPU "cpu" >> >> -#define CPU(obj) OBJECT_CHECK(CPUState, (obj), TYPE_CPU) /* Avoid unnecessary penalties in hot paths by using an unchecked cast. *= / ? >> +#define CPU(obj) ((CPUState *)(obj)) >> #define CPU_CLASS(class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_C= PU) >> #define CPU_GET_CLASS(obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU= ) >> >> -- >> 1.8.4.5 >=20 > Not important if we're going to revert this as soon as 2.0 > is out of the door, but if we expect this to be around for > longer than that it would be worth a brief comment explaining > why this cast macro is a special case. Right now I don't see a post-2.0 solution emerging, so yes, documentation is good. Cheers, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg