All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
@ 2021-10-14 13:23 Miguel Ojeda
  2021-10-14 15:01 ` Peter Zijlstra
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Miguel Ojeda @ 2021-10-14 13:23 UTC (permalink / raw)
  To: Nathan Chancellor, Nick Desaulniers
  Cc: Kees Cook, Peter Zijlstra, Miguel Ojeda, linux-kernel, llvm

`__compiletime_assert` declares a fake `extern` function
which appears (to the compiler) to be called when the test fails.

Therefore, compilers may emit possibly-uninitialized warnings
in some cases, even if it will be an error anyway (for compilers
supporting the `error` attribute, e.g. GCC and Clang >= 14)
or a link failure (for those that do not, e.g. Clang < 14).

Annotating the fake function as `__noreturn` gives them
the information they need to avoid the warning,
e.g. see https://godbolt.org/z/x1v69jjYY.

Link: https://lore.kernel.org/llvm/202110100514.3h9CI4s0-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 include/linux/compiler_types.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index b6ff83a714ca..ca1a66b8cd2f 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -298,7 +298,13 @@ struct ftrace_likely_data {
 #ifdef __OPTIMIZE__
 # define __compiletime_assert(condition, msg, prefix, suffix)		\
 	do {								\
-		extern void prefix ## suffix(void) __compiletime_error(msg); \
+		/*							\
+		 * __noreturn is needed to give the compiler enough	\
+		 * information to avoid certain possibly-uninitialized	\
+		 * warnings (regardless of the build failing).		\
+		 */							\
+		__noreturn extern void prefix ## suffix(void)		\
+			__compiletime_error(msg);			\
 		if (!(condition))					\
 			prefix ## suffix();				\
 	} while (0)
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 13:23 [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn Miguel Ojeda
@ 2021-10-14 15:01 ` Peter Zijlstra
  2021-10-14 17:48   ` Nick Desaulniers
  2021-10-14 17:26 ` Nathan Chancellor
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Peter Zijlstra @ 2021-10-14 15:01 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nathan Chancellor, Nick Desaulniers, Kees Cook, linux-kernel, llvm

