linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] genirq/proc: Show percpu irq affinity
@ 2020-08-10  2:29 Yunfeng Ye
  2020-08-13  8:27 ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: Yunfeng Ye @ 2020-08-10  2:29 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, Shiyuan Hu, Hewenliang

When the "affinity=" cmdline parameter is configured, the interrupt
affinity displayed in the proc directory does not match with that of the
the percu interrupt, and the percu interrupt uses desc->percu_affinity.

So show desc->percu_affinity in show_irq_affinity() for percpu
interrupt.

Signed-off-by: yeyunfeng <yeyunfeng@huawei.com>
---
 kernel/irq/proc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 32c071d7bc03..b9d0fa87b4b4 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -52,6 +52,8 @@ static int show_irq_affinity(int type, struct seq_file *m)
 	case AFFINITY:
 	case AFFINITY_LIST:
 		mask = desc->irq_common_data.affinity;
+		if (irqd_is_per_cpu(&desc->irq_data))
+			mask = desc->percpu_affinity;
 #ifdef CONFIG_GENERIC_PENDING_IRQ
 		if (irqd_is_setaffinity_pending(&desc->irq_data))
 			mask = desc->pending_mask;
-- 
1.8.3.1


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

* Re: [PATCH] genirq/proc: Show percpu irq affinity
  2020-08-10  2:29 [PATCH] genirq/proc: Show percpu irq affinity Yunfeng Ye
@ 2020-08-13  8:27 ` Thomas Gleixner
  2020-08-22  9:33   ` Yunfeng Ye
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2020-08-13  8:27 UTC (permalink / raw)
  To: Yunfeng Ye; +Cc: linux-kernel, Shiyuan Hu, Hewenliang

Yunfeng Ye <yeyunfeng@huawei.com> writes:

> When the "affinity=" cmdline parameter is configured,

There is no such parameter.

> the interrupt affinity displayed in the proc directory does not match
> with that of the the percu interrupt, and the percu interrupt uses
> desc->percu_affinity.

And when the non-existing parameter is not on the command line then
irq->affinity is showing the correct value magically?

Definitely not: It's unconditionally showing irq->affinity and that is
pretty unlikely to match irq->percpu_affinity in any case.

> diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
> index 32c071d7bc03..b9d0fa87b4b4 100644
> --- a/kernel/irq/proc.c
> +++ b/kernel/irq/proc.c
> @@ -52,6 +52,8 @@ static int show_irq_affinity(int type, struct seq_file *m)
>  	case AFFINITY:
>  	case AFFINITY_LIST:
>  		mask = desc->irq_common_data.affinity;
> +		if (irqd_is_per_cpu(&desc->irq_data))
> +			mask = desc->percpu_affinity;

This breaks all architecture which mark interrupts as per CPU without
using the partition mechanism resulting in a NULL pointer dereference.

Thanks,

        tglx

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

* Re: [PATCH] genirq/proc: Show percpu irq affinity
  2020-08-13  8:27 ` Thomas Gleixner
@ 2020-08-22  9:33   ` Yunfeng Ye
  2020-08-22 11:35     ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: Yunfeng Ye @ 2020-08-22  9:33 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Shiyuan Hu, Hewenliang



On 2020/8/13 16:27, Thomas Gleixner wrote:
> Yunfeng Ye <yeyunfeng@huawei.com> writes:
> 
>> When the "affinity=" cmdline parameter is configured,
> 
> There is no such parameter.
> 
>> the interrupt affinity displayed in the proc directory does not match
>> with that of the the percu interrupt, and the percu interrupt uses
>> desc->percu_affinity.
> 
> And when the non-existing parameter is not on the command line then
> irq->affinity is showing the correct value magically?
> 
> Definitely not: It's unconditionally showing irq->affinity and that is
> pretty unlikely to match irq->percpu_affinity in any case.
> 
Sorry,it is "irqaffinity=" cmdline parameter. it will set irq_default_affinity
mask. if the interrupt is not the managed irq, the irq_desc will use
irq_default_affinity as default affinity.

For example, the cmdline "irqaffinity=0,1,126,127" on the 128 cores system:

[root@localhost ~]# cat /proc/irq/4/smp_affinity_list
0-1,126-127

