All of lore.kernel.org
 help / color / mirror / Atom feed
From: julien.grall@linaro.org (Julien Grall)
To: linux-arm-kernel@lists.infradead.org
Subject: [Xen-devel] [PATCH] arm/xen: Initialize event channels earlier
Date: Tue, 28 Jan 2014 18:00:10 +0000	[thread overview]
Message-ID: <52E7F02A.7010508@linaro.org> (raw)
In-Reply-To: <alpine.DEB.2.02.1401281742080.4373@kaball.uk.xensource.com>

On 01/28/2014 05:46 PM, Stefano Stabellini wrote:
> On Tue, 28 Jan 2014, Julien Grall wrote:
>>>> +static int xen_cpu_notification(struct notifier_block *self,
>>>> +				unsigned long action,
>>>> +				void *hcpu)
>>>> +{
>>>> +	int cpu = (long)hcpu;
>>>> +
>>>> +	switch (action) {
>>>> +	case CPU_UP_PREPARE:
>>>> +		xen_percpu_init(cpu);
>>>> +		break;
>>>> +	case CPU_STARTING:
>>>> +		xen_interrupt_init();
>>>> +		break;
>>>
>>> Is CPU_STARTING guaranteed to be called on the new cpu only?
>>
>> Yes.
>>
>>> If so, why not call both xen_percpu_init and xen_interrupt_init on
>>> CPU_STARTING?
>>
>> Just in case that xen_vcpu is used somewhere else by a cpu notifier
>> callback CPU_STARTING. We don't know which callback is called first.
> 
> Could you please elaborate a bit more on the problem you are trying to
> describe?

We want to make sure that the vcpu is registered correctly. If not, we
can't skip it and avoid xen to have a "dead" VCPU to schedule due to BUG_ON.

I agree that now we have a BUG_ON in the middle of xen_percpu_init, but
it's possible to return an error. In this case Linux will skip this cpu
and continue to boot.

>>> As it stands I think you introduced a subtle change (that might be OK
>>> but I think is unintentional): xen_percpu_init might not be called from
>>> the same cpu as its target anymore.
>>
>> No, xen_percpu_init and xen_interrupt_init are called on the boot cpu at
>> the end of xen_guest_init.
>  
> Is CPU_UP_PREPARE guaranteed to be called on the target cpu? I think
> not, therefore you would be executing xen_percpu_init for cpu1 on cpu0.
>

I don't see any issue to execute xen_percpu_init for cpu1 on cpu0, all
the code is taking directly the vcpu ID to initialize.

-- 
Julien Grall

WARNING: multiple messages have this Message-ID (diff)
From: Julien Grall <julien.grall@linaro.org>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	David Vrabel <david.vrabel@citrix.com>,
	"patches@linaro.org" <patches@linaro.org>,
	xen-devel@lists.xenproject.org,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [Xen-devel] [PATCH] arm/xen: Initialize event channels earlier
Date: Tue, 28 Jan 2014 18:00:10 +0000	[thread overview]
Message-ID: <52E7F02A.7010508@linaro.org> (raw)
In-Reply-To: <alpine.DEB.2.02.1401281742080.4373@kaball.uk.xensource.com>

On 01/28/2014 05:46 PM, Stefano Stabellini wrote:
> On Tue, 28 Jan 2014, Julien Grall wrote:
>>>> +static int xen_cpu_notification(struct notifier_block *self,
>>>> +				unsigned long action,
>>>> +				void *hcpu)
>>>> +{
>>>> +	int cpu = (long)hcpu;
>>>> +
>>>> +	switch (action) {
>>>> +	case CPU_UP_PREPARE:
>>>> +		xen_percpu_init(cpu);
>>>> +		break;
>>>> +	case CPU_STARTING:
>>>> +		xen_interrupt_init();
>>>> +		break;
>>>
>>> Is CPU_STARTING guaranteed to be called on the new cpu only?
>>
>> Yes.
>>
>>> If so, why not call both xen_percpu_init and xen_interrupt_init on
>>> CPU_STARTING?
>>
>> Just in case that xen_vcpu is used somewhere else by a cpu notifier
>> callback CPU_STARTING. We don't know which callback is called first.
> 
> Could you please elaborate a bit more on the problem you are trying to
> describe?

We want to make sure that the vcpu is registered correctly. If not, we
can't skip it and avoid xen to have a "dead" VCPU to schedule due to BUG_ON.

I agree that now we have a BUG_ON in the middle of xen_percpu_init, but
it's possible to return an error. In this case Linux will skip this cpu
and continue to boot.

>>> As it stands I think you introduced a subtle change (that might be OK
>>> but I think is unintentional): xen_percpu_init might not be called from
>>> the same cpu as its target anymore.
>>
>> No, xen_percpu_init and xen_interrupt_init are called on the boot cpu at
>> the end of xen_guest_init.
>  
> Is CPU_UP_PREPARE guaranteed to be called on the target cpu? I think
> not, therefore you would be executing xen_percpu_init for cpu1 on cpu0.
>

I don't see any issue to execute xen_percpu_init for cpu1 on cpu0, all
the code is taking directly the vcpu ID to initialize.

-- 
Julien Grall

  parent reply	other threads:[~2014-01-28 18:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 14:54 [PATCH] arm/xen: Initialize event channels earlier Julien Grall
2014-01-28 14:54 ` Julien Grall
2014-01-28 17:13 ` Stefano Stabellini
2014-01-28 17:13   ` Stefano Stabellini
2014-01-28 17:35   ` Julien Grall
2014-01-28 17:35   ` [Xen-devel] " Julien Grall
2014-01-28 17:35     ` Julien Grall
2014-01-28 17:46     ` Stefano Stabellini
2014-01-28 17:46     ` [Xen-devel] " Stefano Stabellini
2014-01-28 17:46       ` Stefano Stabellini
2014-01-28 18:00       ` Julien Grall
2014-01-28 18:00       ` Julien Grall [this message]
2014-01-28 18:00         ` [Xen-devel] " Julien Grall
2014-01-28 18:11         ` Stefano Stabellini
2014-01-28 18:11           ` Stefano Stabellini
2014-01-28 18:11         ` Stefano Stabellini
2014-01-28 17:13 ` Stefano Stabellini

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=52E7F02A.7010508@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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.