All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 5/5] cpumask: fix comment of cpumask_xxx
Date: Tue, 7 Mar 2023 18:52:11 +0100	[thread overview]
Message-ID: <CAHmME9remVPMHaHN-aSRe6ra=QcOPK+KGMgBLKCtfa8Zodt_pw@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=whsQuc-S4vuYpvi013-81UNvNc8CoTMC5AKOMT-uq_7Og@mail.gmail.com>

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

  reply	other threads:[~2023-03-07 17:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06 16:06 [PATCH 0/5] fix call cpumask_next() if no further cpus set Vernon Yang
2023-03-06 16:06 ` [PATCH 1/5] random: fix try_to_generate_entropy() " Vernon Yang
2023-03-06 16:26   ` Yury Norov
2023-03-06 16:06 ` [PATCH 2/5] wireguard: fix wg_cpumask_choose_online() " Vernon Yang
2023-03-06 16:06 ` [PATCH 3/5] scsi: lpfc: fix lpfc_cpu_affinity_check() " Vernon Yang
2023-03-06 18:48   ` Linus Torvalds
2023-03-06 20:09     ` Vernon Yang
2023-03-06 16:06 ` [PATCH 4/5] scsi: lpfc: fix lpfc_nvmet_setup_io_context() " Vernon Yang
2023-03-06 16:06 ` [PATCH 5/5] cpumask: fix comment of cpumask_xxx Vernon Yang
2023-03-06 16:39   ` Yury Norov
2023-03-06 16:44     ` Jason A. Donenfeld
2023-03-06 16:54       ` Yury Norov
2023-03-06 17:04         ` Jason A. Donenfeld
2023-03-06 17:45     ` Vernon Yang
2023-03-06 17:29   ` Linus Torvalds
2023-03-06 17:47     ` Linus Torvalds
2023-03-06 18:02       ` Linus Torvalds
     [not found]       ` <CAHmME9qN1EcfzE2ONA-B+F=8xaqZhqkEY=_npYHgtBpUFCj4Lw@mail.gmail.com>
     [not found]         ` <CAHk-=wjR6SGJhhHT6NzHcZHBJ3p5Y_JPvpQPjkeNQE+emivS6Q@mail.gmail.com>
2023-03-06 21:27           ` Linus Torvalds
2023-03-07 17:52             ` Jason A. Donenfeld [this message]
2023-03-06 18:13     ` Vernon Yang
2023-03-06 18:34       ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHmME9remVPMHaHN-aSRe6ra=QcOPK+KGMgBLKCtfa8Zodt_pw@mail.gmail.com' \
    --to=jason@zx2c4.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.