x86/boot: clean up headers
PATCH 1/1 x86/boot: clean up headers
The inclusion of <linux/kernel.h> was causing issue as the definition of __arch_hweight64 from arch/x86/include/asm/arch_hweight.h eventually gets included. The definition is problematic when compiled with -m16 (all code in arch/x86/boot/ is) as the "D" inline assembly constraint is rejected by both compilers when passed an argument of type long long (regardless of signedness, anything smaller is fine).
Because GCC performs inlining before semantic analysis, and __arch_hweight64 is dead in this translation unit, GCC does not report any issues at compile time. Clang does the semantic analysis in the front end, before inlining (run in the middle) can determine the code is dead. I consider this another case of PR33587, which I think we can do more work to solve.
It turns out that arch/x86/boot/string.c doesn't actually need linux/kernel.h, simply linux/limits.h and linux/compiler.h. Include them, and sort the headers alphabetically.
---
Note that this only regresses for us on linux-next (not mainline).
arch/x86/boot/string.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/x86/boot/string.c +4 -3
@@ -12,10 +12,11 @@* Very basic string functions */ -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/errno.h> #include <asm/asm.h> +#include <linux/compiler.h> +#include <linux/errno.h> +#include <linux/limits.h> +#include <linux/types.h> #include "ctype.h" #include "string.h"
Signature · 1 line
2.21.0.352.gf09ad66450-goog
Quoted 14 lines · Nick Desaulniers
The inclusion of <
linux/kernel.h> was causing issue as the definition of__arch_hweight64fromarch/x86/include/asm/arch_hweight.heventually gets included. The definition is problematic when compiled with -m16 (all code inarch/x86/boot/is) as the "D" inline assembly constraint is rejected by both compilers when passed an argument of type long long (regardless of signedness, anything smaller is fine).Because GCC performs inlining before semantic analysis, and
__arch_hweight64is dead in this translation unit, GCC does not report any issues at compile time. Clang does the semantic analysis in the front end, before inlining (run in the middle) can determine the code is dead. I consider this another case of PR33587, which I think we can do more work to solve.
Quoted 7 lines
It turns out that
arch/x86/boot/string.cdoesn't actually needlinux/kernel.h, simplylinux/limits.handlinux/compiler.h. Include them, and sort the headers alphabetically.
Quoted 28 lines
---
Note that this only regresses for us on linux-next (not mainline).arch/x86/boot/string.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)arch/x86/boot/string.c +4
-3@@ -12,10 +12,11 @@* Very basic string functions */ -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/errno.h> #include <asm/asm.h> +#include <linux/compiler.h> +#include <linux/errno.h> +#include <linux/limits.h> +#include <linux/types.h> #include "ctype.h" #include "string.h" Signature · 1 line
2.21.0.352.gf09ad66450-goog
Hi Nick,
Quoted 4 lines · On Fri, 1 Mar 2019 16:07:14 -0800 Nick Desaulniers <[email protected]>…
It turns out that
arch/x86/boot/string.cdoesn't actually needlinux/kernel.h, simplylinux/limits.handlinux/compiler.h. Include them, and sort the headers alphabetically.
One small nit: please do not do the sort in the same commit as the bug fix. It just complicates the review and has (a remote) possibility of adding a new problem. (Not a big issue here, but in general cleanups and bug fixes should be separate.)
Signature · 2 lines
Cheers, Stephen Rothwell
Hi Nick,
Quoted 11 lines · On Sat, 2 Mar 2019 13:27:50 +1100 Stephen Rothwell <[email protected]> wrote:
Quoted 4 lines · On Fri, 1 Mar 2019 16:07:14 -0800 Nick Desaulniers <[email protected]>…
It turns out that
arch/x86/boot/string.cdoesn't actually needlinux/kernel.h, simplylinux/limits.handlinux/compiler.h. Include them, and sort the headers alphabetically.One small nit: please do not do the sort in the same commit as the bug fix. It just complicates the review and has (a remote) possibility of adding a new problem. (Not a big issue here, but in general cleanups and bug fixes should be separate.)
Also it is *very* common for headers to be included in the order:
linux/ asm/ and then local.
Signature · 2 lines
Cheers, Stephen Rothwell
PATCH v2 1/1 x86/boot: clean up headers
In reply to Stephen RothwellThe inclusion of <linux/kernel.h> was causing issue as the definition of __arch_hweight64 from arch/x86/include/asm/arch_hweight.h eventually gets included. The definition is problematic when compiled with -m16 (all code in arch/x86/boot/ is) as the "D" inline assembly constraint is rejected by both compilers when passed an argument of type long long (regardless of signedness, anything smaller is fine).
Because GCC performs inlining before semantic analysis, and __arch_hweight64 is dead in this translation unit, GCC does not report any issues at compile time. Clang does the semantic analysis in the front end, before inlining (run in the middle) can determine the code is dead. I consider this another case of PR33587, which I think we can do more work to solve.
It turns out that arch/x86/boot/string.c doesn't actually need linux/kernel.h, simply linux/limits.h and linux/compiler.h. Include them, and sort the headers alphabetically.
---
Changes V1 -> V2:
* Add Reviewed, Tested, Suggested tags.
* Drop linux/types.h; it's included in linux/limits.h.
My original intention was to unsort the headers (sorted in V1), but if we drop the out of place linux/types.h, then we can insert the two more specific headers in alphabetic order.
arch/x86/boot/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/boot/string.c +2 -2
@@ -12,9 +12,9 @@* Very basic string functions */ -#include <linux/types.h> -#include <linux/kernel.h> +#include <linux/compiler.h> #include <linux/errno.h> +#include <linux/limits.h> #include <asm/asm.h> #include "ctype.h" #include "string.h"
Signature · 1 line
2.21.0.352.gf09ad66450-goog
Hi Nick,
Quoted 8 lines · On Mon, 4 Mar 2019 09:50:16 -0800 Nick Desaulniers <[email protected]>…
Changes V1 -> V2:
* Add Reviewed, Tested, Suggested tags.
* Droplinux/types.h; it's included inlinux/limits.h.My original intention was to unsort the headers (sorted in V1), but if we drop the out of place
linux/types.h, then we can insert the two more specific headers in alphabetic order.
I don't understand why you care about the include file ordering.
Also, since this file uses things from linux/types.h, I would argue that we need the explicit include of linux/types.h. Just imagine if someone at a later date reomves the linux/types.h include from linux/limits.h (however unlikely that is).
Just do your bug fix.
Signature · 2 lines
Cheers, Stephen Rothwell
PATCH v3 1/1 x86/boot: clean up headers
The inclusion of <linux/kernel.h> was causing issue as the definition of __arch_hweight64 from arch/x86/include/asm/arch_hweight.h eventually gets included. The definition is problematic when compiled with -m16 (all code in arch/x86/boot/ is) as the "D" inline assembly constraint is rejected by both compilers when passed an argument of type long long (regardless of signedness, anything smaller is fine).
Because GCC performs inlining before semantic analysis, and __arch_hweight64 is dead in this translation unit, GCC does not report any issues at compile time. Clang does the semantic analysis in the front end, before inlining (run in the middle) can determine the code is dead. I consider this another case of PR33587, which I think we can do more work to solve.
It turns out that arch/x86/boot/string.c doesn't actually need linux/kernel.h, simply linux/limits.h and linux/compiler.h. Include them, and sort the headers alphabetically.
---
Changes V2 -> V3:
* keep linux/types.h
Changes V1 -> V2:
* Add Reviewed, Tested, Suggested tags.
* Drop linux/types.h; it's included in linux/limits.h.
arch/x86/boot/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/boot/string.c +2 -1
@@ -13,8 +13,9 @@*/ #include <linux/types.h> -#include <linux/kernel.h> +#include <linux/compiler.h> #include <linux/errno.h> +#include <linux/limits.h> #include <asm/asm.h> #include "ctype.h" #include "string.h"
Signature · 1 line
2.21.0.352.gf09ad66450-goog
Quoted 15 lines · Nick Desaulniers
The inclusion of <
linux/kernel.h> was causing issue as the definition of__arch_hweight64fromarch/x86/include/asm/arch_hweight.heventually gets included. The definition is problematic when compiled with -m16 (all code inarch/x86/boot/is) as the "D" inline assembly constraint is rejected by both compilers when passed an argument of type long long (regardless of signedness, anything smaller is fine).Because GCC performs inlining before semantic analysis, and
__arch_hweight64is dead in this translation unit, GCC does not report any issues at compile time. Clang does the semantic analysis in the front end, before inlining (run in the middle) can determine the code is dead. I consider this another case of PR33587, which I think we can do more work to solve.
Quoted 3 lines
It turns out that
arch/x86/boot/string.cdoesn't actually needlinux/kernel.h, simplylinux/limits.handlinux/compiler.h. Include them, and sort the headers alphabetically.
Well, should have cut that out of the commit message too in V3...sigh. Boris assuming everyone's ok with this patch; can you just drop this sentence from the commit message should you apply the patch (or shall I send a v4)?
Quoted 36 lines
Reviewed-by Nathan Chancellor <[email protected]>Tested-by Nathan Chancellor <[email protected]>Suggested-by Stephen Rothwell <[email protected]>Signed-off-by Nick Desaulniers <[email protected]>---
Changes V2 -> V3:
* keeplinux/types.hChanges V1 -> V2:
* Add Reviewed, Tested, Suggested tags.
* Droplinux/types.h; it's included inlinux/limits.h.arch/x86/boot/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/boot/string.c +2
-2@@ -13,8 +13,9 @@*/ #include <linux/types.h> -#include <linux/kernel.h> +#include <linux/compiler.h> #include <linux/errno.h> +#include <linux/limits.h> #include <asm/asm.h> #include "ctype.h" #include "string.h" --2.21.0.352.gf09ad66450-goog
Signature · 2 lines
Thanks, ~Nick Desaulniers
Borislav Petkov
maintainerQuoted 4 lines · Nick Desaulniers
Well, should have cut that out of the commit message too in V3...sigh. Boris assuming everyone's ok with this patch; can you just drop this sentence from the commit message should you apply the patch (or shall I send a v4)?
I'll take a look once the merge window is over and all the dust settles.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.PATCH v4 1/1 x86/boot: clean up headers
The inclusion of <linux/kernel.h> was causing issue as the definition of __arch_hweight64 from arch/x86/include/asm/arch_hweight.h eventually gets included. The definition is problematic when compiled with -m16 (all code in arch/x86/boot/ is) as the "D" inline assembly constraint is rejected by both compilers when passed an argument of type long long (regardless of signedness, anything smaller is fine).
Because GCC performs inlining before semantic analysis, and __arch_hweight64 is dead in this translation unit, GCC does not report any issues at compile time. Clang does the semantic analysis in the front end, before inlining (run in the middle) can determine the code is dead. I consider this another case of PR33587, which I think we can do more work to solve.
It turns out that arch/x86/boot/string.c doesn't actually need linux/kernel.h, simply linux/limits.h and linux/compiler.h.
---
Changes V3 -> V4:
* Drop sentence from commit message about sorting headers.
Changes V2 -> V3:
* keep linux/types.h
Changes V1 -> V2:
* Add Reviewed, Tested, Suggested tags.
* Drop linux/types.h; it's included in linux/limits.h.
arch/x86/boot/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/boot/string.c +2 -1
@@ -13,8 +13,9 @@*/ #include <linux/types.h> -#include <linux/kernel.h> +#include <linux/compiler.h> #include <linux/errno.h> +#include <linux/limits.h> #include <asm/asm.h> #include "ctype.h" #include "string.h"
Signature · 1 line
2.21.0.360.g471c308f928-goog
tip-bot for Nick Desaulniers
merge bot[tip:x86/urgent] x86/boot: Restrict header scope to make Clang happy
x86/boot: Restrict header scope to make Clang happy
Commit-ID: a9c640ac96e19b3966357ec9bb586edd2e1e74de Gitweb: https://git.kernel.org/tip/a9c640ac96e19b3966357ec9bb586edd2e1e74de Author: Nick Desaulniers <[email protected]> AuthorDate: Thu, 14 Mar 2019 15:14:57 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 21 Mar 2019 12:24:38 +0100
x86/boot: Restrict header scope to make Clang happy
The inclusion of <linux/kernel.h> was causing issue as the definition of __arch_hweight64 from arch/x86/include/asm/arch_hweight.h eventually gets included. The definition is problematic when compiled with -m16 (all code in arch/x86/boot/ is) as the "D" inline assembly constraint is rejected by both compilers when passed an argument of type long long (regardless of signedness, anything smaller is fine).
Because GCC performs inlining before semantic analysis, and __arch_hweight64 is dead in this translation unit, GCC does not report any issues at compile time. Clang does the semantic analysis in the front end, before inlining (run in the middle) can determine the code is dead. I consider this another case of PR33587, which I think we can do more work to solve.
It turns out that arch/x86/boot/string.c doesn't actually need linux/kernel.h, simply linux/limits.h and linux/compiler.h.
--- arch/x86/boot/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/boot/string.c +2 -1
@@ -13,8 +13,9 @@*/ #include <linux/types.h> -#include <linux/kernel.h> +#include <linux/compiler.h> #include <linux/errno.h> +#include <linux/limits.h> #include <asm/asm.h> #include "ctype.h" #include "string.h"