public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/events: Always allocate legacy interrupts on PV guests
@ 2015-11-17 15:36 Boris Ostrovsky
  2015-11-17 15:38 ` David Vrabel
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Boris Ostrovsky @ 2015-11-17 15:36 UTC (permalink / raw)
  To: konrad.wilk, david.vrabel
  Cc: xen-devel, linux-kernel, jgross, tglx, Boris Ostrovsky

After commit 8c058b0b9c34 ("x86/irq: Probe for PIC presence before
allocating descs for legacy IRQs") early_irq_init() will no longer
preallocate descriptors for legacy interrupts if PIT does not
exist.

Therefore we need to allocate those descriptors for PV guests
ourselves.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/xen/events/events_base.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 849500e..a2bb333 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -419,8 +419,8 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
 	if (xen_pv_domain() && !xen_initial_domain())
 		return xen_allocate_irq_dynamic();
 
-	/* Legacy IRQ descriptors are already allocated by the arch. */
-	if (gsi < NR_IRQS_LEGACY)
+	/* On HVM legacy IRQ descriptors are already allocated by the arch. */
+	if (xen_hvm_domain() && gsi < NR_IRQS_LEGACY)
 		irq = gsi;
 	else
 		irq = irq_alloc_desc_at(gsi, -1);
@@ -445,8 +445,8 @@ static void xen_free_irq(unsigned irq)
 
 	kfree(info);
 
-	/* Legacy IRQ descriptors are managed by the arch. */
-	if (irq < NR_IRQS_LEGACY)
+	/* On HVM legacy IRQ descriptors are managed by the arch. */
+	if (xen_hvm_domain() && irq < NR_IRQS_LEGACY)
 		return;
 
 	irq_free_desc(irq);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] xen/events: Always allocate legacy interrupts on PV guests
  2015-11-17 15:36 [PATCH] xen/events: Always allocate legacy interrupts on PV guests Boris Ostrovsky
@ 2015-11-17 15:38 ` David Vrabel
  2015-11-17 16:24 ` Juergen Gross
  2015-11-18 11:16 ` [Xen-devel] " Vitaly Kuznetsov
  2 siblings, 0 replies; 8+ messages in thread
From: David Vrabel @ 2015-11-17 15:38 UTC (permalink / raw)
  To: Boris Ostrovsky, konrad.wilk; +Cc: xen-devel, linux-kernel, jgross, tglx

