Messages in this thread | | | From | "Jason A. Donenfeld" <> | Date | Tue, 7 Mar 2023 18:52:11 +0100 | Subject | Re: [PATCH 5/5] cpumask: fix comment of cpumask_xxx |
| |
Hi Linus,
On Mon, Mar 6, 2023 at 10:28 PM Linus Torvalds <torvalds@linux-foundation.org> wrote: > > I'm looking at wg_cpumask_next_online(), and this: > > while (unlikely(!cpumask_test_cpu(cpu, cpu_online_mask))) > cpu = cpumask_next(cpu, cpu_online_mask) % nr_cpumask_bits; > > seems very dodgy indeed. I'm not convinced it might not cause an endless loop.
Indeed this code is crap and wrong in multiple ways. I can probably simplify to something like
static inline int wg_cpumask_next_online(int *last_cpu) { int cpu = cpumask_next(*last_cpu, cpu_online_mask); if (cpu >= nr_cpu_ids) cpumask_first(cpu_online_mask);
as you suggested, which is indeed a lot more straightforward.
I'll get this all cleaned up.
Jason
| |