On Thu, Oct 14, 2021 at 03:23:31PM +0200, Miguel Ojeda wrote:
> `__compiletime_assert` declares a fake `extern` function
> which appears (to the compiler) to be called when the test fails.
> 
> Therefore, compilers may emit possibly-uninitialized warnings
> in some cases, even if it will be an error anyway (for compilers
> supporting the `error` attribute, e.g. GCC and Clang >= 14)
> or a link failure (for those that do not, e.g. Clang < 14).
> 
> Annotating the fake function as `__noreturn` gives them
> the information they need to avoid the warning,
> e.g. see https://godbolt.org/z/x1v69jjYY.
> 
> Link: https://lore.kernel.org/llvm/202110100514.3h9CI4s0-lkp@intel.com/
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
>  include/linux/compiler_types.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index b6ff83a714ca..ca1a66b8cd2f 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -298,7 +298,13 @@ struct ftrace_likely_data {
>  #ifdef __OPTIMIZE__
>  # define __compiletime_assert(condition, msg, prefix, suffix)		\
>  	do {								\
> -		extern void prefix ## suffix(void) __compiletime_error(msg); \
> +		/*							\
> +		 * __noreturn is needed to give the compiler enough	\
> +		 * information to avoid certain possibly-uninitialized	\
> +		 * warnings (regardless of the build failing).		\
> +		 */							\
> +		__noreturn extern void prefix ## suffix(void)		\
> +			__compiletime_error(msg);			\
>  		if (!(condition))					\
>  			prefix ## suffix();				\
>  	} while (0)

Should we not convert this to _Static_assert, now that all supported
compilers are of recent enough vintage to support that?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 13:23 [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn Miguel Ojeda
  2021-10-14 15:01 ` Peter Zijlstra
@ 2021-10-14 17:26 ` Nathan Chancellor
  2021-10-14 17:36 ` Nick Desaulniers
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Nathan Chancellor @ 2021-10-14 17:26 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nick Desaulniers, Kees Cook, Peter Zijlstra, linux-kernel, llvm

On Thu, Oct 14, 2021 at 03:23:31PM +0200, Miguel Ojeda wrote:
> `__compiletime_assert` declares a fake `extern` function
> which appears (to the compiler) to be called when the test fails.
> 
> Therefore, compilers may emit possibly-uninitialized warnings
> in some cases, even if it will be an error anyway (for compilers
> supporting the `error` attribute, e.g. GCC and Clang >= 14)
> or a link failure (for those that do not, e.g. Clang < 14).
> 
> Annotating the fake function as `__noreturn` gives them
> the information they need to avoid the warning,
> e.g. see https://godbolt.org/z/x1v69jjYY.
> 
> Link: https://lore.kernel.org/llvm/202110100514.3h9CI4s0-lkp@intel.com/
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  include/linux/compiler_types.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index b6ff83a714ca..ca1a66b8cd2f 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -298,7 +298,13 @@ struct ftrace_likely_data {
>  #ifdef __OPTIMIZE__
>  # define __compiletime_assert(condition, msg, prefix, suffix)		\
>  	do {								\
> -		extern void prefix ## suffix(void) __compiletime_error(msg); \
> +		/*							\
> +		 * __noreturn is needed to give the compiler enough	\
> +		 * information to avoid certain possibly-uninitialized	\
> +		 * warnings (regardless of the build failing).		\
> +		 */							\
> +		__noreturn extern void prefix ## suffix(void)		\
> +			__compiletime_error(msg);			\
>  		if (!(condition))					\
>  			prefix ## suffix();				\
>  	} while (0)
> -- 
> 2.33.1
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 13:23 [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn Miguel Ojeda
  2021-10-14 15:01 ` Peter Zijlstra
  2021-10-14 17:26 ` Nathan Chancellor
@ 2021-10-14 17:36 ` Nick Desaulniers
  2021-10-21 23:20 ` Miguel Ojeda
  2021-12-02  6:12 ` Dan Carpenter
  4 siblings, 0 replies; 17+ messages in thread
From: Nick Desaulniers @ 2021-10-14 17:36 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nathan Chancellor, Kees Cook, Peter Zijlstra, linux-kernel, llvm,
	Marc Zyngier

On Thu, Oct 14, 2021 at 6:25 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> `__compiletime_assert` declares a fake `extern` function
> which appears (to the compiler) to be called when the test fails.
>
> Therefore, compilers may emit possibly-uninitialized warnings
> in some cases, even if it will be an error anyway (for compilers
> supporting the `error` attribute, e.g. GCC and Clang >= 14)
> or a link failure (for those that do not, e.g. Clang < 14).
>
> Annotating the fake function as `__noreturn` gives them
> the information they need to avoid the warning,
> e.g. see https://godbolt.org/z/x1v69jjYY.

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Link: https://lore.kernel.org/llvm/202110100514.3h9CI4s0-lkp@intel.com/
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
>  include/linux/compiler_types.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index b6ff83a714ca..ca1a66b8cd2f 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -298,7 +298,13 @@ struct ftrace_likely_data {
>  #ifdef __OPTIMIZE__
>  # define __compiletime_assert(condition, msg, prefix, suffix)          \
>         do {                                                            \
> -               extern void prefix ## suffix(void) __compiletime_error(msg); \
> +               /*                                                      \
> +                * __noreturn is needed to give the compiler enough     \
> +                * information to avoid certain possibly-uninitialized  \
> +                * warnings (regardless of the build failing).          \
> +                */                                                     \
> +               __noreturn extern void prefix ## suffix(void)           \
> +                       __compiletime_error(msg);                       \
>                 if (!(condition))                                       \
>                         prefix ## suffix();                             \
>         } while (0)
> --
> 2.33.1
>
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 15:01 ` Peter Zijlstra
@ 2021-10-14 17:48   ` Nick Desaulniers
  2021-10-14 18:33     ` Miguel Ojeda
  2021-10-15  8:11     ` Rasmus Villemoes
  0 siblings, 2 replies; 17+ messages in thread
From: Nick Desaulniers @ 2021-10-14 17:48 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Miguel Ojeda, Nathan Chancellor, Kees Cook, linux-kernel, llvm,
	Rasmus Villemoes, Linus Torvalds

On Thu, Oct 14, 2021 at 8:02 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Thu, Oct 14, 2021 at 03:23:31PM +0200, Miguel Ojeda wrote:
> > `__compiletime_assert` declares a fake `extern` function
> > which appears (to the compiler) to be called when the test fails.
> >
> > Therefore, compilers may emit possibly-uninitialized warnings
> > in some cases, even if it will be an error anyway (for compilers
> > supporting the `error` attribute, e.g. GCC and Clang >= 14)
> > or a link failure (for those that do not, e.g. Clang < 14).
> >
> > Annotating the fake function as `__noreturn` gives them
> > the information they need to avoid the warning,
> > e.g. see https://godbolt.org/z/x1v69jjYY.
> >
> > Link: https://lore.kernel.org/llvm/202110100514.3h9CI4s0-lkp@intel.com/
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> > ---
> >  include/linux/compiler_types.h | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> > index b6ff83a714ca..ca1a66b8cd2f 100644
> > --- a/include/linux/compiler_types.h
> > +++ b/include/linux/compiler_types.h
> > @@ -298,7 +298,13 @@ struct ftrace_likely_data {
> >  #ifdef __OPTIMIZE__
> >  # define __compiletime_assert(condition, msg, prefix, suffix)                \
> >       do {                                                            \
> > -             extern void prefix ## suffix(void) __compiletime_error(msg); \
> > +             /*                                                      \
> > +              * __noreturn is needed to give the compiler enough     \
> > +              * information to avoid certain possibly-uninitialized  \
> > +              * warnings (regardless of the build failing).          \
> > +              */                                                     \
> > +             __noreturn extern void prefix ## suffix(void)           \
> > +                     __compiletime_error(msg);                       \
> >               if (!(condition))                                       \
> >                       prefix ## suffix();                             \
> >       } while (0)
>
> Should we not convert this to _Static_assert, now that all supported
> compilers are of recent enough vintage to support that?

It's a good question; I'm pretty sure we had a thread with Rasmus on
the idea a while ago, and IIRC the answer is no.

Basically, we can't convert BUILD_BUG_ON to _Static_assert because
_Static_assert requires integer constant expressions (ICE) while many
expressions passed to BUILD_BUG_ON in the kernel require that
optimizations such as inlining run (they are not ICEs); BUILD_BUG_ON
is more flexible.  So you can't replace the guts of BUILD_BUG_ON
wholesale with _Static_assert (without doing anything else); it would
be preferable for kernel developers to use _Static_assert (I think we
have a macro, static_assert, too) in cases where they have ICEs rather
than BUILD_BUG_ON (though it flips the condition of the expression;
_Static_assert errors if the expression evaluates to false;
BUILD_BUG_ON when true), but I think there's too much muscle memory
around just using BUILD_BUG_ON that if you introduced something new,
folks wouldn't know to use that instead.

Probably a better demonstration would be to try it and observe some of
the spooky failures at build time that result.  We may be able to
separate the macro into two; BUILD_BUG_ON and BUILD_BUG_ON_OPT (or
whatever color bikeshed), where the former uses _Static_assert under
the hood, and the latter uses __attribute__((error)). Then we could go
about converting cases that could not use _Static_assert to use the
new macro, while the old macro is what folks still reach for first.

I'm not sure how worthwhile that yakshave would be, but at least the
front end of the compiler would error sooner in the case of
_Static_assert, FWIW (not much).  But I don't think we can ever
eliminate __attribute__((error)) from the kernel unless we're ok
outright removing asserts that aren't ICEs.  I would not recommend
that.  I would like to see more usage of static_assert, but I'm not
sure how best to promote that, and if it's worth discussing the subtle
distinction between BUILD_BUG_ON vs _Static_assert again and again and
again every time.
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 17:48   ` Nick Desaulniers
@ 2021-10-14 18:33     ` Miguel Ojeda
  2021-10-14 18:41       ` Miguel Ojeda
  2021-10-15  8:11     ` Rasmus Villemoes
  1 sibling, 1 reply; 17+ messages in thread
From: Miguel Ojeda @ 2021-10-14 18:33 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Peter Zijlstra, Miguel Ojeda, Nathan Chancellor, Kees Cook,
	linux-kernel, llvm, Rasmus Villemoes, Linus Torvalds

On Thu, Oct 14, 2021 at 7:49 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> It's a good question; I'm pretty sure we had a thread with Rasmus on
> the idea a while ago, and IIRC the answer is no.

Yeah, I remember that too.

> Basically, we can't convert BUILD_BUG_ON to _Static_assert because
> _Static_assert requires integer constant expressions (ICE) while many
> expressions passed to BUILD_BUG_ON in the kernel require that
> optimizations such as inlining run (they are not ICEs); BUILD_BUG_ON
> is more flexible.  So you can't replace the guts of BUILD_BUG_ON
> wholesale with _Static_assert (without doing anything else); it would
> be preferable for kernel developers to use _Static_assert (I think we
> have a macro, static_assert, too) in cases where they have ICEs rather
> than BUILD_BUG_ON (though it flips the condition of the expression;
> _Static_assert errors if the expression evaluates to false;
> BUILD_BUG_ON when true), but I think there's too much muscle memory
> around just using BUILD_BUG_ON that if you introduced something new,
> folks wouldn't know to use that instead.

Indeed, `BUILD_BUG_ON` requires the optimizer to see through whatever
you are trying to do. Way more powerful, but finicky too.

Another difference is that `_Static_assert` can be used in more places
(file scope, inside `struct`s...) for tests about e.g. sizes, i.e.
`BUILD_BUG_ON` is not a complete replacement either.

> Probably a better demonstration would be to try it and observe some of
> the spooky failures at build time that result.  We may be able to
> separate the macro into two; BUILD_BUG_ON and BUILD_BUG_ON_OPT (or
> whatever color bikeshed), where the former uses _Static_assert under
> the hood, and the latter uses __attribute__((error)). Then we could go
> about converting cases that could not use _Static_assert to use the
> new macro, while the old macro is what folks still reach for first.

That would be a nice to do, but I am not sure about introducing one
more macro about this... I think it would be simpler to submit patches
for moves into `static_assert` even if we have to "flip" the meaning.

> I'm not sure how worthwhile that yakshave would be, but at least the
> front end of the compiler would error sooner in the case of
> _Static_assert, FWIW (not much).  But I don't think we can ever
> eliminate __attribute__((error)) from the kernel unless we're ok
> outright removing asserts that aren't ICEs.  I would not recommend
> that.  I would like to see more usage of static_assert, but I'm not
> sure how best to promote that, and if it's worth discussing the subtle
> distinction between BUILD_BUG_ON vs _Static_assert again and again and
> again every time.

Perhaps we should add a comment in `BUILD_BUG*` about checking out
`static_assert` -- we have the comment in the latter, but those
reading the former will not realize the may be able to use the
latter...

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 18:33     ` Miguel Ojeda
@ 2021-10-14 18:41       ` Miguel Ojeda
  2021-10-14 18:55         ` Nick Desaulniers
  0 siblings, 1 reply; 17+ messages in thread
From: Miguel Ojeda @ 2021-10-14 18:41 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Peter Zijlstra, Miguel Ojeda, Nathan Chancellor, Kees Cook,
	linux-kernel, llvm, Rasmus Villemoes, Linus Torvalds

On Thu, Oct 14, 2021 at 8:33 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> That would be a nice to do, but I am not sure about introducing one
> more macro about this... I think it would be simpler to submit patches
> for moves into `static_assert` even if we have to "flip" the meaning.

Actually, what would be ideal is a compiler-backed lint that checks
whether it could be an `static_assert`, perhaps in clang-tidy?

It would also ensure things are kept clean.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 18:41       ` Miguel Ojeda
@ 2021-10-14 18:55         ` Nick Desaulniers
  2021-10-14 19:33           ` Miguel Ojeda
  2021-10-15  7:55           ` Rasmus Villemoes
  0 siblings, 2 replies; 17+ messages in thread
From: Nick Desaulniers @ 2021-10-14 18:55 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Peter Zijlstra, Miguel Ojeda, Nathan Chancellor, Kees Cook,
	linux-kernel, llvm, Rasmus Villemoes, Linus Torvalds,
	Joe Perches

On Thu, Oct 14, 2021 at 11:41 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Thu, Oct 14, 2021 at 8:33 PM Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
> >
> > That would be a nice to do, but I am not sure about introducing one
> > more macro about this... I think it would be simpler to submit patches
> > for moves into `static_assert` even if we have to "flip" the meaning.

$ grep -r BUILD_BUG_ON | wc -l
3405

> Actually, what would be ideal is a compiler-backed lint that checks
> whether it could be an `static_assert`, perhaps in clang-tidy?

Oh, that is a good idea.  There is one already for recommending the
use of static_assert instead of assert.  That's actually very nice.

I was playing with trying to adapt clang-tidy's C++11 `auto` fixit to
work on GNU C code to automate the replacement of:

__typeof(x) y = (x);

with:

__auto_type y = (x);

in macros.  That's perhaps interesting, too.  Given the volume of code
in the kernel, I wouldn't waste time with one off patches; rather I'd
work on automation (since clang-tidy can be taught "fixits" to fix the
code in place, not just warn) so that we can better enable treewide
changes AND keep new instances from sneaking back in easier.

Let's see if I get an intern in 2022, maybe I can have them focus on
clang-tidy+kernel.

>
> It would also ensure things are kept clean.
>
> Cheers,
> Miguel



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 18:55         ` Nick Desaulniers
@ 2021-10-14 19:33           ` Miguel Ojeda
  2021-10-15  7:55           ` Rasmus Villemoes
  1 sibling, 0 replies; 17+ messages in thread
From: Miguel Ojeda @ 2021-10-14 19:33 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Peter Zijlstra, Miguel Ojeda, Nathan Chancellor, Kees Cook,
	linux-kernel, llvm, Rasmus Villemoes, Linus Torvalds,
	Joe Perches

On Thu, Oct 14, 2021 at 8:55 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> $ grep -r BUILD_BUG_ON | wc -l
> 3405

Definitely -- I am assuming a significant part of the macro
invocations cannot be static asserts so that we would ended up with
churn anyway...

> Oh, that is a good idea.  There is one already for recommending the
> use of static_assert instead of assert.  That's actually very nice.

Happy to help!

> in the kernel, I wouldn't waste time with one off patches; rather I'd
> work on automation (since clang-tidy can be taught "fixits" to fix the
> code in place, not just warn) so that we can better enable treewide
> changes AND keep new instances from sneaking back in easier.

For automatic fixing we would need to be a bit smart due to the
negation w.r.t. "style", i.e. in most cases it should be easy to apply
it to the expression, e.g. from `!(x == 42)` to `x != 42`, but in
others it may require some "human touch".

There is also the possible mismatch of the usual style rules even if
we apply e.g. `clang-format` after it (one more reason to avoid human
formatting...).

But yeah, I think we should be able to cover the vast majority of them
easily. We can always send them as RFC patches and let folks adapt the
patch, then enable the warning/error by default after one release or
two.

> Let's see if I get an intern in 2022, maybe I can have them focus on
> clang-tidy+kernel.

It would be great to have someone adding more `linuxkernel-` checks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 18:55         ` Nick Desaulniers
  2021-10-14 19:33           ` Miguel Ojeda
@ 2021-10-15  7:55           ` Rasmus Villemoes
  1 sibling, 0 replies; 17+ messages in thread
From: Rasmus Villemoes @ 2021-10-15  7:55 UTC (permalink / raw)
  To: Nick Desaulniers, Miguel Ojeda
  Cc: Peter Zijlstra, Miguel Ojeda, Nathan Chancellor, Kees Cook,
	linux-kernel, llvm, Linus Torvalds, Joe Perches

On 14/10/2021 20.55, Nick Desaulniers wrote:
> On Thu, Oct 14, 2021 at 11:41 AM Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
>>
>> On Thu, Oct 14, 2021 at 8:33 PM Miguel Ojeda
>> <miguel.ojeda.sandonis@gmail.com> wrote:
>>>
>>> That would be a nice to do, but I am not sure about introducing one
>>> more macro about this... I think it would be simpler to submit patches
>>> for moves into `static_assert` even if we have to "flip" the meaning.
> 
> $ grep -r BUILD_BUG_ON | wc -l
> 3405
> 
>> Actually, what would be ideal is a compiler-backed lint that checks
>> whether it could be an `static_assert`, perhaps in clang-tidy?
> 
> Oh, that is a good idea.  There is one already for recommending the
> use of static_assert instead of assert.  That's actually very nice.

So I did

diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index b6ff83a714ca..e212220216e8 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -295,12 +295,17 @@ struct ftrace_likely_data {
 # define __compiletime_object_size(obj) -1
 #endif

+#include <linux/const.h>
+
 #ifdef __OPTIMIZE__
 # define __compiletime_assert(condition, msg, prefix, suffix)          \
        do {                                                            \
                extern void prefix ## suffix(void)
__compiletime_error(msg); \
+               extern void prefix ## suffix ## ice(void)
__compiletime_warning("Ice ice baby"); \
                if (!(condition))                                       \
                        prefix ## suffix();                             \
+               if (__is_constexpr(condition))                          \
+                       prefix ## suffix ## ice();                      \
        } while (0)
 #else
 # define __compiletime_assert(condition, msg, prefix, suffix) do { }
while (0)

and that throws a gazillion warnings. Picking one at random shows that
container_of() has a BUILD_BUG_ON. So we could do

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2776423a587e..0a1969b11619 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -492,9 +492,9 @@ static inline void ftrace_dump(enum ftrace_dump_mode
oops_dump_mode) { }
  */
 #define container_of(ptr, type, member) ({                             \
        void *__mptr = (void *)(ptr);                                   \
-       BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
-                        !__same_type(*(ptr), void),                    \
-                        "pointer type mismatch in container_of()");    \
+       static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
+                     __same_type(*(ptr), void),                        \
+                     "pointer type mismatch in container_of()");       \
        ((type *)(__mptr - offsetof(type, member))); })

 /**
@@ -507,9 +507,9 @@ static inline void ftrace_dump(enum ftrace_dump_mode
oops_dump_mode) { }
  */
 #define container_of_safe(ptr, type, member) ({
        \
        void *__mptr = (void *)(ptr);                                   \
-       BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
-                        !__same_type(*(ptr), void),                    \
-                        "pointer type mismatch in container_of()");    \
+       static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
+                     __same_type(*(ptr), void),                        \
+                     "pointer type mismatch in container_of_safe()");  \
        IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) :                     \
                ((type *)(__mptr - offsetof(type, member))); })

[fixing the copy-pasto in container_of_safe while at it].

Basically, all BUILD_BUG_ONs like that that do type checking are very
obviously candidates for using static_assert instead (they very
naturally go at the end of all the locally declared variables, so one
won't hit the declaration-after-statement problem that can otherwise
prevent using static_assert).

> I was playing with trying to adapt clang-tidy's C++11 `auto` fixit to
> work on GNU C code to automate the replacement of:
> 
> __typeof(x) y = (x);
> 
> with:
> 
> __auto_type y = (x);
> 
> in macros.  That's perhaps interesting, too.  Given the volume of code
> in the kernel, I wouldn't waste time with one off patches;

Well, for the kind of macros that are used _everywhere_ a few one-off
patches might be in order. It's also interesting if one could measure
any speedup from switching those core macros to static_assert.

Rasmus

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 17:48   ` Nick Desaulniers
  2021-10-14 18:33     ` Miguel Ojeda
@ 2021-10-15  8:11     ` Rasmus Villemoes
  2021-10-15 12:36       ` Miguel Ojeda
  1 sibling, 1 reply; 17+ messages in thread
From: Rasmus Villemoes @ 2021-10-15  8:11 UTC (permalink / raw)
  To: Nick Desaulniers, Peter Zijlstra
  Cc: Miguel Ojeda, Nathan Chancellor, Kees Cook, linux-kernel, llvm,
	Linus Torvalds

On 14/10/2021 19.48, Nick Desaulniers wrote:
> On Thu, Oct 14, 2021 at 8:02 AM Peter Zijlstra <peterz@infradead.org> wrote:
>>

> I'm not sure how worthwhile that yakshave would be, 

A yakshave that would be worthwhile is to kill off the macro
compiletime_assert() completely - three is a crowd. It sounds like it
would be implemented in terms of _Static_assert, but it's actually
__attribute__(error). We can fold the definition of compiletime_assert
into BUILD_BUG_ON_MSG.

The users in rwonce.h should just be changed to static_assert, and then
there are very few random users left, which can either be static_assert
or BUILD_BUG_ON_MSG.

Why do we even have a no-op version if !__OPTIMIZE__? AFAIK there's no
CONFIG_O0 option, and such a build wouldn't be interesting at all - it
can't be expected to boot, and it would likely throw warnings left and
right.

Rasmus

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-15  8:11     ` Rasmus Villemoes
@ 2021-10-15 12:36       ` Miguel Ojeda
  0 siblings, 0 replies; 17+ messages in thread
From: Miguel Ojeda @ 2021-10-15 12:36 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Nick Desaulniers, Peter Zijlstra, Miguel Ojeda,
	Nathan Chancellor, Kees Cook, linux-kernel, llvm, Linus Torvalds

On Fri, Oct 15, 2021 at 10:11 AM Rasmus Villemoes
<linux@rasmusvillemoes.dk> wrote:
>
> A yakshave that would be worthwhile is to kill off the macro
> compiletime_assert() completely - three is a crowd. It sounds like it
> would be implemented in terms of _Static_assert, but it's actually
> __attribute__(error). We can fold the definition of compiletime_assert
> into BUILD_BUG_ON_MSG.

Agreed, two should be enough.

> Why do we even have a no-op version if !__OPTIMIZE__? AFAIK there's no
> CONFIG_O0 option, and such a build wouldn't be interesting at all - it
> can't be expected to boot, and it would likely throw warnings left and
> right.

Yeah, I don't think it would compile as it is anyway.

Perhaps it is there for some kind of tooling? For a static analyzer or
something like sparse (if it didn't have its own define)...

But yeah, every use of it should have a comment explaining why it is
there, like crypto/jitterentropy.c does. There are a couple without
it.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 13:23 [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn Miguel Ojeda
                   ` (2 preceding siblings ...)
  2021-10-14 17:36 ` Nick Desaulniers
@ 2021-10-21 23:20 ` Miguel Ojeda
  2021-12-02  6:12 ` Dan Carpenter
  4 siblings, 0 replies; 17+ messages in thread
From: Miguel Ojeda @ 2021-10-21 23:20 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nathan Chancellor, Nick Desaulniers, Kees Cook, Peter Zijlstra,
	linux-kernel, llvm

On Thu, Oct 14, 2021 at 3:25 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> `__compiletime_assert` declares a fake `extern` function
> which appears (to the compiler) to be called when the test fails.

Queuing this one through my tree.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-10-14 13:23 [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn Miguel Ojeda
                   ` (3 preceding siblings ...)
  2021-10-21 23:20 ` Miguel Ojeda
@ 2021-12-02  6:12 ` Dan Carpenter
  2021-12-02  6:24   ` Dan Carpenter
  4 siblings, 1 reply; 17+ messages in thread
From: Dan Carpenter @ 2021-12-02  6:12 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nathan Chancellor, Nick Desaulniers, Kees Cook, Peter Zijlstra,
	linux-kernel, llvm

On Thu, Oct 14, 2021 at 03:23:31PM +0200, Miguel Ojeda wrote:
> `__compiletime_assert` declares a fake `extern` function
> which appears (to the compiler) to be called when the test fails.
> 
> Therefore, compilers may emit possibly-uninitialized warnings
> in some cases, even if it will be an error anyway (for compilers
> supporting the `error` attribute, e.g. GCC and Clang >= 14)
> or a link failure (for those that do not, e.g. Clang < 14).
> 
> Annotating the fake function as `__noreturn` gives them
> the information they need to avoid the warning,
> e.g. see https://godbolt.org/z/x1v69jjYY.
> 
> Link: https://lore.kernel.org/llvm/202110100514.3h9CI4s0-lkp@intel.com/
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

This patch is kind of a headache for Smatch.

The patch basically turns BUILD_BUG() into BUG().  That's fine.

But it also turn BUILD_BUG_ON(!__builtin_constant_p(foo) into a BUG_ON().
A lot of places call BUILD_BUG_ON() to ensure that functions are inlined
and the build breaks if not.  For example, the FIELD_GET() macro will
trigger a build bug if "mask" is not a compile time constant.

   295  static __always_inline u32 cal_read_field(struct cal_dev *cal, u32 offset, u32 mask)
   296  {
   297          return FIELD_GET(mask, cal_read(cal, offset));
   298  }

Unfortunately, Smatch doesn't respect the __always_inline annotation so
now it thinks cal_read_field calls BUG() and records it as a noreturn
function.  And all the callers get marked as noreturn functions as well.

Could we make it so that BUILD_BUG() is a noreturn function and
BUILD_BUG_ON() is left as it was?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
  2021-12-02  6:12 ` Dan Carpenter
@ 2021-12-02  6:24   ` Dan Carpenter
  0 siblings, 0 replies; 17+ messages in thread
From: Dan Carpenter @ 2021-12-02  6:24 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nathan Chancellor, Nick Desaulniers, Kees Cook, Peter Zijlstra,
	linux-kernel, llvm

Never mind.  I can just add some code to Smatch to ignore compile time
asserts.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
@ 2021-11-07  8:28 kernel test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2021-11-07  8:28 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 46568 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211014132331.GA4811@kernel.org>
References: <20211014132331.GA4811@kernel.org>
TO: Miguel Ojeda <ojeda@kernel.org>

Hi Miguel,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.15]
[cannot apply to next-20211106]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Miguel-Ojeda/compiler_types-mark-__compiletime_assert-failure-as-__noreturn/20211014-212525
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 348949d9a4440abdab3b1dc99a9bb660e8c7da7c
:::::: branch date: 3 weeks ago
:::::: commit date: 3 weeks ago
config: riscv-randconfig-c006-20211014 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project acb3b187c4c88650a6a717a1bcb234d27d0d7f54)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/dbc83335c8484937120e562d531c7f401aa944b2
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Miguel-Ojeda/compiler_types-mark-__compiletime_assert-failure-as-__noreturn/20211014-212525
        git checkout dbc83335c8484937120e562d531c7f401aa944b2
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   kernel/bpf/core.c:962:2: note: Loop condition is false.  Exiting loop
           BUILD_BUG_ON(BPF_REG_AX  + 1 != MAX_BPF_JIT_REG);
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   kernel/bpf/core.c:963:2: note: Taking false branch
           BUILD_BUG_ON(MAX_BPF_REG + 1 != MAX_BPF_JIT_REG);
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   kernel/bpf/core.c:963:2: note: Loop condition is false.  Exiting loop
           BUILD_BUG_ON(MAX_BPF_REG + 1 != MAX_BPF_JIT_REG);
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   kernel/bpf/core.c:982:6: note: Assuming field 'dst_reg' is not equal to __MAX_BPF_REG
           if (from->dst_reg == BPF_REG_AX || from->src_reg == BPF_REG_AX)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/bpf/core.c:982:6: note: Left side of '||' is false
   kernel/bpf/core.c:982:37: note: Assuming field 'src_reg' is not equal to __MAX_BPF_REG
           if (from->dst_reg == BPF_REG_AX || from->src_reg == BPF_REG_AX)
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/bpf/core.c:982:2: note: Taking false branch
           if (from->dst_reg == BPF_REG_AX || from->src_reg == BPF_REG_AX)
           ^
   kernel/bpf/core.c:985:6: note: Assuming field 'imm' is not equal to 0
           if (from->imm == 0 &&
               ^~~~~~~~~~~~~~
   kernel/bpf/core.c:985:21: note: Left side of '&&' is false
           if (from->imm == 0 &&
                              ^
   kernel/bpf/core.c:992:2: note: Control jumps to 'case 0:'  at line 1068
           switch (from->code) {
           ^
   kernel/bpf/core.c:1069:54: note: The right operand of '^' is a garbage value
                   *to++ = BPF_ALU32_IMM(BPF_MOV, BPF_REG_AX, imm_rnd ^ aux[0].imm);
                                                                      ^
   include/linux/filter.h:124:12: note: expanded from macro 'BPF_ALU32_IMM'
                   .imm   = IMM })
                            ^~~
   Suppressed 13 warnings (13 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   11 warnings generated.
>> mm/gup.c:708:2: warning: Value stored to 'page' is never read [clang-analyzer-deadcode.DeadStores]
           page = follow_trans_huge_pmd(vma, address, pmd, flags);
           ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:708:2: note: Value stored to 'page' is never read
           page = follow_trans_huge_pmd(vma, address, pmd, flags);
           ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1294:13: warning: Dereference of null pointer (loaded from variable 'unlocked') [clang-analyzer-core.NullDereference]
                   *unlocked = true;
                    ~~~~~~~~ ^
   mm/gup.c:1268:6: note: Assuming 'unlocked' is null
           if (unlocked)
               ^~~~~~~~
   mm/gup.c:1268:2: note: Taking false branch
           if (unlocked)
           ^
   mm/gup.c:1273:6: note: Assuming 'vma' is non-null
           if (!vma || address < vma->vm_start)
               ^~~~
   mm/gup.c:1273:6: note: Left side of '||' is false
   mm/gup.c:1273:14: note: Assuming 'address' is >= field 'vm_start'
           if (!vma || address < vma->vm_start)
                       ^~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1273:2: note: Taking false branch
           if (!vma || address < vma->vm_start)
           ^
   mm/gup.c:1276:7: note: Calling 'vma_permits_fault'
           if (!vma_permits_fault(vma, fault_flags))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1210:18: note: Assuming the condition is false
           bool write   = !!(fault_flags & FAULT_FLAG_WRITE);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1211:18: note: Assuming the condition is false
           bool foreign = !!(fault_flags & FAULT_FLAG_REMOTE);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1212:24: note: 'write' is true
           vm_flags_t vm_flags = write ? VM_WRITE : VM_READ;
                                 ^~~~~
   mm/gup.c:1212:24: note: '?' condition is true
   mm/gup.c:1214:6: note: Assuming the condition is false
           if (!(vm_flags & vma->vm_flags))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1214:2: note: Taking false branch
           if (!(vm_flags & vma->vm_flags))
           ^
   mm/gup.c:1224:7: note: Calling 'arch_vma_access_permitted'
           if (!arch_vma_access_permitted(vma, write, false, foreign))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/asm-generic/mm_hooks.h:29:2: note: Returning the value 1, which participates in a condition later
           return true;
           ^~~~~~~~~~~
   mm/gup.c:1224:7: note: Returning from 'arch_vma_access_permitted'
           if (!arch_vma_access_permitted(vma, write, false, foreign))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1224:2: note: Taking false branch
           if (!arch_vma_access_permitted(vma, write, false, foreign))
           ^
   mm/gup.c:1227:2: note: Returning the value 1, which participates in a condition later
           return true;
           ^~~~~~~~~~~
   mm/gup.c:1276:7: note: Returning from 'vma_permits_fault'
           if (!vma_permits_fault(vma, fault_flags))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1276:2: note: Taking false branch
           if (!vma_permits_fault(vma, fault_flags))
           ^
   mm/gup.c:1279:7: note: Assuming the condition is false
           if ((fault_flags & FAULT_FLAG_KILLABLE) &&
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1279:42: note: Left side of '&&' is false
           if ((fault_flags & FAULT_FLAG_KILLABLE) &&
                                                   ^
   mm/gup.c:1284:6: note: Assuming the condition is false
           if (ret & VM_FAULT_ERROR) {
               ^~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1284:2: note: Taking false branch
           if (ret & VM_FAULT_ERROR) {
           ^
   mm/gup.c:1292:6: note: Assuming the condition is true
           if (ret & VM_FAULT_RETRY) {
               ^~~~~~~~~~~~~~~~~~~~
   mm/gup.c:1292:2: note: Taking true branch
           if (ret & VM_FAULT_RETRY) {
           ^
   mm/gup.c:1294:13: note: Dereference of null pointer (loaded from variable 'unlocked')
                   *unlocked = true;
                    ~~~~~~~~ ^
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
--
                   ^        ~~~~~~
   lib/assoc_array.c:409:3: note: Value stored to 'cursor' is never read
                   cursor = parent;
                   ^        ~~~~~~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   lib/debugobjects.c:502:9: warning: Value stored to 'hint' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
                   void *hint = descr->debug_hint ?
                         ^~~~   ~~~~~~~~~~~~~~~~~~~
   lib/debugobjects.c:502:9: note: Value stored to 'hint' during its initialization is never read
                   void *hint = descr->debug_hint ?
                         ^~~~   ~~~~~~~~~~~~~~~~~~~
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   lib/math/reciprocal_div.c:51:14: warning: The result of the left shift is undefined due to shifting by '64', which is greater or equal to the width of type 'unsigned long long' [clang-analyzer-core.UndefinedBinaryOperatorResult]
           mlow = 1ULL << (32 + l);
                       ^  ~~~~~~~~
   lib/math/reciprocal_div.c:47:2: note: Taking false branch
           WARN(l == 32,
           ^
   include/asm-generic/bug.h:174:2: note: expanded from macro 'WARN'
           no_printk(format);                                              \
           ^
   include/linux/printk.h:131:2: note: expanded from macro 'no_printk'
           if (0)                                          \
           ^
   lib/math/reciprocal_div.c:51:14: note: The result of the left shift is undefined due to shifting by '64', which is greater or equal to the width of type 'unsigned long long'
           mlow = 1ULL << (32 + l);
                       ^  ~~~~~~~~
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   15 warnings generated.
   Suppressed 15 warnings (15 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   12 warnings generated.
   mm/shmem.c:1362:2: warning: Value stored to 'index' is never read [clang-analyzer-deadcode.DeadStores]
           index = page->index;
           ^       ~~~~~~~~~~~
   mm/shmem.c:1362:2: note: Value stored to 'index' is never read
           index = page->index;
           ^       ~~~~~~~~~~~
>> mm/shmem.c:1554:24: warning: Value stored to 'mapping' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct address_space *mapping = info->vfs_inode.i_mapping;
                                 ^~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/shmem.c:1554:24: note: Value stored to 'mapping' during its initialization is never read
           struct address_space *mapping = info->vfs_inode.i_mapping;
                                 ^~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 10 warnings (9 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   11 warnings generated.
   mm/percpu.c:276:44: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
           return pcpu_unit_offsets[cpu] + (page_idx << PAGE_SHIFT);
                                                     ^
   mm/percpu.c:2247:2: note: Calling 'pcpu_reclaim_populated'
           pcpu_reclaim_populated();
           ^~~~~~~~~~~~~~~~~~~~~~~~
   mm/percpu.c:2143:2: note: 'debug_locks' is 0
           lockdep_assert_held(&pcpu_lock);
           ^
   include/linux/lockdep.h:316:2: note: expanded from macro 'lockdep_assert_held'
           lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/lockdep.h:310:15: note: expanded from macro 'lockdep_assert'
           do { WARN_ON(debug_locks && !(cond)); } while (0)
                        ^~~~~~~~~~~
   include/asm-generic/bug.h:166:25: note: expanded from macro 'WARN_ON'
           int __ret_warn_on = !!(condition);                              \
                                  ^~~~~~~~~
   mm/percpu.c:2143:2: note: Left side of '&&' is false
           lockdep_assert_held(&pcpu_lock);
           ^
   include/linux/lockdep.h:316:2: note: expanded from macro 'lockdep_assert_held'
           lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
           ^
   include/linux/lockdep.h:310:27: note: expanded from macro 'lockdep_assert'
           do { WARN_ON(debug_locks && !(cond)); } while (0)
                                    ^
   mm/percpu.c:2143:2: note: Loop condition is false.  Exiting loop
           lockdep_assert_held(&pcpu_lock);
           ^
   include/linux/lockdep.h:316:2: note: expanded from macro 'lockdep_assert_held'
           lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
           ^
   include/linux/lockdep.h:310:2: note: expanded from macro 'lockdep_assert'
           do { WARN_ON(debug_locks && !(cond)); } while (0)
           ^
   mm/percpu.c:2151:2: note: Loop condition is true.  Entering loop body
           while (!list_empty(&pcpu_chunk_lists[pcpu_to_depopulate_slot])) {
           ^
   mm/percpu.c:2152:11: note: Left side of '&&' is false
                   chunk = list_first_entry(&pcpu_chunk_lists[pcpu_to_depopulate_slot],
                           ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   mm/percpu.c:2152:11: note: Taking false branch
                   chunk = list_first_entry(&pcpu_chunk_lists[pcpu_to_depopulate_slot],
                           ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   mm/percpu.c:2152:11: note: Loop condition is false.  Exiting loop
                   chunk = list_first_entry(&pcpu_chunk_lists[pcpu_to_depopulate_slot],
                           ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
--
           ^
   include/asm-generic/rwonce.h:36:2: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
           ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   include/linux/skbuff.h:1942:2: note: Loop condition is false.  Exiting loop
           WRITE_ONCE(prev->next, newsk);
           ^
   include/asm-generic/rwonce.h:60:2: note: expanded from macro 'WRITE_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:2: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
           ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   include/linux/skbuff.h:1942:2: note: Dereference of null pointer
           WRITE_ONCE(prev->next, newsk);
           ^
   include/asm-generic/rwonce.h:61:2: note: expanded from macro 'WRITE_ONCE'
           __WRITE_ONCE(x, val);                                           \
           ^~~~~~~~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:55:30: note: expanded from macro '__WRITE_ONCE'
           *(volatile typeof(x) *)&(x) = (val);                            \
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
   include/linux/skbuff.h:2048:2: warning: 2nd function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
           __skb_insert(newsk, next->prev, next, list);
           ^
   net/tipc/bcast.c:565:2: note: Calling 'tipc_bcbase_xmit'
           tipc_bcbase_xmit(net, &xmitq);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/tipc/bcast.c:184:2: note: Taking false branch
           if (skb_queue_empty(xmitq))
           ^
   net/tipc/bcast.c:189:6: note: Assuming 'bearer_id' is < 0
           if (bearer_id >= 0) {
               ^~~~~~~~~~~~~~
   net/tipc/bcast.c:189:2: note: Taking false branch
           if (bearer_id >= 0) {
           ^
   net/tipc/bcast.c:195:2: note: Calling '__skb_queue_head_init'
           __skb_queue_head_init(&_xmitq);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/tipc/bcast.c:195:2: note: Returning from '__skb_queue_head_init'
           __skb_queue_head_init(&_xmitq);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/tipc/bcast.c:196:2: note: Loop condition is true.  Entering loop body
           for (bearer_id = 0; bearer_id < MAX_BEARERS; bearer_id++) {
           ^
   net/tipc/bcast.c:197:7: note: Assuming the condition is false
                   if (!bb->dests[bearer_id])
                       ^~~~~~~~~~~~~~~~~~~~~
   net/tipc/bcast.c:197:3: note: Taking false branch
                   if (!bb->dests[bearer_id])
                   ^
   net/tipc/bcast.c:200:3: note: Loop condition is true.  Entering loop body
                   skb_queue_walk(xmitq, skb) {
                   ^
   include/linux/skbuff.h:3537:3: note: expanded from macro 'skb_queue_walk'
                   for (skb = (queue)->next;                                       \
                   ^
   net/tipc/bcast.c:202:8: note: Assuming '_skb' is non-null
                           if (!_skb)
                               ^~~~~
   net/tipc/bcast.c:202:4: note: Taking false branch
                           if (!_skb)
                           ^
   net/tipc/bcast.c:204:4: note: Calling '__skb_queue_tail'
                           __skb_queue_tail(&_xmitq, _skb);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:2081:2: note: Calling '__skb_queue_before'
           __skb_queue_before(list, (struct sk_buff *)list, newsk);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:2048:2: note: 2nd function call argument is an uninitialized value
           __skb_insert(newsk, next->prev, next, list);
           ^                   ~~~~~~~~~~
   Suppressed 14 warnings (14 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
>> mm/migrate.c:1633:3: warning: Value stored to 'gfp_mask' is never read [clang-analyzer-deadcode.DeadStores]
                   gfp_mask |= GFP_TRANSHUGE;
                   ^
   mm/migrate.c:1633:3: note: Value stored to 'gfp_mask' is never read
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   18 warnings generated.
   drivers/char/ipmi/ipmi_ssif.c:817:37: warning: Array access (via field 'rsp') results in a null pointer dereference [clang-analyzer-core.NullDereference]
                   if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) {
                                                     ^    ~~~
   drivers/char/ipmi/ipmi_ssif.c:618:6: note: Assuming 'result' is >= 0
           if (result < 0) {
               ^~~~~~~~~~
   drivers/char/ipmi/ipmi_ssif.c:618:2: note: Taking false branch
           if (result < 0) {
           ^
   drivers/char/ipmi/ipmi_ssif.c:642:7: note: Assuming 'len' is > 1
           if ((len > 1) && (ssif_info->multi_pos == 0)
                ^~~~~~~
   drivers/char/ipmi/ipmi_ssif.c:642:6: note: Left side of '&&' is true
           if ((len > 1) && (ssif_info->multi_pos == 0)
               ^
   drivers/char/ipmi/ipmi_ssif.c:642:20: note: Assuming field 'multi_pos' is equal to 0
           if ((len > 1) && (ssif_info->multi_pos == 0)
                             ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/char/ipmi/ipmi_ssif.c:642:6: note: Left side of '&&' is true
           if ((len > 1) && (ssif_info->multi_pos == 0)
               ^
   drivers/char/ipmi/ipmi_ssif.c:643:9: note: Assuming the condition is false
                                   && (data[0] == 0x00) && (data[1] == 0x01)) {
                                       ^~~~~~~~~~~~~~~
   drivers/char/ipmi/ipmi_ssif.c:643:26: note: Left side of '&&' is false
                                   && (data[0] == 0x00) && (data[1] == 0x01)) {
                                                        ^
   drivers/char/ipmi/ipmi_ssif.c:661:24: note: Field 'multi_pos' is 0
           } else if (ssif_info->multi_pos) {
                                 ^
   drivers/char/ipmi/ipmi_ssif.c:661:9: note: Taking false branch
           } else if (ssif_info->multi_pos) {
                  ^
   drivers/char/ipmi/ipmi_ssif.c:732:6: note: 'result' is >= 0
           if (result < 0) {
               ^~~~~~
   drivers/char/ipmi/ipmi_ssif.c:732:2: note: Taking false branch
           if (result < 0) {
           ^
   drivers/char/ipmi/ipmi_ssif.c:739:6: note: Assuming the condition is false
           if (ssif_info->ssif_debug & SSIF_DEBUG_STATE)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/char/ipmi/ipmi_ssif.c:739:2: note: Taking false branch
           if (ssif_info->ssif_debug & SSIF_DEBUG_STATE)
           ^
   drivers/char/ipmi/ipmi_ssif.c:744:10: note: Calling 'ipmi_ssif_lock_cond'
           flags = ipmi_ssif_lock_cond(ssif_info, &oflags);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/char/ipmi/ipmi_ssif.c:311:2: note: Value assigned to field 'curr_msg'
           spin_lock_irqsave(&ssif_info->lock, *flags);
           ^
   include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
           raw_spin_lock_irqsave(spinlock_check(lock), flags);     \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:256:11: note: expanded from macro 'raw_spin_lock_irqsave'
                   flags = _raw_spin_lock_irqsave(lock);   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/char/ipmi/ipmi_ssif.c:311:2: note: Value assigned to field 'ssif_state', which participates in a condition later
           spin_lock_irqsave(&ssif_info->lock, *flags);
           ^
   include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
           raw_spin_lock_irqsave(spinlock_check(lock), flags);     \
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:256:11: note: expanded from macro 'raw_spin_lock_irqsave'
                   flags = _raw_spin_lock_irqsave(lock);   \
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/char/ipmi/ipmi_ssif.c:311:2: note: Loop condition is false.  Exiting loop
           spin_lock_irqsave(&ssif_info->lock, *flags);
           ^
   include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
           raw_spin_lock_irqsave(spinlock_check(lock), flags);     \
           ^
   include/linux/spinlock.h:254:2: note: expanded from macro 'raw_spin_lock_irqsave'
           do {                                            \
           ^
   drivers/char/ipmi/ipmi_ssif.c:311:2: note: Loop condition is false.  Exiting loop
           spin_lock_irqsave(&ssif_info->lock, *flags);
           ^
   include/linux/spinlock.h:391:43: note: expanded from macro 'spin_lock_irqsave'

vim +/page +708 mm/gup.c

69e68b4f03135d Kirill A. Shutemov 2014-06-04  610  
080dbb618b4bc2 Aneesh Kumar K.V   2017-07-06  611  static struct page *follow_pmd_mask(struct vm_area_struct *vma,
080dbb618b4bc2 Aneesh Kumar K.V   2017-07-06  612  				    unsigned long address, pud_t *pudp,
df06b37ffe5a44 Keith Busch        2018-10-26  613  				    unsigned int flags,
df06b37ffe5a44 Keith Busch        2018-10-26  614  				    struct follow_page_context *ctx)
69e68b4f03135d Kirill A. Shutemov 2014-06-04  615  {
688272809fcce5 Huang Ying         2018-06-07  616  	pmd_t *pmd, pmdval;
69e68b4f03135d Kirill A. Shutemov 2014-06-04  617  	spinlock_t *ptl;
69e68b4f03135d Kirill A. Shutemov 2014-06-04  618  	struct page *page;
69e68b4f03135d Kirill A. Shutemov 2014-06-04  619  	struct mm_struct *mm = vma->vm_mm;
69e68b4f03135d Kirill A. Shutemov 2014-06-04  620  
080dbb618b4bc2 Aneesh Kumar K.V   2017-07-06  621  	pmd = pmd_offset(pudp, address);
688272809fcce5 Huang Ying         2018-06-07  622  	/*
688272809fcce5 Huang Ying         2018-06-07  623  	 * The READ_ONCE() will stabilize the pmdval in a register or
688272809fcce5 Huang Ying         2018-06-07  624  	 * on the stack so that it will stop changing under the code.
688272809fcce5 Huang Ying         2018-06-07  625  	 */
688272809fcce5 Huang Ying         2018-06-07  626  	pmdval = READ_ONCE(*pmd);
688272809fcce5 Huang Ying         2018-06-07  627  	if (pmd_none(pmdval))
69e68b4f03135d Kirill A. Shutemov 2014-06-04  628  		return no_page_table(vma, flags);
be9d30458913f7 Wei Yang           2020-01-30  629  	if (pmd_huge(pmdval) && is_vm_hugetlb_page(vma)) {
e66f17ff71772b Naoya Horiguchi    2015-02-11  630  		page = follow_huge_pmd(mm, address, pmd, flags);
e66f17ff71772b Naoya Horiguchi    2015-02-11  631  		if (page)
4bbd4c776a63a0 Kirill A. Shutemov 2014-06-04  632  			return page;
e66f17ff71772b Naoya Horiguchi    2015-02-11  633  		return no_page_table(vma, flags);
4bbd4c776a63a0 Kirill A. Shutemov 2014-06-04  634  	}
688272809fcce5 Huang Ying         2018-06-07  635  	if (is_hugepd(__hugepd(pmd_val(pmdval)))) {
4dc71451a2078e Aneesh Kumar K.V   2017-07-06  636  		page = follow_huge_pd(vma, address,
688272809fcce5 Huang Ying         2018-06-07  637  				      __hugepd(pmd_val(pmdval)), flags,
4dc71451a2078e Aneesh Kumar K.V   2017-07-06  638  				      PMD_SHIFT);
4dc71451a2078e Aneesh Kumar K.V   2017-07-06  639  		if (page)
4dc71451a2078e Aneesh Kumar K.V   2017-07-06  640  			return page;
4dc71451a2078e Aneesh Kumar K.V   2017-07-06  641  		return no_page_table(vma, flags);
4dc71451a2078e Aneesh Kumar K.V   2017-07-06  642  	}
84c3fc4e9c563d Zi Yan             2017-09-08  643  retry:
688272809fcce5 Huang Ying         2018-06-07  644  	if (!pmd_present(pmdval)) {
84c3fc4e9c563d Zi Yan             2017-09-08  645  		if (likely(!(flags & FOLL_MIGRATION)))
84c3fc4e9c563d Zi Yan             2017-09-08  646  			return no_page_table(vma, flags);
84c3fc4e9c563d Zi Yan             2017-09-08  647  		VM_BUG_ON(thp_migration_supported() &&
688272809fcce5 Huang Ying         2018-06-07  648  				  !is_pmd_migration_entry(pmdval));
688272809fcce5 Huang Ying         2018-06-07  649  		if (is_pmd_migration_entry(pmdval))
84c3fc4e9c563d Zi Yan             2017-09-08  650  			pmd_migration_entry_wait(mm, pmd);
688272809fcce5 Huang Ying         2018-06-07  651  		pmdval = READ_ONCE(*pmd);
688272809fcce5 Huang Ying         2018-06-07  652  		/*
688272809fcce5 Huang Ying         2018-06-07  653  		 * MADV_DONTNEED may convert the pmd to null because
c1e8d7c6a7a682 Michel Lespinasse  2020-06-08  654  		 * mmap_lock is held in read mode
688272809fcce5 Huang Ying         2018-06-07  655  		 */
688272809fcce5 Huang Ying         2018-06-07  656  		if (pmd_none(pmdval))
688272809fcce5 Huang Ying         2018-06-07  657  			return no_page_table(vma, flags);
84c3fc4e9c563d Zi Yan             2017-09-08  658  		goto retry;
84c3fc4e9c563d Zi Yan             2017-09-08  659  	}
688272809fcce5 Huang Ying         2018-06-07  660  	if (pmd_devmap(pmdval)) {
3565fce3a6597e Dan Williams       2016-01-15  661  		ptl = pmd_lock(mm, pmd);
df06b37ffe5a44 Keith Busch        2018-10-26  662  		page = follow_devmap_pmd(vma, address, pmd, flags, &ctx->pgmap);
3565fce3a6597e Dan Williams       2016-01-15  663  		spin_unlock(ptl);
3565fce3a6597e Dan Williams       2016-01-15  664  		if (page)
3565fce3a6597e Dan Williams       2016-01-15  665  			return page;
3565fce3a6597e Dan Williams       2016-01-15  666  	}
688272809fcce5 Huang Ying         2018-06-07  667  	if (likely(!pmd_trans_huge(pmdval)))
df06b37ffe5a44 Keith Busch        2018-10-26  668  		return follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);
6742d293cbe01d Kirill A. Shutemov 2016-01-15  669  
688272809fcce5 Huang Ying         2018-06-07  670  	if ((flags & FOLL_NUMA) && pmd_protnone(pmdval))
db08f2030a173f Aneesh Kumar K.V   2017-02-24  671  		return no_page_table(vma, flags);
db08f2030a173f Aneesh Kumar K.V   2017-02-24  672  
84c3fc4e9c563d Zi Yan             2017-09-08  673  retry_locked:
69e68b4f03135d Kirill A. Shutemov 2014-06-04  674  	ptl = pmd_lock(mm, pmd);
688272809fcce5 Huang Ying         2018-06-07  675  	if (unlikely(pmd_none(*pmd))) {
688272809fcce5 Huang Ying         2018-06-07  676  		spin_unlock(ptl);
688272809fcce5 Huang Ying         2018-06-07  677  		return no_page_table(vma, flags);
688272809fcce5 Huang Ying         2018-06-07  678  	}
84c3fc4e9c563d Zi Yan             2017-09-08  679  	if (unlikely(!pmd_present(*pmd))) {
84c3fc4e9c563d Zi Yan             2017-09-08  680  		spin_unlock(ptl);
84c3fc4e9c563d Zi Yan             2017-09-08  681  		if (likely(!(flags & FOLL_MIGRATION)))
84c3fc4e9c563d Zi Yan             2017-09-08  682  			return no_page_table(vma, flags);
84c3fc4e9c563d Zi Yan             2017-09-08  683  		pmd_migration_entry_wait(mm, pmd);
84c3fc4e9c563d Zi Yan             2017-09-08  684  		goto retry_locked;
84c3fc4e9c563d Zi Yan             2017-09-08  685  	}
6742d293cbe01d Kirill A. Shutemov 2016-01-15  686  	if (unlikely(!pmd_trans_huge(*pmd))) {
6742d293cbe01d Kirill A. Shutemov 2016-01-15  687  		spin_unlock(ptl);
df06b37ffe5a44 Keith Busch        2018-10-26  688  		return follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);
6742d293cbe01d Kirill A. Shutemov 2016-01-15  689  	}
4066c119483af8 Yang Shi           2021-04-29  690  	if (flags & FOLL_SPLIT_PMD) {
6742d293cbe01d Kirill A. Shutemov 2016-01-15  691  		int ret;
6742d293cbe01d Kirill A. Shutemov 2016-01-15  692  		page = pmd_page(*pmd);
6742d293cbe01d Kirill A. Shutemov 2016-01-15  693  		if (is_huge_zero_page(page)) {
6742d293cbe01d Kirill A. Shutemov 2016-01-15  694  			spin_unlock(ptl);
6742d293cbe01d Kirill A. Shutemov 2016-01-15  695  			ret = 0;
78ddc534734190 Kirill A. Shutemov 2016-01-15  696  			split_huge_pmd(vma, pmd, address);
337d9abf1cd1a5 Naoya Horiguchi    2016-07-26  697  			if (pmd_trans_unstable(pmd))
337d9abf1cd1a5 Naoya Horiguchi    2016-07-26  698  				ret = -EBUSY;
4066c119483af8 Yang Shi           2021-04-29  699  		} else {
bfe7b00de6d1e2 Song Liu           2019-09-23  700  			spin_unlock(ptl);
bfe7b00de6d1e2 Song Liu           2019-09-23  701  			split_huge_pmd(vma, pmd, address);
bfe7b00de6d1e2 Song Liu           2019-09-23  702  			ret = pte_alloc(mm, pmd) ? -ENOMEM : 0;
69e68b4f03135d Kirill A. Shutemov 2014-06-04  703  		}
6742d293cbe01d Kirill A. Shutemov 2016-01-15  704  
6742d293cbe01d Kirill A. Shutemov 2016-01-15  705  		return ret ? ERR_PTR(ret) :
df06b37ffe5a44 Keith Busch        2018-10-26  706  			follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);
69e68b4f03135d Kirill A. Shutemov 2014-06-04  707  	}
6742d293cbe01d Kirill A. Shutemov 2016-01-15 @708  	page = follow_trans_huge_pmd(vma, address, pmd, flags);
6742d293cbe01d Kirill A. Shutemov 2016-01-15  709  	spin_unlock(ptl);
df06b37ffe5a44 Keith Busch        2018-10-26  710  	ctx->page_mask = HPAGE_PMD_NR - 1;
6742d293cbe01d Kirill A. Shutemov 2016-01-15  711  	return page;
69e68b4f03135d Kirill A. Shutemov 2014-06-04  712  }
4bbd4c776a63a0 Kirill A. Shutemov 2014-06-04  713  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 31445 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn
@ 2021-11-06  9:19 kernel test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kernel test robot @ 2021-11-06  9:19 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 16202 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211014132331.GA4811@kernel.org>
References: <20211014132331.GA4811@kernel.org>
TO: Miguel Ojeda <ojeda@kernel.org>

Hi Miguel,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.15]
[cannot apply to next-20211106]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Miguel-Ojeda/compiler_types-mark-__compiletime_assert-failure-as-__noreturn/20211014-212525
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 348949d9a4440abdab3b1dc99a9bb660e8c7da7c
:::::: branch date: 3 weeks ago
:::::: commit date: 3 weeks ago
config: x86_64-randconfig-c007-20211015 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project acb3b187c4c88650a6a717a1bcb234d27d0d7f54)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/dbc83335c8484937120e562d531c7f401aa944b2
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Miguel-Ojeda/compiler_types-mark-__compiletime_assert-failure-as-__noreturn/20211014-212525
        git checkout dbc83335c8484937120e562d531c7f401aa944b2
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   drivers/hwmon/asus_atk0110.c:220:2: note: 'value' declared without an initial value
           u64 value;
           ^~~~~~~~~
   drivers/hwmon/asus_atk0110.c:223:8: note: Calling 'atk_read_value'
           err = atk_read_value(s, &value);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:635:6: note: Assuming field 'is_valid' is false
           if (!sensor->is_valid ||
               ^~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:635:24: note: Left side of '||' is true
           if (!sensor->is_valid ||
                                 ^
   drivers/hwmon/asus_atk0110.c:637:7: note: Assuming field 'old_interface' is false
                   if (sensor->data->old_interface)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:637:3: note: Taking false branch
                   if (sensor->data->old_interface)
                   ^
   drivers/hwmon/asus_atk0110.c:640:10: note: Calling 'atk_read_value_new'
                           err = atk_read_value_new(sensor, value);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:609:8: note: Calling 'atk_gitm'
           obj = atk_gitm(data, sensor->id);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:547:6: note: Assuming 'status' is equal to AE_OK
           if (status != AE_OK) {
               ^~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:547:2: note: Taking false branch
           if (status != AE_OK) {
           ^
   drivers/hwmon/asus_atk0110.c:555:6: note: Assuming field 'length' is >= 8
           if (obj->buffer.length < 8) {
               ^~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:555:2: note: Taking false branch
           if (obj->buffer.length < 8) {
           ^
   drivers/hwmon/asus_atk0110.c:561:2: note: Returning pointer (loaded from 'obj'), which participates in a condition later
           return obj;
           ^~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:609:8: note: Returning from 'atk_gitm'
           obj = atk_gitm(data, sensor->id);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:610:6: note: Calling 'IS_ERR'
           if (IS_ERR(obj))
               ^~~~~~~~~~~
   include/linux/err.h:36:9: note: Assuming the condition is true
           return IS_ERR_VALUE((unsigned long)ptr);
                  ^
   include/linux/err.h:22:34: note: expanded from macro 'IS_ERR_VALUE'
   #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
                           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   include/linux/err.h:36:2: note: Returning the value 1, which participates in a condition later
           return IS_ERR_VALUE((unsigned long)ptr);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:610:6: note: Returning from 'IS_ERR'
           if (IS_ERR(obj))
               ^~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:610:2: note: Taking true branch
           if (IS_ERR(obj))
           ^
   drivers/hwmon/asus_atk0110.c:611:3: note: Returning value, which participates in a condition later
                   return PTR_ERR(obj);
                   ^~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:640:10: note: Returning from 'atk_read_value_new'
                           err = atk_read_value_new(sensor, value);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/asus_atk0110.c:642:7: note: Assuming 'err' is 0
                   if (err)
                       ^~~
   drivers/hwmon/asus_atk0110.c:642:3: note: Taking false branch
                   if (err)
                   ^
   drivers/hwmon/asus_atk0110.c:647:24: note: Assigned value is garbage or undefined
                   sensor->cached_value = *value;
                                        ^ ~~~~~~
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
>> mm/memory.c:1132:20: warning: Value stored to 'src_mm' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct mm_struct *src_mm = src_vma->vm_mm;
                             ^~~~~~   ~~~~~~~~~~~~~~
   mm/memory.c:1132:20: note: Value stored to 'src_mm' during its initialization is never read
           struct mm_struct *src_mm = src_vma->vm_mm;
                             ^~~~~~   ~~~~~~~~~~~~~~
   mm/memory.c:1169:20: warning: Value stored to 'src_mm' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct mm_struct *src_mm = src_vma->vm_mm;
                             ^~~~~~   ~~~~~~~~~~~~~~
   mm/memory.c:1169:20: note: Value stored to 'src_mm' during its initialization is never read
           struct mm_struct *src_mm = src_vma->vm_mm;
                             ^~~~~~   ~~~~~~~~~~~~~~
   mm/memory.c:2543:3: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
                   pte_unmap_unlock(mapped_pte, ptl);
                   ^
   include/linux/mm.h:2274:2: note: expanded from macro 'pte_unmap_unlock'
           spin_unlock(ptl);                               \
           ^
   mm/memory.c:2715:9: note: Calling '__apply_to_page_range'
           return __apply_to_page_range(mm, addr, size, fn, data, false);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/memory.c:2667:14: note: Assuming 'addr' is < 'end'
           if (WARN_ON(addr >= end))
                       ^
   include/asm-generic/bug.h:121:25: note: expanded from macro 'WARN_ON'
           int __ret_warn_on = !!(condition);                              \
                                  ^~~~~~~~~
   mm/memory.c:2667:6: note: Taking false branch
           if (WARN_ON(addr >= end))
               ^
   include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
           if (unlikely(__ret_warn_on))                                    \
           ^
   mm/memory.c:2667:2: note: Taking false branch
           if (WARN_ON(addr >= end))
           ^
   mm/memory.c:2672:10: note: Assuming the condition is false
                   next = pgd_addr_end(addr, end);
                          ^
   include/linux/pgtable.h:761:3: note: expanded from macro 'pgd_addr_end'
           (__boundary - 1 < (end) - 1)? __boundary: (end);                \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/memory.c:2672:10: note: '?' condition is false
                   next = pgd_addr_end(addr, end);
                          ^
   include/linux/pgtable.h:761:2: note: expanded from macro 'pgd_addr_end'
           (__boundary - 1 < (end) - 1)? __boundary: (end);                \
           ^
   mm/memory.c:2673:7: note: Assuming the condition is false
                   if (pgd_none(*pgd) && !create)
                       ^~~~~~~~~~~~~~
   mm/memory.c:2673:22: note: Left side of '&&' is false
                   if (pgd_none(*pgd) && !create)
                                      ^
   mm/memory.c:2675:7: note: Taking false branch
                   if (WARN_ON_ONCE(pgd_leaf(*pgd)))
                       ^
   include/asm-generic/bug.h:105:2: note: expanded from macro 'WARN_ON_ONCE'
           if (unlikely(__ret_warn_on))                            \
           ^
   mm/memory.c:2675:3: note: Taking false branch
                   if (WARN_ON_ONCE(pgd_leaf(*pgd)))
                   ^
   mm/memory.c:2677:7: note: Assuming the condition is false
                   if (!pgd_none(*pgd) && WARN_ON_ONCE(pgd_bad(*pgd))) {
                       ^~~~~~~~~~~~~~~
   mm/memory.c:2677:23: note: Left side of '&&' is false
                   if (!pgd_none(*pgd) && WARN_ON_ONCE(pgd_bad(*pgd))) {
                                       ^
   mm/memory.c:2682:9: note: Calling 'apply_to_p4d_range'
                   err = apply_to_p4d_range(mm, pgd, addr, next,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/memory.c:2630:6: note: 'create' is false
           if (create) {
               ^~~~~~
   mm/memory.c:2630:2: note: Taking false branch
           if (create) {
           ^
   mm/memory.c:2638:10: note: Assuming the condition is false
                   next = p4d_addr_end(addr, end);
                          ^
   include/linux/pgtable.h:767:3: note: expanded from macro 'p4d_addr_end'
           (__boundary - 1 < (end) - 1)? __boundary: (end);                \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/memory.c:2638:10: note: '?' condition is false
                   next = p4d_addr_end(addr, end);
                          ^
   include/linux/pgtable.h:767:2: note: expanded from macro 'p4d_addr_end'
           (__boundary - 1 < (end) - 1)? __boundary: (end);                \
           ^
   mm/memory.c:2639:7: note: Calling 'p4d_none'
                   if (p4d_none(*p4d) && !create)
                       ^~~~~~~~~~~~~~
   arch/x86/include/asm/pgtable.h:872:9: note: Assuming the condition is false
           return (native_p4d_val(p4d) & ~(_PAGE_KNL_ERRATUM_MASK)) == 0;
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/x86/include/asm/pgtable.h:872:2: note: Returning zero, which participates in a condition later
           return (native_p4d_val(p4d) & ~(_PAGE_KNL_ERRATUM_MASK)) == 0;
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/memory.c:2639:7: note: Returning from 'p4d_none'
                   if (p4d_none(*p4d) && !create)

vim +/src_mm +1132 mm/memory.c

^1da177e4c3f41 Linus Torvalds   2005-04-16  1125  
c78f463649d60f Peter Xu         2020-10-13  1126  static inline int
c78f463649d60f Peter Xu         2020-10-13  1127  copy_pmd_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
c78f463649d60f Peter Xu         2020-10-13  1128  	       pud_t *dst_pud, pud_t *src_pud, unsigned long addr,
c78f463649d60f Peter Xu         2020-10-13  1129  	       unsigned long end)
^1da177e4c3f41 Linus Torvalds   2005-04-16  1130  {
c78f463649d60f Peter Xu         2020-10-13  1131  	struct mm_struct *dst_mm = dst_vma->vm_mm;
c78f463649d60f Peter Xu         2020-10-13 @1132  	struct mm_struct *src_mm = src_vma->vm_mm;
^1da177e4c3f41 Linus Torvalds   2005-04-16  1133  	pmd_t *src_pmd, *dst_pmd;
^1da177e4c3f41 Linus Torvalds   2005-04-16  1134  	unsigned long next;
^1da177e4c3f41 Linus Torvalds   2005-04-16  1135  
^1da177e4c3f41 Linus Torvalds   2005-04-16  1136  	dst_pmd = pmd_alloc(dst_mm, dst_pud, addr);
^1da177e4c3f41 Linus Torvalds   2005-04-16  1137  	if (!dst_pmd)
^1da177e4c3f41 Linus Torvalds   2005-04-16  1138  		return -ENOMEM;
^1da177e4c3f41 Linus Torvalds   2005-04-16  1139  	src_pmd = pmd_offset(src_pud, addr);
^1da177e4c3f41 Linus Torvalds   2005-04-16  1140  	do {
^1da177e4c3f41 Linus Torvalds   2005-04-16  1141  		next = pmd_addr_end(addr, end);
84c3fc4e9c563d Zi Yan           2017-09-08  1142  		if (is_swap_pmd(*src_pmd) || pmd_trans_huge(*src_pmd)
84c3fc4e9c563d Zi Yan           2017-09-08  1143  			|| pmd_devmap(*src_pmd)) {
71e3aac0724ffe Andrea Arcangeli 2011-01-13  1144  			int err;
c78f463649d60f Peter Xu         2020-10-13  1145  			VM_BUG_ON_VMA(next-addr != HPAGE_PMD_SIZE, src_vma);
8f34f1eac3820f Peter Xu         2021-06-30  1146  			err = copy_huge_pmd(dst_mm, src_mm, dst_pmd, src_pmd,
8f34f1eac3820f Peter Xu         2021-06-30  1147  					    addr, dst_vma, src_vma);
71e3aac0724ffe Andrea Arcangeli 2011-01-13  1148  			if (err == -ENOMEM)
71e3aac0724ffe Andrea Arcangeli 2011-01-13  1149  				return -ENOMEM;
71e3aac0724ffe Andrea Arcangeli 2011-01-13  1150  			if (!err)
71e3aac0724ffe Andrea Arcangeli 2011-01-13  1151  				continue;
71e3aac0724ffe Andrea Arcangeli 2011-01-13  1152  			/* fall through */
71e3aac0724ffe Andrea Arcangeli 2011-01-13  1153  		}
^1da177e4c3f41 Linus Torvalds   2005-04-16  1154  		if (pmd_none_or_clear_bad(src_pmd))
^1da177e4c3f41 Linus Torvalds   2005-04-16  1155  			continue;
c78f463649d60f Peter Xu         2020-10-13  1156  		if (copy_pte_range(dst_vma, src_vma, dst_pmd, src_pmd,
c78f463649d60f Peter Xu         2020-10-13  1157  				   addr, next))
^1da177e4c3f41 Linus Torvalds   2005-04-16  1158  			return -ENOMEM;
^1da177e4c3f41 Linus Torvalds   2005-04-16  1159  	} while (dst_pmd++, src_pmd++, addr = next, addr != end);
^1da177e4c3f41 Linus Torvalds   2005-04-16  1160  	return 0;
^1da177e4c3f41 Linus Torvalds   2005-04-16  1161  }
^1da177e4c3f41 Linus Torvalds   2005-04-16  1162  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34210 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-12-02  6:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 13:23 [PATCH] compiler_types: mark __compiletime_assert failure as __noreturn Miguel Ojeda
2021-10-14 15:01 ` Peter Zijlstra
2021-10-14 17:48   ` Nick Desaulniers
2021-10-14 18:33     ` Miguel Ojeda
2021-10-14 18:41       ` Miguel Ojeda
2021-10-14 18:55         ` Nick Desaulniers
2021-10-14 19:33           ` Miguel Ojeda
2021-10-15  7:55           ` Rasmus Villemoes
2021-10-15  8:11     ` Rasmus Villemoes
2021-10-15 12:36       ` Miguel Ojeda
2021-10-14 17:26 ` Nathan Chancellor
2021-10-14 17:36 ` Nick Desaulniers
2021-10-21 23:20 ` Miguel Ojeda
2021-12-02  6:12 ` Dan Carpenter
2021-12-02  6:24   ` Dan Carpenter
2021-11-06  9:19 kernel test robot
2021-11-07  8:28 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.