Re: [llvmlinux] percpu | bitmap issue? (Cannot boot on bare metal due to a kernel NULL pointer dereference)

From: Baoquan He
Date: Tue Sep 08 2015 - 23:26:01 EST


Hi Sedat,

On 09/09/15 at 04:51am, Sedat Dilek wrote:
> On Wed, Sep 9, 2015 at 4:29 AM, Baoquan He <bhe@xxxxxxxxxx> wrote:
> commit 1a1d48a4a8fde49aedc045d894efe67173d59fe0
> "linux/bitmap: Force inlining of bitmap weight functions"
>
> ...on top of Linux v4.2.
>
> This resulted in the same call-trace in QEMU.
>
> I hacked around to only re-build mm/percpu.c with GCC (rest with
> CLANG) with some guidance from Linus (compiler warapper-script) etc.

Sorry, from below log message and code flow I didn't get what's wrong
with it. I am working on another issue which gives me much headache,
don't hvae time to look into the the disassembling code now. But if GCC
built code works, it should be related to compiler issues. You can try
more tests, e.g build percpu.c bitmap.c with GCC. Maybe other people
can give suggestions.

Sorry again, Sedat.

setup_percpu: NR_CPUS:256 nr_cpumask_bits:256 nr_cpu_ids:1 nr_node_ids:1

arch/x86/kernel/setup_percpu.c:setup_per_cpu_areas() ->
mm/percpu.c : pcpu_embed_first_chunk() ->
mm/percpu.c:pcpu_build_alloc_info() ->
include/linux/cpumask.h:
#define num_possible_cpus() cpumask_weight(cpu_possible_mask)
static inline unsigned int cpumask_weight(const struct cpumask *srcp)
{
return bitmap_weight(cpumask_bits(srcp), nr_cpumask_bits);
}

include/linux/bitmap.h:
static inline int bitmap_weight(const unsigned long *src, unsigned int nbits)
{
if (small_const_nbits(nbits))
return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
return __bitmap_weight(src, nbits);
}

lib/bitmap.c:
int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
{
unsigned int k, lim = bits/BITS_PER_LONG;
int w = 0;

for (k = 0; k < lim; k++)
w += hweight_long(bitmap[k]);

if (bits % BITS_PER_LONG)
w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));

return w;
}
EXPORT_SYMBOL(__bitmap_weight);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/