All of lore.kernel.org
 help / color / mirror / Atom feed
* [rcu:dev.2021.05.02a 114/114] kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used
@ 2021-05-06  2:16 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-05-06  2:16 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: kbuild-all, linux-kernel

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev.2021.05.02a
head:   35d2c62851bc03a945ae81ab0726985f726107b1
commit: 35d2c62851bc03a945ae81ab0726985f726107b1 [114/114] refscale: Add measurement of clock readout
config: nios2-randconfig-r014-20210505 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0
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://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?id=35d2c62851bc03a945ae81ab0726985f726107b1
        git remote add rcu https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
        git fetch --no-tags rcu dev.2021.05.02a
        git checkout 35d2c62851bc03a945ae81ab0726985f726107b1
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=nios2 

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

All warnings (new ones prefixed by >>):

   kernel/rcu/refscale.c: In function 'ref_clock_section':
>> kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
     472 |  volatile u64 x;
         |               ^
   kernel/rcu/refscale.c: In function 'ref_clock_delay_section':
   kernel/rcu/refscale.c:484:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
     484 |  volatile u64 x;
         |               ^


vim +/x +472 kernel/rcu/refscale.c

   469	
   470	static void ref_clock_section(const int nloops)
   471	{
 > 472		volatile u64 x;
   473		int i;
   474	
   475		preempt_disable();
   476		for (i = nloops; i >= 0; i--) {
   477			x = ktime_get_real_fast_ns();
   478		}
   479		preempt_enable();
   480	}
   481	

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

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

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

* [rcu:dev.2021.05.02a 114/114] kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used
@ 2021-05-06  2:16 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-05-06  2:16 UTC (permalink / raw)
  To: kbuild-all

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev.2021.05.02a
head:   35d2c62851bc03a945ae81ab0726985f726107b1
commit: 35d2c62851bc03a945ae81ab0726985f726107b1 [114/114] refscale: Add measurement of clock readout
config: nios2-randconfig-r014-20210505 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0
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://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?id=35d2c62851bc03a945ae81ab0726985f726107b1
        git remote add rcu https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
        git fetch --no-tags rcu dev.2021.05.02a
        git checkout 35d2c62851bc03a945ae81ab0726985f726107b1
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=nios2 

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

All warnings (new ones prefixed by >>):

   kernel/rcu/refscale.c: In function 'ref_clock_section':
>> kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
     472 |  volatile u64 x;
         |               ^
   kernel/rcu/refscale.c: In function 'ref_clock_delay_section':
   kernel/rcu/refscale.c:484:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
     484 |  volatile u64 x;
         |               ^


vim +/x +472 kernel/rcu/refscale.c

   469	
   470	static void ref_clock_section(const int nloops)
   471	{
 > 472		volatile u64 x;
   473		int i;
   474	
   475		preempt_disable();
   476		for (i = nloops; i >= 0; i--) {
   477			x = ktime_get_real_fast_ns();
   478		}
   479		preempt_enable();
   480	}
   481	

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

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

* Re: [rcu:dev.2021.05.02a 114/114] kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used
  2021-05-06  2:16 ` kernel test robot
@ 2021-05-10 18:14   ` Paul E. McKenney
  -1 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2021-05-10 18:14 UTC (permalink / raw)
  To: kernel test robot; +Cc: kbuild-all, linux-kernel

On Thu, May 06, 2021 at 10:16:43AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev.2021.05.02a
> head:   35d2c62851bc03a945ae81ab0726985f726107b1
> commit: 35d2c62851bc03a945ae81ab0726985f726107b1 [114/114] refscale: Add measurement of clock readout
> config: nios2-randconfig-r014-20210505 (attached as .config)
> compiler: nios2-linux-gcc (GCC) 9.3.0
> 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://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?id=35d2c62851bc03a945ae81ab0726985f726107b1
>         git remote add rcu https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
>         git fetch --no-tags rcu dev.2021.05.02a
>         git checkout 35d2c62851bc03a945ae81ab0726985f726107b1
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=nios2 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>    kernel/rcu/refscale.c: In function 'ref_clock_section':
> >> kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
>      472 |  volatile u64 x;
>          |               ^
>    kernel/rcu/refscale.c: In function 'ref_clock_delay_section':
>    kernel/rcu/refscale.c:484:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
>      484 |  volatile u64 x;
>          |               ^
> 
> 
> vim +/x +472 kernel/rcu/refscale.c
> 
>    469	
>    470	static void ref_clock_section(const int nloops)
>    471	{
>  > 472		volatile u64 x;
>    473		int i;
>    474	
>    475		preempt_disable();
>    476		for (i = nloops; i >= 0; i--) {
>    477			x = ktime_get_real_fast_ns();
>    478		}
>    479		preempt_enable();
>    480	}
>    481	

OK, how about with the following fixup patch?

But please note that this compiler warning is incorrect.  The variable
is marked volatile, so the compiler cannot possibly know that it is in
fact unused.  Some debugger might be examining it, for but one example.

Thus, the fixup patch below is a workaround for the compiler bug.

							Thanx, Paul

