Re: ledtrig-cpu: Limit to 4 CPUs

From: Jacek Anaszewski
Date: Sat Sep 26 2020 - 09:59:20 EST


On 9/25/20 11:40 AM, Pavel Machek wrote:
Hi!

So.. no, it is not causing kernel crashes or something. But it is
example of bad interface, and _that_ is causing problems. (And yes, if
I realized it is simply possible to limit it, maybe the BIN_ATTR
conversion would not be neccessary...)

The limitation you proposed breaks the trigger on many plafforms.

Actually it precludes its use.

I still see the patch in your linux-next, so I reserve myself the
right to comment on your pull request.

You are free to comment on anything.

I believe probability someone uses that with more than 4 CPUs is <
5%.

So you even didn't bother to check:

$ git grep "default-trigger = \"cpu[4-9]"
arch/arm/boot/dts/vexpress-v2m-rs1.dtsi: linux,default-trigger = "cpu4";
arch/arm/boot/dts/vexpress-v2m-rs1.dtsi: linux,default-trigger = "cpu5";
arch/arm/boot/dts/vexpress-v2m.dtsi: linux,default-trigger = "cpu4";
arch/arm/boot/dts/vexpress-v2m.dtsi: linux,default-trigger = "cpu5";

cpus are enumerated starting from 0, so there are more reasons for which
your patch is broken:

1. There are mainline users.
2. You claim that you limit trigger use to 4 cpus, while the number is
actually 5, due to your condition:
+ if (cpu > 4)
+ continue;
3. For platforms exceeding the limit the number of triggers registered
would not match the number all available cpus, for no obvious reason.
Better solution would be to prevent use of the trigger entirely
in such cases, which would need only to alter first instruction in
ledtrig_cpu_init(), which currently is:

BUILD_BUG_ON(CONFIG_NR_CPUS > 9999);

However I am not in favor of this approach since after removing
PAGE_LIMIT size on triggers file, the trigger doesn't longer cause
problems even with hypothetical 1000 cpus.

The correct approach would be to create new trigger with better
interface and then advise people switching to it.

Probability that someone uses it with more than 100 CPUs is << 1%
I'd say. Systems just don't have that many LEDs. I'll take the risk.

If I broke someone's real, existing setup, I'll raise the limit.

Is this professional approach - throw a potential bug at users and
check if it will hit them? :-) And for no reason - you're not fixing
anything.

(With exception of uled setups. In such cases, I'll just laugh.)

If you know or can find out someone using it with more than 4 CPUs, I
can obviously raise the limit before the merge.

--
Best regards,
Jacek Anaszewski