From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754582AbbIIDZz (ORCPT ); Tue, 8 Sep 2015 23:25:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43492 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752623AbbIIDZq (ORCPT ); Tue, 8 Sep 2015 23:25:46 -0400 Date: Wed, 9 Sep 2015 11:25:41 +0800 From: Baoquan He To: Sedat Dilek Cc: Denys Vlasenko , Tejun Heo , Christoph Lameter , LKML , Andrew Morton , David Rientjes , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Thomas Graf , Ingo Molnar , the arch/x86 maintainers Subject: Re: [llvmlinux] percpu | bitmap issue? (Cannot boot on bare metal due to a kernel NULL pointer dereference) Message-ID: <20150909032541.GC1998@dhcp-17-102.nay.redhat.com> References: <20150909022945.GB1998@dhcp-17-102.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sedat, On 09/09/15 at 04:51am, Sedat Dilek wrote: > On Wed, Sep 9, 2015 at 4:29 AM, Baoquan He 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);