------------------------------------------------------------------------

commit 1838223c42250bfc27a15b9712591e663babb1f0
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Mon May 10 11:12:01 2021 -0700

    squash! refscale: Add measurement of clock readout
    
    [ paulmck: Adjust volatility per kernel test robot feedback. ]
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index bef61a322104..20e892b2502c 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -467,29 +467,33 @@ static struct ref_scale_ops acqrel_ops = {
 	.name		= "acqrel"
 };
 
+static volatile u64 stopopts;
+
 static void ref_clock_section(const int nloops)
 {
-	volatile u64 x;
+	u64 x;
 	int i;
 
 	preempt_disable();
 	for (i = nloops; i >= 0; i--) {
-		x = ktime_get_real_fast_ns();
+		x += ktime_get_real_fast_ns();
 	}
 	preempt_enable();
+	stopopts = x;
 }
 
 static void ref_clock_delay_section(const int nloops, const int udl, const int ndl)
 {
-	volatile u64 x;
+	u64 x;
 	int i;
 
 	preempt_disable();
 	for (i = nloops; i >= 0; i--) {
-		x = ktime_get_real_fast_ns();
+		x += ktime_get_real_fast_ns();
 		un_delay(udl, ndl);
 	}
 	preempt_enable();
+	stopopts = x;
 }
 
 static struct ref_scale_ops clock_ops = {

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

* Re: [rcu:dev.2021.05.02a 114/114] kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used
@ 2021-05-10 18:14   ` Paul E. McKenney
  0 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2021-05-10 18:14 UTC (permalink / raw)
  To: kbuild-all

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

On Thu, May 06, 2021 at 10:16:43AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev.2021.05.02a
> head:   35d2c62851bc03a945ae81ab0726985f726107b1
> commit: 35d2c62851bc03a945ae81ab0726985f726107b1 [114/114] refscale: Add measurement of clock readout
> config: nios2-randconfig-r014-20210505 (attached as .config)
> compiler: nios2-linux-gcc (GCC) 9.3.0
> 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://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/commit/?id=35d2c62851bc03a945ae81ab0726985f726107b1
>         git remote add rcu https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
>         git fetch --no-tags rcu dev.2021.05.02a
>         git checkout 35d2c62851bc03a945ae81ab0726985f726107b1
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=nios2 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>    kernel/rcu/refscale.c: In function 'ref_clock_section':
> >> kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
>      472 |  volatile u64 x;
>          |               ^
>    kernel/rcu/refscale.c: In function 'ref_clock_delay_section':
>    kernel/rcu/refscale.c:484:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
>      484 |  volatile u64 x;
>          |               ^
> 
> 
> vim +/x +472 kernel/rcu/refscale.c
> 
>    469	
>    470	static void ref_clock_section(const int nloops)
>    471	{
>  > 472		volatile u64 x;
>    473		int i;
>    474	
>    475		preempt_disable();
>    476		for (i = nloops; i >= 0; i--) {
>    477			x = ktime_get_real_fast_ns();
>    478		}
>    479		preempt_enable();
>    480	}
>    481	

OK, how about with the following fixup patch?

But please note that this compiler warning is incorrect.  The variable
is marked volatile, so the compiler cannot possibly know that it is in
fact unused.  Some debugger might be examining it, for but one example.

Thus, the fixup patch below is a workaround for the compiler bug.

							Thanx, Paul

------------------------------------------------------------------------

commit 1838223c42250bfc27a15b9712591e663babb1f0
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Mon May 10 11:12:01 2021 -0700

    squash! refscale: Add measurement of clock readout
    
    [ paulmck: Adjust volatility per kernel test robot feedback. ]
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index bef61a322104..20e892b2502c 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -467,29 +467,33 @@ static struct ref_scale_ops acqrel_ops = {
 	.name		= "acqrel"
 };
 
+static volatile u64 stopopts;
+
 static void ref_clock_section(const int nloops)
 {
-	volatile u64 x;
+	u64 x;
 	int i;
 
 	preempt_disable();
 	for (i = nloops; i >= 0; i--) {
-		x = ktime_get_real_fast_ns();
+		x += ktime_get_real_fast_ns();
 	}
 	preempt_enable();
+	stopopts = x;
 }
 
 static void ref_clock_delay_section(const int nloops, const int udl, const int ndl)
 {
-	volatile u64 x;
+	u64 x;
 	int i;
 
 	preempt_disable();
 	for (i = nloops; i >= 0; i--) {
-		x = ktime_get_real_fast_ns();
+		x += ktime_get_real_fast_ns();
 		un_delay(udl, ndl);
 	}
 	preempt_enable();
+	stopopts = x;
 }
 
 static struct ref_scale_ops clock_ops = {

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

end of thread, other threads:[~2021-05-10 18:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  2:16 [rcu:dev.2021.05.02a 114/114] kernel/rcu/refscale.c:472:15: warning: variable 'x' set but not used kernel test robot
2021-05-06  2:16 ` kernel test robot
2021-05-10 18:14 ` Paul E. McKenney
2021-05-10 18:14   ` Paul E. McKenney

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.