The irq 4 is "arch_timer" interrupt, which is a percpu interrupt.

So is it necessary to show the percpu irq affinity correct?

thanks.

>> diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
>> index 32c071d7bc03..b9d0fa87b4b4 100644
>> --- a/kernel/irq/proc.c
>> +++ b/kernel/irq/proc.c
>> @@ -52,6 +52,8 @@ static int show_irq_affinity(int type, struct seq_file *m)
>>  	case AFFINITY:
>>  	case AFFINITY_LIST:
>>  		mask = desc->irq_common_data.affinity;
>> +		if (irqd_is_per_cpu(&desc->irq_data))
>> +			mask = desc->percpu_affinity;
> 
> This breaks all architecture which mark interrupts as per CPU without
> using the partition mechanism resulting in a NULL pointer dereference.
> 
Yes, it is a problem.

> Thanks,
> 
>         tglx
> 
> .
> 


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

* Re: [PATCH] genirq/proc: Show percpu irq affinity
  2020-08-22  9:33   ` Yunfeng Ye
@ 2020-08-22 11:35     ` Thomas Gleixner
  2020-08-25  9:39       ` Yunfeng Ye
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2020-08-22 11:35 UTC (permalink / raw)
  To: Yunfeng Ye; +Cc: linux-kernel, Shiyuan Hu, Hewenliang, Marc Zyngier

On Sat, Aug 22 2020 at 17:33, Yunfeng Ye wrote:
> On 2020/8/13 16:27, Thomas Gleixner wrote:
> For example, the cmdline "irqaffinity=0,1,126,127" on the 128 cores system:
>
> [root@localhost ~]# cat /proc/irq/4/smp_affinity_list
> 0-1,126-127
>
> The irq 4 is "arch_timer" interrupt, which is a percpu interrupt.
>
> So is it necessary to show the percpu irq affinity correct?

Yes, it makes sense to do so, but you used the wrong check. The correct
one is:

irq_settings_is_per_cpu_devid()

which will not wreckage the output for other per cpu marked interrupts
which never set the percpu_affinity pointer with the obvious
consequences... The pointer would need a NULL check in any case, but it
might be more straight forward to update affinity when percpu_affinity
is initialized. Haven't looked in detail though.

Thanks,

        tglx

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

* Re: [PATCH] genirq/proc: Show percpu irq affinity
  2020-08-22 11:35     ` Thomas Gleixner
@ 2020-08-25  9:39       ` Yunfeng Ye
  0 siblings, 0 replies; 5+ messages in thread
From: Yunfeng Ye @ 2020-08-25  9:39 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Shiyuan Hu, Hewenliang, Marc Zyngier



On 2020/8/22 19:35, Thomas Gleixner wrote:
> On Sat, Aug 22 2020 at 17:33, Yunfeng Ye wrote:
>> On 2020/8/13 16:27, Thomas Gleixner wrote:
>> For example, the cmdline "irqaffinity=0,1,126,127" on the 128 cores system:
>>
>> [root@localhost ~]# cat /proc/irq/4/smp_affinity_list
>> 0-1,126-127
>>
>> The irq 4 is "arch_timer" interrupt, which is a percpu interrupt.
>>
>> So is it necessary to show the percpu irq affinity correct?
> 
> Yes, it makes sense to do so, but you used the wrong check. The correct
> one is:
> 
> irq_settings_is_per_cpu_devid()
> 
> which will not wreckage the output for other per cpu marked interrupts
> which never set the percpu_affinity pointer with the obvious
> consequences... The pointer would need a NULL check in any case, but it
> might be more straight forward to update affinity when percpu_affinity
> is initialized. Haven't looked in detail though.
> 
ok, I will send the patch v2, thanks.

> Thanks,
> 
>         tglx
> 
> .
> 


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

end of thread, other threads:[~2020-08-25  9:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10  2:29 [PATCH] genirq/proc: Show percpu irq affinity Yunfeng Ye
2020-08-13  8:27 ` Thomas Gleixner
2020-08-22  9:33   ` Yunfeng Ye
2020-08-22 11:35     ` Thomas Gleixner
2020-08-25  9:39       ` Yunfeng Ye

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).