All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Jason Wang <jasowang@redhat.com>,
	qemu-devel@nongnu.org, pbonzini@redhat.com, peterx@redhat.com,
	wexu@redhat.com, vkaplans@redhat.com,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Amit Shah <amit.shah@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] qom and debug
Date: Tue, 30 Aug 2016 14:57:08 +0300	[thread overview]
Message-ID: <20160830145633-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20160830133741.776e8ff0.cornelia.huck@de.ibm.com>

On Tue, Aug 30, 2016 at 01:37:41PM +0200, Cornelia Huck wrote:
> On Tue, 30 Aug 2016 14:15:14 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > On Tue, Aug 30, 2016 at 01:11:05PM +0200, Cornelia Huck wrote:
> > > On Tue, 30 Aug 2016 13:21:23 +0300
> > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > > 
> > > > BTW downstreams are building with --disable-qom-cast-debug which drops
> > > > all QOM casts on data path - one way is to say we just make this the
> > > > default upstream as well. Another to say that we want to distinguish
> > > > fast path calls from slow path, this way we will be able to bring back
> > > > some of the checks.
> > > 
> > > I find CONFIG_QOM_CAST_DEBUG a bit inconsistent, btw:
> > > 
> > > - for object casts, we optimize away all checks and just return the
> > > object for !debug
> > > - for class casts, we optimize away only the caching and still keep the
> > > checking (why would we drop the caching if this can speed up things?)
> > > 
> > > We certainly want to have debug turned on during development to avoid
> > > nasty surprises later (otherwise, why even bother?), but it makes sense
> > > to turn it off for a release. (Is there an easy way to turn it off for
> > > the release, normal or stable, and keep it during the development
> > > cycle?)
> > 
> > I think the assumption was class casts are not on data path.
> > Ideally we'd keep it on for release too for non-datapath things,
> > to help improve security.
> 
> This would probably need some more fine-grained configuration.

We can start with Jason's patch :)

> For now, what about this completely untested patch that at least adds
> caching for the class->interfaces case if debug is off?

Fine with me.

> diff --git a/qom/object.c b/qom/object.c
> index 8166b7d..05f1fe4 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -696,12 +696,16 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
>                                                const char *func)
>  {
>      ObjectClass *ret;
> +    int i;
>  
>      trace_object_class_dynamic_cast_assert(class ? class->type->name : "(null)",
>                                             typename, file, line, func);
>  
> -#ifdef CONFIG_QOM_CAST_DEBUG
> -    int i;
> +#ifndef CONFIG_QOM_CAST_DEBUG
> +    if (!class || !class->interfaces) {
> +        return class;
> +    }
> +#endif
>  
>      for (i = 0; class && i < OBJECT_CLASS_CAST_CACHE; i++) {
>          if (class->class_cast_cache[i] == typename) {
> @@ -709,11 +713,6 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
>              goto out;
>          }
>      }
> -#else
> -    if (!class || !class->interfaces) {
> -        return class;
> -    }
> -#endif
>  
>      ret = object_class_dynamic_cast(class, typename);
>      if (!ret && class) {
> @@ -722,7 +721,6 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
>          abort();
>      }
>  
> -#ifdef CONFIG_QOM_CAST_DEBUG
>      if (class && ret == class) {
>          for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
>              class->class_cast_cache[i - 1] = class->class_cast_cache[i];
> @@ -730,7 +728,6 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
>          class->class_cast_cache[i - 1] = typename;
>      }
>  out:
> -#endif
>      return ret;
>  }
>  

  reply	other threads:[~2016-08-30 11:57 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30  3:06 [Qemu-devel] [PATCH for 2.8 00/11] virtio/vhost DMAR support Jason Wang
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 01/11] linux-headers: update to 4.8-rc4 Jason Wang
2016-09-05  1:24   ` Wei Xu
2016-09-05  1:26     ` Michael S. Tsirkin
2016-09-06  6:28       ` Jason Wang
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 02/11] virtio: convert to use DMA api Jason Wang
2016-08-30  7:31   ` Cornelia Huck
2016-08-30 10:02     ` Michael S. Tsirkin
2016-08-30 10:21       ` Michael S. Tsirkin
2016-08-30 11:11         ` [Qemu-devel] qom and debug (was: [PATCH for 2.8 02/11] virtio: convert to use DMA api) Cornelia Huck
2016-08-30 11:15           ` Michael S. Tsirkin
2016-08-30 11:37             ` [Qemu-devel] qom and debug Cornelia Huck
2016-08-30 11:57               ` Michael S. Tsirkin [this message]
2016-08-31  2:47     ` [Qemu-devel] [PATCH for 2.8 02/11] virtio: convert to use DMA api Jason Wang
2016-09-05  2:26   ` Wei Xu
2016-09-06  6:30     ` Jason Wang
2016-09-05  2:33   ` Michael S. Tsirkin
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 03/11] intel_iommu: name vtd address space with devfn Jason Wang
2016-09-05  6:56   ` Wei Xu
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 04/11] intel_iommu: allocate new key when creating new address space Jason Wang
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 05/11] exec: introduce address_space_get_iotlb_entry() Jason Wang
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 06/11] intel_iommu: support device iotlb descriptor Jason Wang
2016-08-30 13:16   ` Peter Xu
2016-08-31  2:54     ` Jason Wang
2016-09-01  1:26       ` Peter Xu
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 07/11] virtio-pci: address space translation service (ATS) support Jason Wang
2016-08-30 13:21   ` Peter Xu
2016-08-31  2:55     ` Jason Wang
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 08/11] acpi: add ATSR for q35 Jason Wang
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 09/11] memory: handle alias for iommu notifier Jason Wang
2016-08-30 13:28   ` Peter Xu
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 10/11] Revert "intel_iommu: Throw hw_error on notify_started" Jason Wang
2016-08-30  3:37   ` Alex Williamson
2016-08-31  2:45     ` Jason Wang
2016-09-01  2:29       ` Peter Xu
2016-09-01  2:43         ` Alex Williamson
2016-09-01  3:58           ` Peter Xu
2016-09-02  4:15             ` David Gibson
2016-09-02  5:37               ` Peter Xu
2016-09-02  6:10                 ` David Gibson
2016-09-02  6:15                   ` Peter Xu
2016-09-02  6:18                     ` Peter Xu
2016-09-02  7:00                       ` David Gibson
2016-09-02  9:31                         ` Peter Xu
2016-09-02 15:13                           ` Alex Williamson
2016-09-05  6:28                             ` Peter Xu
2016-08-30  3:06 ` [Qemu-devel] [PATCH for 2.8 11/11] vhost_net: device IOTLB support Jason Wang
2016-09-01  3:34   ` Peter Xu
2016-09-01  7:36     ` Jason Wang
2016-09-02  5:47       ` Peter Xu
2016-08-30  3:25 ` [Qemu-devel] [PATCH for 2.8 00/11] virtio/vhost DMAR support no-reply
2016-08-30  3:29 ` no-reply

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=20160830145633-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vkaplans@redhat.com \
    --cc=wexu@redhat.com \
    /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.