On 17/11/15 15:36, Boris Ostrovsky wrote:
> After commit 8c058b0b9c34 ("x86/irq: Probe for PIC presence before
> allocating descs for legacy IRQs") early_irq_init() will no longer
> preallocate descriptors for legacy interrupts if PIT does not
> exist.
> 
> Therefore we need to allocate those descriptors for PV guests
> ourselves.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

David

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] xen/events: Always allocate legacy interrupts on PV guests
  2015-11-17 15:36 [PATCH] xen/events: Always allocate legacy interrupts on PV guests Boris Ostrovsky
  2015-11-17 15:38 ` David Vrabel
@ 2015-11-17 16:24 ` Juergen Gross
  2015-11-18 11:16 ` [Xen-devel] " Vitaly Kuznetsov
  2 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2015-11-17 16:24 UTC (permalink / raw)
  To: Boris Ostrovsky, konrad.wilk, david.vrabel; +Cc: xen-devel, linux-kernel, tglx

On 17/11/15 16:36, Boris Ostrovsky wrote:
> After commit 8c058b0b9c34 ("x86/irq: Probe for PIC presence before
> allocating descs for legacy IRQs") early_irq_init() will no longer
> preallocate descriptors for legacy interrupts if PIT does not
> exist.
> 
> Therefore we need to allocate those descriptors for PV guests
> ourselves.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>

Tested-by: Juergen Gross <jgross@suse.com>


Juergen

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen/events: Always allocate legacy interrupts on PV guests
  2015-11-17 15:36 [PATCH] xen/events: Always allocate legacy interrupts on PV guests Boris Ostrovsky
  2015-11-17 15:38 ` David Vrabel
  2015-11-17 16:24 ` Juergen Gross
@ 2015-11-18 11:16 ` Vitaly Kuznetsov
  2015-11-18 14:03   ` Boris Ostrovsky
  2 siblings, 1 reply; 8+ messages in thread
From: Vitaly Kuznetsov @ 2015-11-18 11:16 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: konrad.wilk, david.vrabel, jgross, tglx, linux-kernel, xen-devel

Boris Ostrovsky <boris.ostrovsky@oracle.com> writes:

> After commit 8c058b0b9c34 ("x86/irq: Probe for PIC presence before
> allocating descs for legacy IRQs") early_irq_init() will no longer
> preallocate descriptors for legacy interrupts if PIT does not
> exist.

PIC?

>
> Therefore we need to allocate those descriptors for PV guests
> ourselves.
>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  drivers/xen/events/events_base.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
> index 849500e..a2bb333 100644
> --- a/drivers/xen/events/events_base.c
> +++ b/drivers/xen/events/events_base.c
> @@ -419,8 +419,8 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
>  	if (xen_pv_domain() && !xen_initial_domain())
>  		return xen_allocate_irq_dynamic();
>
> -	/* Legacy IRQ descriptors are already allocated by the arch. */
> -	if (gsi < NR_IRQS_LEGACY)
> +	/* On HVM legacy IRQ descriptors are already allocated by the arch. */
> +	if (xen_hvm_domain() && gsi < NR_IRQS_LEGACY)
>  		irq = gsi;

Wouldn't it be better to write it as
 if (gsi < nr_legacy_irqs()) ?

I think it's possible to have PIC-less HVM guests in future (btw, what
about HVMlite?). I see nr_legacy_irqs() is x86-only but it can easily be
defined to NR_IRQS_LEGACY on other arches.

>  	else
>  		irq = irq_alloc_desc_at(gsi, -1);
> @@ -445,8 +445,8 @@ static void xen_free_irq(unsigned irq)
>
>  	kfree(info);
>
> -	/* Legacy IRQ descriptors are managed by the arch. */
> -	if (irq < NR_IRQS_LEGACY)
> +	/* On HVM legacy IRQ descriptors are managed by the arch. */
> +	if (xen_hvm_domain() && irq < NR_IRQS_LEGACY)
>  		return;
>
>  	irq_free_desc(irq);

-- 
  Vitaly

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen/events: Always allocate legacy interrupts on PV guests
  2015-11-18 11:16 ` [Xen-devel] " Vitaly Kuznetsov
@ 2015-11-18 14:03   ` Boris Ostrovsky
  2015-11-18 14:28     ` Vitaly Kuznetsov
  0 siblings, 1 reply; 8+ messages in thread
From: Boris Ostrovsky @ 2015-11-18 14:03 UTC (permalink / raw)
  To: Vitaly Kuznetsov, david.vrabel
  Cc: konrad.wilk, jgross, tglx, linux-kernel, xen-devel

On 11/18/2015 06:16 AM, Vitaly Kuznetsov wrote:
> Boris Ostrovsky <boris.ostrovsky@oracle.com> writes:
>
>> After commit 8c058b0b9c34 ("x86/irq: Probe for PIC presence before
>> allocating descs for legacy IRQs") early_irq_init() will no longer
>> preallocate descriptors for legacy interrupts if PIT does not
>> exist.
> PIC?

Right. David, can you fix this before committing?

>
>> Therefore we need to allocate those descriptors for PV guests
>> ourselves.
>>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
>> ---
>>   drivers/xen/events/events_base.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
>> index 849500e..a2bb333 100644
>> --- a/drivers/xen/events/events_base.c
>> +++ b/drivers/xen/events/events_base.c
>> @@ -419,8 +419,8 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
>>   	if (xen_pv_domain() && !xen_initial_domain())
>>   		return xen_allocate_irq_dynamic();
>>
>> -	/* Legacy IRQ descriptors are already allocated by the arch. */
>> -	if (gsi < NR_IRQS_LEGACY)
>> +	/* On HVM legacy IRQ descriptors are already allocated by the arch. */
>> +	if (xen_hvm_domain() && gsi < NR_IRQS_LEGACY)
>>   		irq = gsi;
> Wouldn't it be better to write it as
>   if (gsi < nr_legacy_irqs()) ?

I don't think so: on PV we end up setting legacy_pic to null_legacy_pic 
in probe_8259A() and that will make nr_legacy_irqs() return 0.

>
> I think it's possible to have PIC-less HVM guests in future (btw, what
> about HVMlite?). I see nr_legacy_irqs() is x86-only but it can easily be
> defined to NR_IRQS_LEGACY on other arches.

