All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] ACPI: Eliminate usage of uninitialized_var() macro
@ 2020-06-15 11:03 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-06-15 11:03 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200615040047.3535543-1-yanaijie@huawei.com>
References: <20200615040047.3535543-1-yanaijie@huawei.com>
TO: Jason Yan <yanaijie@huawei.com>
TO: rjw(a)rjwysocki.net
TO: lenb(a)kernel.org
TO: linux-acpi(a)vger.kernel.org
TO: linux-kernel(a)vger.kernel.org
CC: kernel-hardening(a)lists.openwall.com
CC: Jason Yan <yanaijie@huawei.com>
CC: Kees Cook <keescook@chromium.org>

Hi Jason,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on pm/linux-next]
[also build test WARNING on v5.8-rc1 next-20200614]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Jason-Yan/ACPI-Eliminate-usage-of-uninitialized_var-macro/20200615-120116
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
:::::: branch date: 7 hours ago
:::::: commit date: 7 hours ago
config: x86_64-randconfig-m001-20200615 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

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

smatch warnings:
drivers/acpi/acpi_pad.c:118 round_robin_cpu() error: uninitialized symbol 'preferred_cpu'.

# https://github.com/0day-ci/linux/commit/c17437ba5d3fc0096e02d985513c5897feb4bc5a
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout c17437ba5d3fc0096e02d985513c5897feb4bc5a
vim +/preferred_cpu +118 drivers/acpi/acpi_pad.c

8e0af5141ab950 Shaohua Li          2009-07-27   81  
8e0af5141ab950 Shaohua Li          2009-07-27   82  static unsigned long cpu_weight[NR_CPUS];
8e0af5141ab950 Shaohua Li          2009-07-27   83  static int tsk_in_cpu[NR_CPUS] = {[0 ... NR_CPUS-1] = -1};
8e0af5141ab950 Shaohua Li          2009-07-27   84  static DECLARE_BITMAP(pad_busy_cpus_bits, NR_CPUS);
8e0af5141ab950 Shaohua Li          2009-07-27   85  static void round_robin_cpu(unsigned int tsk_index)
8e0af5141ab950 Shaohua Li          2009-07-27   86  {
8e0af5141ab950 Shaohua Li          2009-07-27   87  	struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
8e0af5141ab950 Shaohua Li          2009-07-27   88  	cpumask_var_t tmp;
8e0af5141ab950 Shaohua Li          2009-07-27   89  	int cpu;
f67538f81e6b8d Andrew Morton       2009-11-13   90  	unsigned long min_weight = -1;
c17437ba5d3fc0 Jason Yan           2020-06-15   91  	unsigned long preferred_cpu;
8e0af5141ab950 Shaohua Li          2009-07-27   92  
8e0af5141ab950 Shaohua Li          2009-07-27   93  	if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
8e0af5141ab950 Shaohua Li          2009-07-27   94  		return;
8e0af5141ab950 Shaohua Li          2009-07-27   95  
5f160126105025 Stuart Hayes        2012-06-13   96  	mutex_lock(&round_robin_lock);
8e0af5141ab950 Shaohua Li          2009-07-27   97  	cpumask_clear(tmp);
8e0af5141ab950 Shaohua Li          2009-07-27   98  	for_each_cpu(cpu, pad_busy_cpus)
06931e62246844 Bartosz Golaszewski 2015-05-26   99  		cpumask_or(tmp, tmp, topology_sibling_cpumask(cpu));
8e0af5141ab950 Shaohua Li          2009-07-27  100  	cpumask_andnot(tmp, cpu_online_mask, tmp);
8e0af5141ab950 Shaohua Li          2009-07-27  101  	/* avoid HT sibilings if possible */
8e0af5141ab950 Shaohua Li          2009-07-27  102  	if (cpumask_empty(tmp))
8e0af5141ab950 Shaohua Li          2009-07-27  103  		cpumask_andnot(tmp, cpu_online_mask, pad_busy_cpus);
8e0af5141ab950 Shaohua Li          2009-07-27  104  	if (cpumask_empty(tmp)) {
5f160126105025 Stuart Hayes        2012-06-13  105  		mutex_unlock(&round_robin_lock);
8b29d29abc484d Lenny Szubowicz     2018-03-27  106  		free_cpumask_var(tmp);
8e0af5141ab950 Shaohua Li          2009-07-27  107  		return;
8e0af5141ab950 Shaohua Li          2009-07-27  108  	}
8e0af5141ab950 Shaohua Li          2009-07-27  109  	for_each_cpu(cpu, tmp) {
8e0af5141ab950 Shaohua Li          2009-07-27  110  		if (cpu_weight[cpu] < min_weight) {
8e0af5141ab950 Shaohua Li          2009-07-27  111  			min_weight = cpu_weight[cpu];
8e0af5141ab950 Shaohua Li          2009-07-27  112  			preferred_cpu = cpu;
8e0af5141ab950 Shaohua Li          2009-07-27  113  		}
8e0af5141ab950 Shaohua Li          2009-07-27  114  	}
8e0af5141ab950 Shaohua Li          2009-07-27  115  
8e0af5141ab950 Shaohua Li          2009-07-27  116  	if (tsk_in_cpu[tsk_index] != -1)
8e0af5141ab950 Shaohua Li          2009-07-27  117  		cpumask_clear_cpu(tsk_in_cpu[tsk_index], pad_busy_cpus);
8e0af5141ab950 Shaohua Li          2009-07-27 @118  	tsk_in_cpu[tsk_index] = preferred_cpu;
8e0af5141ab950 Shaohua Li          2009-07-27  119  	cpumask_set_cpu(preferred_cpu, pad_busy_cpus);
8e0af5141ab950 Shaohua Li          2009-07-27  120  	cpu_weight[preferred_cpu]++;
5f160126105025 Stuart Hayes        2012-06-13  121  	mutex_unlock(&round_robin_lock);
8e0af5141ab950 Shaohua Li          2009-07-27  122  
8e0af5141ab950 Shaohua Li          2009-07-27  123  	set_cpus_allowed_ptr(current, cpumask_of(preferred_cpu));
8b29d29abc484d Lenny Szubowicz     2018-03-27  124  
8b29d29abc484d Lenny Szubowicz     2018-03-27  125  	free_cpumask_var(tmp);
8e0af5141ab950 Shaohua Li          2009-07-27  126  }
8e0af5141ab950 Shaohua Li          2009-07-27  127  

