Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ledtrig-cpu: Limit to 8 CPUs

Some machines have thousands of CPUs... and trigger mechanisms was not
really meant for thousands of triggers. I doubt anyone uses this
trigger on many-CPU machine; but if they do, they'll need to do it
properly.

Signed-off-by: Pavel Machek <pavel@ucw.cz>

+10 -3
+10 -3
drivers/leds/trigger/ledtrig-cpu.c
··· 2 2 /* 3 3 * ledtrig-cpu.c - LED trigger based on CPU activity 4 4 * 5 - * This LED trigger will be registered for each possible CPU and named as 6 - * cpu0, cpu1, cpu2, cpu3, etc. 5 + * This LED trigger will be registered for first 8 CPUs and named 6 + * as cpu0..cpu7. There's additional trigger called cpu that 7 + * is on when any CPU is active. 8 + * 9 + * If you want support for arbitrary number of CPUs, make it one trigger, 10 + * with additional sysfs file selecting which CPU to watch. 7 11 * 8 12 * It can be bound to any LED just like other triggers using either a 9 13 * board file or via sysfs interface. 10 14 * 11 15 * An API named ledtrig_cpu is exported for any user, who want to add CPU 12 - * activity indication in their code 16 + * activity indication in their code. 13 17 * 14 18 * Copyright 2011 Linus Walleij <linus.walleij@linaro.org> 15 19 * Copyright 2011 - 2012 Bryan Wu <bryan.wu@canonical.com> ··· 148 144 */ 149 145 for_each_possible_cpu(cpu) { 150 146 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); 147 + 148 + if (cpu >= 8) 149 + continue; 151 150 152 151 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); 153 152