All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Andreas Färber" <afaerber@suse.de>
Cc: Laurent Desnogues <laurent.desnogues@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH qom-cpu for-2.0] cpu: Avoid QOM casts for CPU()
Date: Fri, 28 Mar 2014 15:52:21 +0000	[thread overview]
Message-ID: <CAFEAcA8DasaumEMT2qc+EEnET-r8nCFgv86Ccqiq_WSWioy0KQ@mail.gmail.com> (raw)
In-Reply-To: <1396021744-29942-1-git-send-email-afaerber@suse.de>

On 28 March 2014 15:49, Andreas Färber <afaerber@suse.de> 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 to
> a noticeable increase of CPU() usage in "hot" paths for both TCG and KVM.
>
> 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 anyway.
>
> Keep the CPU() macro for a consistent developer experience and
> flexibility to exchange its implementation, but turn it into a pure
> C cast for now.
>
> Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  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)
> +#define CPU(obj) ((CPUState *)(obj))
>  #define CPU_CLASS(class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_CPU)
>  #define CPU_GET_CLASS(obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU)
>
> --
> 1.8.4.5

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.

thanks
-- PMM

  reply	other threads:[~2014-03-28 15:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28 15:49 [Qemu-devel] [PATCH qom-cpu for-2.0] cpu: Avoid QOM casts for CPU() Andreas Färber
2014-03-28 15:52 ` Peter Maydell [this message]
2014-03-28 17:10   ` Andreas Färber
2014-03-31 17:16     ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFEAcA8DasaumEMT2qc+EEnET-r8nCFgv86Ccqiq_WSWioy0KQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=afaerber@suse.de \
    --cc=laurent.desnogues@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.