Yes, HVMlite (or however we will end up calling it) will allow these 
sorts of thing. But HVMlite is not supported yet at all. And it's x86 only.

-boris

>
>>   	else
>>   		irq = irq_alloc_desc_at(gsi, -1);
>> @@ -445,8 +445,8 @@ static void xen_free_irq(unsigned irq)
>>
>>   	kfree(info);
>>
>> -	/* Legacy IRQ descriptors are managed by the arch. */
>> -	if (irq < NR_IRQS_LEGACY)
>> +	/* On HVM legacy IRQ descriptors are managed by the arch. */
>> +	if (xen_hvm_domain() && irq < NR_IRQS_LEGACY)
>>   		return;
>>
>>   	irq_free_desc(irq);


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen/events: Always allocate legacy interrupts on PV guests
  2015-11-18 14:03   ` Boris Ostrovsky
@ 2015-11-18 14:28     ` Vitaly Kuznetsov
  2015-11-18 15:00       ` Boris Ostrovsky
  0 siblings, 1 reply; 8+ messages in thread
From: Vitaly Kuznetsov @ 2015-11-18 14:28 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: david.vrabel, konrad.wilk, jgross, tglx, linux-kernel, xen-devel

Boris Ostrovsky <boris.ostrovsky@oracle.com> writes:

> On 11/18/2015 06:16 AM, Vitaly Kuznetsov wrote:
>> Boris Ostrovsky <boris.ostrovsky@oracle.com> writes:
>>
>>> After commit 8c058b0b9c34 ("x86/irq: Probe for PIC presence before
>>> allocating descs for legacy IRQs") early_irq_init() will no longer
>>> preallocate descriptors for legacy interrupts if PIT does not
>>> exist.
>> PIC?
>
> Right. David, can you fix this before committing?
>
>>
>>> Therefore we need to allocate those descriptors for PV guests
>>> ourselves.
>>>
>>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>>> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
>>> ---
>>>   drivers/xen/events/events_base.c | 8 ++++----
>>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
>>> index 849500e..a2bb333 100644
>>> --- a/drivers/xen/events/events_base.c
>>> +++ b/drivers/xen/events/events_base.c
>>> @@ -419,8 +419,8 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
>>>   	if (xen_pv_domain() && !xen_initial_domain())
>>>   		return xen_allocate_irq_dynamic();
>>>
>>> -	/* Legacy IRQ descriptors are already allocated by the arch. */
>>> -	if (gsi < NR_IRQS_LEGACY)
>>> +	/* On HVM legacy IRQ descriptors are already allocated by the arch. */
>>> +	if (xen_hvm_domain() && gsi < NR_IRQS_LEGACY)
>>>   		irq = gsi;
>> Wouldn't it be better to write it as
>>   if (gsi < nr_legacy_irqs()) ?
>
> I don't think so: on PV we end up setting legacy_pic to
> null_legacy_pic in probe_8259A() and that will make nr_legacy_irqs()
> return 0.

Yes, so the condition will always be false for PV and it equals to
xen_hvm_domain() or am I missng something?

>
>>
>> I think it's possible to have PIC-less HVM guests in future (btw, what
>> about HVMlite?). I see nr_legacy_irqs() is x86-only but it can easily be
>> defined to NR_IRQS_LEGACY on other arches.
>
> Yes, HVMlite (or however we will end up calling it) will allow these
> sorts of thing. But HVMlite is not supported yet at all. And it's x86
> only.
>
> -boris
>
>>
>>>   	else
>>>   		irq = irq_alloc_desc_at(gsi, -1);
>>> @@ -445,8 +445,8 @@ static void xen_free_irq(unsigned irq)
>>>
>>>   	kfree(info);
>>>
>>> -	/* Legacy IRQ descriptors are managed by the arch. */
>>> -	if (irq < NR_IRQS_LEGACY)
>>> +	/* On HVM legacy IRQ descriptors are managed by the arch. */
>>> +	if (xen_hvm_domain() && irq < NR_IRQS_LEGACY)
>>>   		return;
>>>
>>>   	irq_free_desc(irq);

-- 
  Vitaly

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen/events: Always allocate legacy interrupts on PV guests
  2015-11-18 14:28     ` Vitaly Kuznetsov
