All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Stefan ISAILA <aisaila@bitdefender.com>
To: "JBeulich@suse.com" <JBeulich@suse.com>
Cc: "tim@xen.org" <tim@xen.org>,
	"sstabellini@kernel.org" <sstabellini@kernel.org>,
	"wei.liu2@citrix.com" <wei.liu2@citrix.com>,
	"rcojocaru@bitdefender.com" <rcojocaru@bitdefender.com>,
	"George.Dunlap@eu.citrix.com" <George.Dunlap@eu.citrix.com>,
	"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"ian.jackson@eu.citrix.com" <ian.jackson@eu.citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	"julien.grall@arm.com" <julien.grall@arm.com>,
	"tamas@tklengyel.com" <tamas@tklengyel.com>
Subject: Re: [PATCH v2] common/vm_event: Initialize vm_event lists on domain creation
Date: Thu, 24 Aug 2017 15:17:32 +0000	[thread overview]
Message-ID: <1503587852.3092.9.camel@bitdefender.com> (raw)
In-Reply-To: <599EEF9402000078001733B4@prv-mh.provo.novell.com>

On Jo, 2017-08-24 at 07:24 -0600, Jan Beulich wrote:
> > 
> > > 
> > > > 
> > > > On 24.08.17 at 13:48, <aisaila@bitdefender.com> wrote:
> > The patch splits the vm_event into three structures:vm_event_share,
> > vm_event_paging, vm_event_monitor. The allocation for the
> > structure is moved to vm_event_enable so that it can be
> > allocated/init when needed and freed in vm_event_disable.
> > 
> > Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
> Missing brief description of changes from v1 here.
> 
> > 
> > @@ -50,32 +50,37 @@ static int vm_event_enable(
> >      int rc;
> >      unsigned long ring_gfn = d->arch.hvm_domain.params[param];
> >  
> > +    if ( !(*ved) )
> > +        (*ved) = xzalloc(struct vm_event_domain);
> > +    if ( !(*ved) )
> In none of the three cases you really need the parentheses around
> *ved.
> 
> > 
> > @@ -187,39 +194,45 @@ void vm_event_wake(struct domain *d, struct 
> > vm_event_domain *ved)
> >          vm_event_wake_blocked(d, ved);
> >  }
> >  
> > -static int vm_event_disable(struct domain *d, struct
> > vm_event_domain *ved)
> > +static int vm_event_disable(struct domain *d, struct
> > vm_event_domain **ved)
> >  {
> > -    if ( ved->ring_page )
> > +    if ( !*ved )
> > +        return 0;
> > +
> > +    if ( (*ved)->ring_page )
> >      {
> > [...]
> > +        xfree(*ved);
> > +        *ved = NULL;
> >      }
> If both if()-s above are really useful, you are leaking *ved when it
> is non-NULL but ->ring_page is NULL.
> 
> > 
> > @@ -500,6 +519,9 @@ bool_t vm_event_check_ring(struct
> > vm_event_domain *ved)
> >  int __vm_event_claim_slot(struct domain *d, struct vm_event_domain
> > *ved,
> >                            bool_t allow_sleep)
> >  {
> > +    if ( !ved )
> > +        return -ENOSYS;
> I don't think ENOSYS is correct here.
Can you tell me what is the preferred return value here?
> 
> > 
> > @@ -510,24 +532,24 @@ int __vm_event_claim_slot(struct domain *d,
> > struct vm_event_domain *ved,
> >  /* Registered with Xen-bound event channel for incoming
> > notifications. */
> >  static void mem_paging_notification(struct vcpu *v, unsigned int
> > port)
> >  {
> > -    if ( likely(v->domain->vm_event->paging.ring_page != NULL) )
> > -        vm_event_resume(v->domain, &v->domain->vm_event->paging);
> > +    if ( likely(v->domain->vm_event_paging->ring_page != NULL) )
> > +        vm_event_resume(v->domain, v->domain->vm_event_paging);
> >  }
> >  #endif
> >  
> >  /* Registered with Xen-bound event channel for incoming
> > notifications. */
> >  static void monitor_notification(struct vcpu *v, unsigned int
> > port)
> >  {
> > -    if ( likely(v->domain->vm_event->monitor.ring_page != NULL) )
> > -        vm_event_resume(v->domain, &v->domain->vm_event->monitor);
> > +    if ( likely(v->domain->vm_event_monitor->ring_page != NULL) )
> > +        vm_event_resume(v->domain, v->domain->vm_event_monitor);
> >  }
> >  
> >  #ifdef CONFIG_HAS_MEM_SHARING
> >  /* Registered with Xen-bound event channel for incoming
> > notifications. */
> >  static void mem_sharing_notification(struct vcpu *v, unsigned int
> > port)
> >  {
> > -    if ( likely(v->domain->vm_event->share.ring_page != NULL) )
> > -        vm_event_resume(v->domain, &v->domain->vm_event->share);
> > +    if ( likely(v->domain->vm_event_share->ring_page != NULL) )
> > +        vm_event_resume(v->domain, v->domain->vm_event_share);
> >  }
> >  #endif
> For all three a local variable holding v->domain would certain help;
> eventually the functions should even be passed struct domain *
> instead of struct vcpu *, I think.
> 
> > 
> > @@ -599,7 +621,6 @@ int vm_event_domctl(struct domain *d,
> > xen_domctl_vm_event_op_t *vec,
> >  #ifdef CONFIG_HAS_MEM_PAGING
> >      case XEN_DOMCTL_VM_EVENT_OP_PAGING:
> >      {
> > -        struct vm_event_domain *ved = &d->vm_event->paging;
> Dropping this local variable (and similar ones below) pointlessly
> increases the size of this patch.
I have dropped the local var because in case of a XEN_VM_EVENT_ENABLE
d->vm_event_... is allocated in the vm_event_enable function below so
it will allocate mem for the local variable.
> 
> > 
> > --- a/xen/drivers/passthrough/pci.c
> > +++ b/xen/drivers/passthrough/pci.c
> > @@ -1363,9 +1363,11 @@ static int assign_device(struct domain *d,
> > u16 seg, u8 bus, u8 devfn, u32 flag)
> >  
> >      /* Prevent device assign if mem paging or mem sharing have
> > been 
> >       * enabled for this domain */
> > +    if( !d->vm_event_paging )
> > +        return -EXDEV;
> Is this check the wrong way round? And why can't it be combined
> with ...
> 
> > 
> >      if ( unlikely(!need_iommu(d) &&
> >              (d->arch.hvm_domain.mem_sharing_enabled ||
> > -             d->vm_event->paging.ring_page ||
> > +             d->vm_event_paging->ring_page ||
> >               p2m_get_hostp2m(d)->global_logdirty)) )
> >          return -EXDEV;
> ... this set?
> 
> Jan
Alex
> 
> ________________________
> This email was scanned by Bitdefender
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-08-24 15:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 11:48 [PATCH v2] common/vm_event: Initialize vm_event lists on domain creation Alexandru Isaila
2017-08-24 13:24 ` Jan Beulich
2017-08-24 15:17   ` Alexandru Stefan ISAILA [this message]
2017-08-24 15:24     ` Jan Beulich
2017-08-24 19:15       ` Tamas K Lengyel
2017-08-24 19:11 ` Tamas K Lengyel

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=1503587852.3092.9.camel@bitdefender.com \
    --to=aisaila@bitdefender.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=sstabellini@kernel.org \
    --cc=tamas@tklengyel.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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.