From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 426KDp6hx7zF3C9 for ; Sat, 8 Sep 2018 00:14:02 +1000 (AEST) Date: Fri, 7 Sep 2018 16:13:50 +0200 From: Peter Zijlstra To: Christophe Leroy Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] perf: enum overflow in uapi/linux/perf_event.h Message-ID: <20180907141350.GK24142@hirez.programming.kicks-ass.net> References: <20180907134246.GC24106@hirez.programming.kicks-ass.net> <20180907135817.GF24106@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <20180907135817.GF24106@hirez.programming.kicks-ass.net> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Fri, Sep 07, 2018 at 03:58:17PM +0200, Peter Zijlstra wrote: > On Fri, Sep 07, 2018 at 01:50:18PM +0000, Christophe Leroy wrote: > > > > > > On 09/07/2018 01:42 PM, Peter Zijlstra wrote: > > > On Fri, Sep 07, 2018 at 01:27:19PM +0000, Christophe Leroy wrote: > > > > On PPC32, enums are 32 bits, so __PERF_SAMPLE_CALLCHAIN_EARLY is > > > > out of scope. The following sparse warning is encountered: > > > > > > > > CHECK arch/powerpc/kernel/process.c > > > > ./include/uapi/linux/perf_event.h:147:56: warning: cast truncates bits from constant value (8000000000000000 becomes 0) > > > > > > Urgh... what compiler is that? I've not seen anything like that from the > > > build bots. > > > > > > > [root@pc16082vm linux-powerpc]# sparse --version > > 0.5.2 > > > > [root@pc16082vm linux-powerpc]# ppc-linux-gcc --version > > ppc-linux-gcc (GCC) 5.4.0 > > Ah, that's a sparse warning. But does your GCC agree? The thing is, > sparse uses the C enum spec, but I suspect GCC uses the C++ enum spec > and it all works fine. What does the below proglet print on your PPC32 box? I suspect the output will be: 400000000000 and all is well. --- #include enum ponies { big = 1ULL<<46, }; int main(int argc, char **argv) { unsigned long long val = big; printf("%Lx\n", val); return 0; }