[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wh5E-xdc5P6SfN-ey6zvVri43rTj0g8kjUBWD3hhE-jiw@mail.gmail.com>
Date: Thu, 12 May 2022 12:10:55 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Test Bot <zgrieee@...il.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Mike Christie <michael.christie@...cle.com>,
Mingzhe Zou <mingzhe.zou@...ystack.cn>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-scsi <linux-scsi@...r.kernel.org>,
target-devel <target-devel@...r.kernel.org>
Subject: Re: ERROR: drivers: iscsi: iscsi_target.c
On Thu, May 12, 2022 at 11:42 AM Test Bot <zgrieee@...il.com> wrote:
>
> void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
> {
> int ord, cpu;
> cpumask_t conn_allowed_cpumask;
Yeah, that's not how you are supposed to use 'cpumask_t'
This is why we have CONFIG_CPUMASK_OFFSTACK and 'cpumask_var_t', so
that the pattern is
cpumask_var_t mask;
if (!alloc_cpumask_var(&mask, GFP_KERNEL))
return -ENOMEM;
... use 'mask' here as a ...
free_cpumask_var(mask);
and if the cpumask is small, it's allocated on the stack (and that
'alloc_cpumask_var()' becomes a no-op) and if it's huge, it has a real
allocation so that the stack frame doesn't grow too big.
The problem seems to have been introduced in this merge window by
commit d72d827f2f26 ("scsi: target: Add iscsi/cpus_allowed_list in
configfs"), but I didn't really look any closer than a plain "git
blame", so it might have happened before that too.
I also didn't check whether there was some explicit reason why the
code couldn't allocate the cpumask this way.
Btw, it's worth noting that 'cpumask_t' is always the full static
compile-time NR_CPUS bits in size, but a dynamically allocated
'cpumask_var_t' is only nr_cpumask_bits in size (ie the actual maximum
on that machine, as opposed to the theoretical maximum size). So they
are *not* exactly the same kind of 'cpumask_t' pointer in the end, but
no sane code should care (ie you have to do something else wrong for
the alloc_cpumask_var() pattern to not work).
Linus
Powered by blists - more mailing lists