lkml.org 
[lkml]   [2023]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [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

\
 
 \ /
  Last update: 2023-03-27 00:47    [W:0.038 / U:0.812 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site