All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: "Julien Grall" <julien.grall@arm.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Jan Beulich" <JBeulich@suse.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 2/5] xen/domain: Break __domain_destroy() out of domain_create() and complete_domain_destroy()
Date: Mon, 3 Sep 2018 18:05:34 +0100	[thread overview]
Message-ID: <3e614297-0c27-20e6-d939-62a8ed3a2b62@citrix.com> (raw)
In-Reply-To: <20180903170159.cibbzhgmayxtwmbs@zion.uk.xensource.com>

On 03/09/18 18:01, Wei Liu wrote:
> On Mon, Sep 03, 2018 at 05:58:02PM +0100, Andrew Cooper wrote:
>> On 03/09/18 17:54, Wei Liu wrote:
>>> On Mon, Sep 03, 2018 at 03:46:57PM +0100, Andrew Cooper wrote:
>>>> This is the first step in making the destroy path idepotent, and using it in
>>> "idempotent".
>>>
>>>> place of the ad-hoc cleanup paths in the create path.
>>>>
>>>> To begin with, the trivial free operations are broken out.  The rest of the
>>>> cleanup code will be moved as it is demonstrated (or made) to be idempotent.
>>>>
>>>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>>> ---
>>>> CC: Jan Beulich <JBeulich@suse.com>
>>>> CC: Wei Liu <wei.liu2@citrix.com>
>>>> CC: Roger Pau Monné <roger.pau@citrix.com>
>>>> CC: Stefano Stabellini <sstabellini@kernel.org>
>>>> CC: Julien Grall <julien.grall@arm.com>
>>>> ---
>>>>  xen/common/domain.c | 29 ++++++++++++++++++++++-------
>>>>  1 file changed, 22 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/xen/common/domain.c b/xen/common/domain.c
>>>> index 43ab926..2253c2d 100644
>>>> --- a/xen/common/domain.c
>>>> +++ b/xen/common/domain.c
>>>> @@ -260,6 +260,23 @@ static int __init parse_extra_guest_irqs(const char *s)
>>>>  }
>>>>  custom_param("extra_guest_irqs", parse_extra_guest_irqs);
>>>>  
>>>> +/*
>>>> + * Destroy a domain once all references to it have been dropped.  Used either
>>>> + * from the RCU path, or from the domain_create() error path before the domain
>>>> + * is inserted into the domlist.
>>>> + */
>>>> +static void __domain_destroy(struct domain *d)
>>>> +{
>>>> +    BUG_ON(!d->is_dying);
>>>> +    BUG_ON(atomic_read(&d->refcnt) != DOMAIN_DESTROYED);
>>>> +
>>>> +    xfree(d->pbuf);
>>> With this changed to XFREE here:
>> This is the one place where it doesn't matter.  d goes fully out of
>> scope before the end of this function.
> That's fair enough.
>
>>> Reviewed-by: Wei Liu <wei.liu2@citrix.com>
>>>
>>>> +
>>>> +    free_cpumask_var(d->dirty_cpumask);
>>> On making things idempotent: this function seems to be a candidate.
>> I don't understand.  One implementation is xfree() under the hood, and
>> the other is a no-op because no allocation took place.
> I mean it would probably be useful to make free_cpumask_var idempotent
> by using XFREE so multiple calls to it will not free dangling pointer.

Ah - that's complicated because of the (lack of) indirection of the
parameter.

There is FREE_CPUMASK_VAR() which DTRT, but see above for why it isn't
used.  (There is a similar FREE_XENHEAP_PAGE helper).

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-09-03 17:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03 14:46 [PATCH 0/5] xen/domain: Cleanup to the domain_create() error paths Andrew Cooper
2018-09-03 14:46 ` [PATCH 1/5] xen/domain: Prepare data for is_{pv, hvm}_domain() as early as possible Andrew Cooper
2018-09-03 16:03   ` Jan Beulich
2018-09-04 12:17     ` Andrew Cooper
2018-09-04 12:53       ` Jan Beulich
2018-09-03 16:47   ` Wei Liu
2018-09-03 14:46 ` [PATCH 2/5] xen/domain: Break __domain_destroy() out of domain_create() and complete_domain_destroy() Andrew Cooper
2018-09-03 16:05   ` Jan Beulich
2018-09-03 16:54   ` Wei Liu
2018-09-03 16:58     ` Andrew Cooper
2018-09-03 17:01       ` Wei Liu
2018-09-03 17:05         ` Andrew Cooper [this message]
2018-09-03 17:07           ` Wei Liu
2018-09-03 14:46 ` [PATCH 3/5] xen/domain: Call lock_profile_deregister_struct() from common code Andrew Cooper
2018-09-03 16:05   ` Jan Beulich
2018-09-03 16:56   ` Wei Liu
2018-09-03 14:46 ` [PATCH 4/5] xen/domain: Fold xsm_free_security_domain() paths together Andrew Cooper
2018-09-03 16:08   ` Jan Beulich
2018-09-03 16:57   ` Wei Liu
2018-09-07 20:48   ` [Non-DoD Source] " DeGraaf, Daniel G
2018-09-03 14:47 ` [PATCH 5/5] xen/domain: Make rangeset_domain_destroy() idempotent Andrew Cooper
2018-09-03 16:09   ` Jan Beulich
2018-09-03 16:57   ` Wei Liu

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=3e614297-0c27-20e6-d939-62a8ed3a2b62@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.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.