[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH RFC v1 2/4] xl for rt scheduler



Hi Dario,


> Â Â Â Â > + Â Âlibxl_domain_sched_params_init(&scinfo);
> Â Â Â Â > + Â Ârc = sched_domain_get(LIBXL_SCHEDULER_RT, domid,
> Â Â Â Â &scinfo);
> Â Â Â Â > + Â Âif (rc)
> Â Â Â Â > + Â Â Â Âreturn rc;
> Â Â Â Â > +

> âThank you very much for pasting the rules here! I really appreciate
> it. However, I didn't quite get why it violate the libxl type paradigm
> and how I should correct it. (Sorry. :-()â
>
<<The user must always calls "dispose" exactly once afterwards, to clean
up, regardless of whether operations on this object succeeded or
failed>>

While, above, you're exiting, if rc is true, without calling dispose.

It depens a lot on the function, but what you usually do, is grouping
the calls to the various dispose under a label (typically 'out:') and
goto there to exit.

Look around, both in xl and libxl, you'll find plenty of examples of
that.

> We actually followed the way credit scheduler does
> in main_sched_credit(int argc, char **argv)
>
>
> Â Â Â Â } else { /* set credit scheduler paramaters */
> Â Â Â Â Â Â libxl_domain_sched_params scinfo;
> Â Â Â Â Â Â libxl_domain_sched_params_init(&scinfo);
> Â Â Â Â Â Â scinfo.sched = LIBXL_SCHEDULER_CREDIT;
> Â Â Â Â Â Â if (opt_w)
> Â Â Â Â Â Â Â Â scinfo.weight = weight;
> Â Â Â Â Â Â if (opt_c)
> Â Â Â Â Â Â Â Â scinfo.cap = cap;
> Â Â Â Â Â Â rc = sched_domain_set(domid, &scinfo);
> Â Â Â Â Â Â libxl_domain_sched_params_dispose(&scinfo);
>
And in fact, here's dispose! :-)


I think you are right! But I think the implementation of this functionality for credit scheduler also has the exactly same issue: scinfo will not be disposed when hypercall returns false.Â

Here is the code for sched_credit_domain_output(int domid) in tools/libxl/xl_cmdimpl.c.Â
  rc = sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo);

  if (rc)Â

    return rc;

  domname = libxl_domid_to_name(ctx, domid);

  printf("%-33s %4d %6d %4d\n",

    domname,

    domid,

    scinfo.weight,

    scinfo.cap);

  free(domname);

  libxl_domain_sched_params_dispose(&scinfo);

(Note: sched_domain_get() init the scinfo, but didn't dispose it. )

ÂAs you can see, it has the exact issue I had. :-) If it's the case, I can submit a separate patch for this. :-)

Thanks,

MengÂ


--


-----------
Meng Xu
PhD Student in Computer and Information Science
University of Pennsylvania

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.