* Re: [PATCH] x86/kernel: remove unneeded dead-store initialization
2021-03-31 8:00 [PATCH] x86/kernel: remove unneeded dead-store initialization Yang Li
@ 2021-03-31 17:49 ` Nick Desaulniers
2021-04-07 12:02 ` Borislav Petkov
2021-04-07 19:22 ` [tip: x86/cleanups] x86/cacheinfo: Remove " tip-bot2 for Yang Li
2 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2021-03-31 17:49 UTC (permalink / raw)
To: Yang Li
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
H. Peter Anvin, Nathan Chancellor, LKML, clang-built-linux
On Wed, Mar 31, 2021 at 1:00 AM Yang Li <yang.lee@linux.alibaba.com> wrote:
>
> make clang-analyzer on x86_64 defconfig caught my attention with:
>
> arch/x86/kernel/cpu/cacheinfo.c:880:24: warning: Value stored to
> 'this_cpu_ci' during its initialization is never read
> [clang-analyzer-deadcode.DeadStores]
> struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
> ^
>
> So, simply remove this unneeded dead-store initialization to make
> clang-analyzer happy.
>
> As compilers will detect this unneeded assignment and optimize this anyway,
> the resulting object code is identical before and after this change.
>
> No functional change. No change to object code.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Looks like this is from when this code was introduced in
commit 0d55ba46bfbe ("x86/cacheinfo: Move cacheinfo sysfs code to
generic infrastructure")
though this file was moved from arch/x86/kernel/cpu/intel_cacheinfo.c
to arch/x86/kernel/cpu/cacheinfo.c in
commit 1d200c078d0e ("x86/CPU: Rename intel_cacheinfo.c to cacheinfo.c")
(So I don't think a Fixes tag for 0d55ba46bfbe would be appropriate).
Thanks for the patch!
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
> ---
> arch/x86/kernel/cpu/cacheinfo.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
> index 3ca9be4..d66af29 100644
> --- a/arch/x86/kernel/cpu/cacheinfo.c
> +++ b/arch/x86/kernel/cpu/cacheinfo.c
> @@ -877,7 +877,7 @@ void init_intel_cacheinfo(struct cpuinfo_x86 *c)
> static int __cache_amd_cpumap_setup(unsigned int cpu, int index,
> struct _cpuid4_info_regs *base)
> {
> - struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
> + struct cpu_cacheinfo *this_cpu_ci;
> struct cacheinfo *this_leaf;
> int i, sibling;
>
> --
> 1.8.3.1
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] x86/kernel: remove unneeded dead-store initialization
2021-03-31 8:00 [PATCH] x86/kernel: remove unneeded dead-store initialization Yang Li
2021-03-31 17:49 ` Nick Desaulniers
@ 2021-04-07 12:02 ` Borislav Petkov
2021-04-07 17:41 ` Nick Desaulniers
2021-04-07 19:22 ` [tip: x86/cleanups] x86/cacheinfo: Remove " tip-bot2 for Yang Li
2 siblings, 1 reply; 8+ messages in thread
From: Borislav Petkov @ 2021-04-07 12:02 UTC (permalink / raw)
To: Yang Li
Cc: tglx, mingo, x86, hpa, nathan, ndesaulniers, linux-kernel,
clang-built-linux
On Wed, Mar 31, 2021 at 04:00:24PM +0800, Yang Li wrote:
> make clang-analyzer on x86_64 defconfig caught my attention with:
I can't trigger this here using:
make CC=clang-11 -j16 clang-analyzer
I get all kinds of missing python scripts:
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/lib/python3.9/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/lib/python3.9/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "/mnt/kernel/kernel/linux/./scripts/clang-tools/run-clang-tools.py", line 54, in run_analysis
p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]],
File "/usr/lib/python3.9/subprocess.py", line 501, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.9/subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1819, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'clang-tidy'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/mnt/kernel/kernel/linux/./scripts/clang-tools/run-clang-tools.py", line 74, in <module>
main()
File "/mnt/kernel/kernel/linux/./scripts/clang-tools/run-clang-tools.py", line 70, in main
pool.map(run_analysis, datastore)
File "/usr/lib/python3.9/multiprocessing/pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/usr/lib/python3.9/multiprocessing/pool.py", line 771, in get
raise self._value
FileNotFoundError: [Errno 2] No such file or directory: 'clang-tidy'
make: *** [Makefile:1914: clang-analyzer] Error 1
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 8+ messages in thread
* [tip: x86/cleanups] x86/cacheinfo: Remove unneeded dead-store initialization
2021-03-31 8:00 [PATCH] x86/kernel: remove unneeded dead-store initialization Yang Li
2021-03-31 17:49 ` Nick Desaulniers
2021-04-07 12:02 ` Borislav Petkov
@ 2021-04-07 19:22 ` tip-bot2 for Yang Li
2 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Yang Li @ 2021-04-07 19:22 UTC (permalink / raw)
To: linux-tip-commits
Cc: Abaci Robot, Yang Li, Borislav Petkov, Nick Desaulniers, x86,
linux-kernel
The following commit has been merged into the x86/cleanups branch of tip:
Commit-ID: dda451f391eee5d68db3ca87fd8b2a42c8c2b507
Gitweb: https://git.kernel.org/tip/dda451f391eee5d68db3ca87fd8b2a42c8c2b507
Author: Yang Li <yang.lee@linux.alibaba.com>
AuthorDate: Wed, 31 Mar 2021 16:00:24 +08:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Wed, 07 Apr 2021 21:12:12 +02:00
x86/cacheinfo: Remove unneeded dead-store initialization
$ make CC=clang clang-analyzer
(needs clang-tidy installed on the system too)
on x86_64 defconfig triggers:
arch/x86/kernel/cpu/cacheinfo.c:880:24: warning: Value stored to 'this_cpu_ci' \
during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
^
arch/x86/kernel/cpu/cacheinfo.c:880:24: note: Value stored to 'this_cpu_ci' \
during its initialization is never read
So simply remove this unneeded dead-store initialization.
As compilers will detect this unneeded assignment and optimize this
anyway the resulting object code is identical before and after this
change.
No functional change. No change to object code.
[ bp: Massage commit message. ]
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lkml.kernel.org/r/1617177624-24670-1-git-send-email-yang.lee@linux.alibaba.com
---
arch/x86/kernel/cpu/cacheinfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
index 3ca9be4..d66af29 100644
--- a/arch/x86/kernel/cpu/cacheinfo.c
+++ b/arch/x86/kernel/cpu/cacheinfo.c
@@ -877,7 +877,7 @@ void init_intel_cacheinfo(struct cpuinfo_x86 *c)
static int __cache_amd_cpumap_setup(unsigned int cpu, int index,
struct _cpuid4_info_regs *base)
{
- struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
+ struct cpu_cacheinfo *this_cpu_ci;
struct cacheinfo *this_leaf;
int i, sibling;
^ permalink raw reply related [flat|nested] 8+ messages in thread