* Re: [PATCH] perf: enum overflow in uapi/linux/perf_event.h [not found] ` <20180907135817.GF24106@hirez.programming.kicks-ass.net> @ 2018-09-07 14:15 ` Christophe LEROY 2018-09-07 14:23 ` Peter Zijlstra 2018-09-07 18:43 ` Luc Van Oostenryck 0 siblings, 2 replies; 4+ messages in thread From: Christophe LEROY @ 2018-09-07 14:15 UTC (permalink / raw) To: Peter Zijlstra Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel, linuxppc-dev, linux-sparse Le 07/09/2018 à 15:58, Peter Zijlstra a écrit : > 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. > Ah yes, it seems that GCC is happy. So sparse should be fixed instead ? Anyway, is it really correct to put this constant inside that enum, after PERF_SAMPLE_MAX ? Christophe ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf: enum overflow in uapi/linux/perf_event.h 2018-09-07 14:15 ` [PATCH] perf: enum overflow in uapi/linux/perf_event.h Christophe LEROY @ 2018-09-07 14:23 ` Peter Zijlstra 2018-09-07 18:43 ` Luc Van Oostenryck 1 sibling, 0 replies; 4+ messages in thread From: Peter Zijlstra @ 2018-09-07 14:23 UTC (permalink / raw) To: Christophe LEROY Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel, linuxppc-dev, linux-sparse On Fri, Sep 07, 2018 at 04:15:33PM +0200, Christophe LEROY wrote: > Ah yes, it seems that GCC is happy. So sparse should be fixed instead ? Ideally, yes. > Anyway, is it really correct to put this constant inside that enum, after > PERF_SAMPLE_MAX ? It is a bit of a hack, agreed. What we do is use the top bit of that word (u64) for some internal state. By placing it there (after MAX) we ensure it is not available for userspace (trying to set it will return in -EINVAL) and by keeping it in the enum we know that bit is unavailable for future use. I have a patch queued that puts a little comment on that: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=perf/urgent&id=34cad593c9ea350a1811ab718e64b36e5cde870c (url is not stable, as I regenerate that git tree from quilt every so often, but it should probably last the day). ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf: enum overflow in uapi/linux/perf_event.h 2018-09-07 14:15 ` [PATCH] perf: enum overflow in uapi/linux/perf_event.h Christophe LEROY 2018-09-07 14:23 ` Peter Zijlstra @ 2018-09-07 18:43 ` Luc Van Oostenryck 2018-09-07 23:55 ` Luc Van Oostenryck 1 sibling, 1 reply; 4+ messages in thread From: Luc Van Oostenryck @ 2018-09-07 18:43 UTC (permalink / raw) To: Christophe LEROY Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel, linuxppc-dev, linux-sparse On Fri, Sep 07, 2018 at 04:15:33PM +0200, Christophe LEROY wrote: > Le 07/09/2018 à 15:58, Peter Zijlstra a écrit : > > 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. Sparse is a bit weird about the exact underlying type used for enums. > Ah yes, it seems that GCC is happy. So sparse should be fixed instead ? I'll investigate (I suppose the same is given on x86-32). -- Luc ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf: enum overflow in uapi/linux/perf_event.h 2018-09-07 18:43 ` Luc Van Oostenryck @ 2018-09-07 23:55 ` Luc Van Oostenryck 0 siblings, 0 replies; 4+ messages in thread From: Luc Van Oostenryck @ 2018-09-07 23:55 UTC (permalink / raw) To: Christophe LEROY Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel, linuxppc-dev, linux-sparse On Fri, Sep 07, 2018 at 08:43:59PM +0200, Luc Van Oostenryck wrote: > On Fri, Sep 07, 2018 at 04:15:33PM +0200, Christophe LEROY wrote: > > Le 07/09/2018 à 15:58, Peter Zijlstra a écrit : > > > 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. > > Sparse is a bit weird about the exact underlying type used for enums. > > > Ah yes, it seems that GCC is happy. So sparse should be fixed instead ? > > I'll investigate (I suppose the same is given on x86-32). It's definitively a bug in sparse. A relatively nasty one and which open a can of worms. Fortunately, I had already looked at these problems in May, I just didn't had the time to push the patches. -- Luc ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-07 23:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <a70172863fa7d3c138f788b18d36524bd45b0a73.1536326078.git.christophe.leroy@c-s.fr>
[not found] ` <20180907134246.GC24106@hirez.programming.kicks-ass.net>
[not found] ` <ae32181d-37b2-1a13-3c72-66775e05ff88@c-s.fr>
[not found] ` <20180907135817.GF24106@hirez.programming.kicks-ass.net>
2018-09-07 14:15 ` [PATCH] perf: enum overflow in uapi/linux/perf_event.h Christophe LEROY
2018-09-07 14:23 ` Peter Zijlstra
2018-09-07 18:43 ` Luc Van Oostenryck
2018-09-07 23:55 ` Luc Van Oostenryck
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).