@ 2015-11-18 15:00       ` Boris Ostrovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Boris Ostrovsky @ 2015-11-18 15:00 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: david.vrabel, konrad.wilk, jgross, tglx, linux-kernel, xen-devel

On 11/18/2015 09:28 AM, Vitaly Kuznetsov wrote:
> Boris Ostrovsky <boris.ostrovsky@oracle.com> writes:
>
>> On 11/18/2015 06:16 AM, Vitaly Kuznetsov wrote:
>>> Boris Ostrovsky <boris.ostrovsky@oracle.com> writes:
>>>
>>>> After commit 8c058b0b9c34 ("x86/irq: Probe for PIC presence before
>>>> allocating descs for legacy IRQs") early_irq_init() will no longer
>>>> preallocate descriptors for legacy interrupts if PIT does not
>>>> exist.
>>> PIC?
>> Right. David, can you fix this before committing?
>>
>>>> Therefore we need to allocate those descriptors for PV guests
>>>> ourselves.
>>>>
>>>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>>>> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
>>>> ---
>>>>    drivers/xen/events/events_base.c | 8 ++++----
>>>>    1 file changed, 4 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
>>>> index 849500e..a2bb333 100644
>>>> --- a/drivers/xen/events/events_base.c
>>>> +++ b/drivers/xen/events/events_base.c
>>>> @@ -419,8 +419,8 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
>>>>    	if (xen_pv_domain() && !xen_initial_domain())
>>>>    		return xen_allocate_irq_dynamic();
>>>>
>>>> -	/* Legacy IRQ descriptors are already allocated by the arch. */
>>>> -	if (gsi < NR_IRQS_LEGACY)
>>>> +	/* On HVM legacy IRQ descriptors are already allocated by the arch. */
>>>> +	if (xen_hvm_domain() && gsi < NR_IRQS_LEGACY)
>>>>    		irq = gsi;
>>> Wouldn't it be better to write it as
>>>    if (gsi < nr_legacy_irqs()) ?
>> I don't think so: on PV we end up setting legacy_pic to
>> null_legacy_pic in probe_8259A() and that will make nr_legacy_irqs()
>> return 0.
> Yes, so the condition will always be false for PV and it equals to
> xen_hvm_domain() or am I missng something?

Oh, I see what you are saying. Yes, it would be cleaner.

-boris



>
>>> I think it's possible to have PIC-less HVM guests in future (btw, what
>>> about HVMlite?). I see nr_legacy_irqs() is x86-only but it can easily be
>>> defined to NR_IRQS_LEGACY on other arches.
>>>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen/events: Always allocate legacy interrupts on PV guests
  2015-11-20 16:25 Boris Ostrovsky
@ 2015-11-26 18:22 ` David Vrabel
  0 siblings, 0 replies; 8+ messages in thread
From: David Vrabel @ 2015-11-26 18:22 UTC (permalink / raw)
  To: Boris Ostrovsky, konrad.wilk, david.vrabel, linux
  Cc: jgross, linux-kernel, xen-devel, stefano.stabellini, tglx,
	vkuznets, linux-arm-kernel

On 20/11/15 16:25, Boris Ostrovsky wrote:
> After commit 8c058b0b9c34 ("x86/irq: Probe for PIC presence before
> allocating descs for legacy IRQs") early_irq_init() will no longer
> preallocate descriptors for legacy interrupts if PIC does not
> exist, which is the case for Xen PV guests.
> 
> Therefore we may need to allocate those descriptors ourselves.

Applied to for-linus-4.4, thanks.

> --- a/arch/arm64/include/asm/irq.h
> +++ b/arch/arm64/include/asm/irq.h
> @@ -7,4 +7,10 @@ struct pt_regs;
>  
>  extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
>  
> +#define NR_IRQS_LEGACY  0

I dropped this unnecessary #define.

David

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-11-26 18:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-17 15:36 [PATCH] xen/events: Always allocate legacy interrupts on PV guests Boris Ostrovsky
2015-11-17 15:38 ` David Vrabel
2015-11-17 16:24 ` Juergen Gross
2015-11-18 11:16 ` [Xen-devel] " Vitaly Kuznetsov
2015-11-18 14:03   ` Boris Ostrovsky
2015-11-18 14:28     ` Vitaly Kuznetsov
2015-11-18 15:00       ` Boris Ostrovsky
  -- strict thread matches above, loose matches on Subject: below --
2015-11-20 16:25 Boris Ostrovsky
2015-11-26 18:22 ` [Xen-devel] " David Vrabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox