[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7102b6dc-1721-46cd-bdb4-a3d39e12a82b@huawei.com>
Date: Tue, 16 Aug 2022 14:22:12 +0800
From: Yicong Yang <yangyicong@...wei.com>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
CC: <yangyicong@...ilicon.com>, <will@...nel.org>,
<mark.rutland@....com>, <Frank.li@....com>, <shawnguo@...nel.org>,
<s.hauer@...gutronix.de>, <kernel@...gutronix.de>,
<festevam@...il.com>, <linux-imx@....com>,
<zhangshaokun@...ilicon.com>, <agross@...nel.org>,
<bjorn.andersson@...aro.org>, <konrad.dybcio@...ainline.org>,
<khuong@...amperecomputing.com>, <john.garry@...wei.com>,
<gregkh@...uxfoundation.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linux-arm-msm@...r.kernel.org>
Subject: Re: [PATCH] drivers/perf: Change WARN_ON() to dev_err() on
irq_set_affinity() failure
On 2022/8/15 17:39, Jonathan Cameron wrote:
> On Mon, 15 Aug 2022 17:28:15 +0800
> Yicong Yang <yangyicong@...wei.com> wrote:
>
>> From: Yicong Yang <yangyicong@...ilicon.com>
>>
>> The WARN_ON() on irq_set_affinity() failure is misused according to the [1]
>> and may crash people's box unintentionally. This may also be redundant since
>> in the failure case we may also trigger the WARN and dump the stack in the
>> perf core[2] for a second time.
>>
>> So change the WARN_ON() to dev_err() to just print the failure message.
>>
>> [1] https://github.com/torvalds/linux/blob/master/include/asm-generic/bug.h#L74
>> [2] https://github.com/torvalds/linux/blob/master/kernel/events/core.c#L313
>>
>> Suggested-by: Greg KH <gregkh@...uxfoundation.org>
>> [https://lore.kernel.org/lkml/YuOi3i0XHV++z1YI@kroah.com/]
>> Signed-off-by: Yicong Yang <yangyicong@...ilicon.com>
>
> Looks like progress in a sensible direction to me.
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
>
> Kind of unrelated question inline.
>
Thanks for the quick review! replies below.
>>
>
>
>> diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
>> index 00d4c45a8017..05e1b3e274d7 100644
>> --- a/drivers/perf/arm_smmuv3_pmu.c
>> +++ b/drivers/perf/arm_smmuv3_pmu.c
>> @@ -646,7 +646,8 @@ static int smmu_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
>>
>> perf_pmu_migrate_context(&smmu_pmu->pmu, cpu, target);
>> smmu_pmu->on_cpu = target;
>> - WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(target)));
>> + if (irq_set_affinity(smmu_pmu->irq, cpumask_of(target)))
>> + dev_err(smmu_pmu->dev, "Failed to set interrupt affinity\n");
>>
>> return 0;
>> }
>> @@ -892,7 +893,8 @@ static int smmu_pmu_probe(struct platform_device *pdev)
>>
>> /* Pick one CPU to be the preferred one to use */
>> smmu_pmu->on_cpu = raw_smp_processor_id();
>> - WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(smmu_pmu->on_cpu)));
>> + if (irq_set_affinity(smmu_pmu->irq, cpumask_of(smmu_pmu->on_cpu)))
>> + dev_err(dev, "Failed to set interrupt affinity\n");
>
> In this case we have the option to fail probe. Failing to set affinity means
> we are broken anyway, so perhaps that is cleaner than carrying on.
>
This patch only switch the way on error notification with no functional change intended.
So if we need to change the behaviour here it should be in a separate patch. Indeed I'm
not sure it's necessary to fail probe here since we can use the pmu if it fails here.
> As a side note, I wonder if other drivers could benefit from what I think
> is a micro optimization to short cut calling the hp handlers when the
> decision of which CPU is easy...
>
It seems sensible to me but may differ in differenct pmu drivers since they may need the
hp handlers called. Needs more check.
Thanks.
>>
>> err = cpuhp_state_add_instance_nocalls(cpuhp_state_num,
>> &smmu_pmu->node);
> .
>
Powered by blists - more mailing lists