:::::: The code@line 118 was first introduced by commit
:::::: 8e0af5141ab950b78b3ebbfaded5439dcf8b3a8d ACPI: create Processor Aggregator Device driver

:::::: TO: Shaohua Li <shaohua.li@intel.com>
:::::: CC: Len Brown <len.brown@intel.com>

---
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: 28530 bytes --]

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

* Re: [PATCH] ACPI: Eliminate usage of uninitialized_var() macro
  2020-06-15  4:00 Jason Yan
@ 2020-06-24 15:49 ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2020-06-24 15:49 UTC (permalink / raw)
  To: Jason Yan; +Cc: lenb, linux-acpi, linux-kernel, kernel-hardening, Kees Cook

On Monday, June 15, 2020 6:00:47 AM CEST Jason Yan wrote:
> This is an effort to eliminate the uninitialized_var() macro[1].
> 
> The use of this macro is the wrong solution because it forces off ANY
> analysis by the compiler for a given variable. It even masks "unused
> variable" warnings.
> 
> Quoted from Linus[2]:
> 
> "It's a horrible thing to use, in that it adds extra cruft to the
> source code, and then shuts up a compiler warning (even the _reliable_
> warnings from gcc)."
> 
> The gcc option "-Wmaybe-uninitialized" has been disabled and this change
> will not produce any warnnings even with "make W=1".
> 
> [1] https://github.com/KSPP/linux/issues/81
> [2] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/
> 
> Cc: Kees Cook <keescook@chromium.org>
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> ---
>  drivers/acpi/acpi_pad.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
> index e7dc0133f817..6cc4c92d9ff9 100644
> --- a/drivers/acpi/acpi_pad.c
> +++ b/drivers/acpi/acpi_pad.c
> @@ -88,7 +88,7 @@ static void round_robin_cpu(unsigned int tsk_index)
>  	cpumask_var_t tmp;
>  	int cpu;
>  	unsigned long min_weight = -1;
> -	unsigned long uninitialized_var(preferred_cpu);
> +	unsigned long preferred_cpu;
>  
>  	if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
>  		return;
> 

Applied as 5.9 material, thanks!





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

* [PATCH] ACPI: Eliminate usage of uninitialized_var() macro
@ 2020-06-15  4:00 Jason Yan
  2020-06-24 15:49 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Yan @ 2020-06-15  4:00 UTC (permalink / raw)
  To: rjw, lenb, linux-acpi, linux-kernel
  Cc: kernel-hardening, Jason Yan, Kees Cook

This is an effort to eliminate the uninitialized_var() macro[1].

The use of this macro is the wrong solution because it forces off ANY
analysis by the compiler for a given variable. It even masks "unused
variable" warnings.

Quoted from Linus[2]:

"It's a horrible thing to use, in that it adds extra cruft to the
source code, and then shuts up a compiler warning (even the _reliable_
warnings from gcc)."

The gcc option "-Wmaybe-uninitialized" has been disabled and this change
will not produce any warnnings even with "make W=1".

[1] https://github.com/KSPP/linux/issues/81
[2] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/

Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
---
 drivers/acpi/acpi_pad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index e7dc0133f817..6cc4c92d9ff9 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -88,7 +88,7 @@ static void round_robin_cpu(unsigned int tsk_index)
 	cpumask_var_t tmp;
 	int cpu;
 	unsigned long min_weight = -1;
-	unsigned long uninitialized_var(preferred_cpu);
+	unsigned long preferred_cpu;
 
 	if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
 		return;
-- 
2.25.4


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

end of thread, other threads:[~2020-06-24 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 11:03 [PATCH] ACPI: Eliminate usage of uninitialized_var() macro kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2020-06-15  4:00 Jason Yan
2020-06-24 15:49 ` Rafael J. Wysocki

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.