mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
@ 2023-10-31 22:05 Tony Luck
  2023-11-01  9:43 ` Bagas Sanjaya
  2023-11-01 20:26 ` Moger, Babu
  0 siblings, 2 replies; 13+ messages in thread
From: Tony Luck @ 2023-10-31 22:05 UTC (permalink / raw)
  To: Fenghua Yu, Reinette Chatre, Peter Newman, x86
  Cc: Shaopeng Tan, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
	linux-kernel, patches, Tony Luck

In a "W=1" build gcc throws a warning:

arch/x86/kernel/cpu/resctrl/core.c: In function ‘cache_alloc_hsw_probe’:
arch/x86/kernel/cpu/resctrl/core.c:139:16: warning: variable ‘h’ set but not used

Fix by switching from rdmsr() to rdmsrl() using a single u64 argument
for the MSR value instead of the pair of u32 for the high and low
halves.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
This has been annoying me for a while as the only warning from the
resctrl code when building with W=1.

N.B. compile tested only. I don't have a Haswell system to check this works.

 arch/x86/kernel/cpu/resctrl/core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 19e0681f0435..4084131d391d 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -136,15 +136,16 @@ static inline void cache_alloc_hsw_probe(void)
 {
 	struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_L3];
 	struct rdt_resource *r  = &hw_res->r_resctrl;
-	u32 l, h, max_cbm = BIT_MASK(20) - 1;
+	u32 max_cbm = BIT_MASK(20) - 1;
+	u64 l3_cbm_0;
 
 	if (wrmsr_safe(MSR_IA32_L3_CBM_BASE, max_cbm, 0))
 		return;
 
-	rdmsr(MSR_IA32_L3_CBM_BASE, l, h);
+	rdmsrl(MSR_IA32_L3_CBM_BASE, l3_cbm_0);
 
 	/* If all the bits were set in MSR, return success */
-	if (l != max_cbm)
+	if (l3_cbm_0 != max_cbm)
 		return;
 
 	hw_res->num_closid = 4;
-- 
2.41.0


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

* Re: [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-10-31 22:05 [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe() Tony Luck
@ 2023-11-01  9:43 ` Bagas Sanjaya
  2023-11-01 14:33   ` Luck, Tony
  2023-11-01 20:26 ` Moger, Babu
  1 sibling, 1 reply; 13+ messages in thread
From: Bagas Sanjaya @ 2023-11-01  9:43 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu, Reinette Chatre, Peter Newman, x86
  Cc: Shaopeng Tan, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
	linux-kernel, patches

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

On Tue, Oct 31, 2023 at 03:05:34PM -0700, Tony Luck wrote:
> In a "W=1" build gcc throws a warning:
> 
> arch/x86/kernel/cpu/resctrl/core.c: In function ‘cache_alloc_hsw_probe’:
> arch/x86/kernel/cpu/resctrl/core.c:139:16: warning: variable ‘h’ set but not used
> 
> Fix by switching from rdmsr() to rdmsrl() using a single u64 argument
> for the MSR value instead of the pair of u32 for the high and low
> halves.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---
> This has been annoying me for a while as the only warning from the
> resctrl code when building with W=1.
> 
> N.B. compile tested only. I don't have a Haswell system to check this works.
> 
>  arch/x86/kernel/cpu/resctrl/core.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> index 19e0681f0435..4084131d391d 100644
> --- a/arch/x86/kernel/cpu/resctrl/core.c
> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> @@ -136,15 +136,16 @@ static inline void cache_alloc_hsw_probe(void)
>  {
>  	struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_L3];
>  	struct rdt_resource *r  = &hw_res->r_resctrl;
> -	u32 l, h, max_cbm = BIT_MASK(20) - 1;
> +	u32 max_cbm = BIT_MASK(20) - 1;
> +	u64 l3_cbm_0;
>  
>  	if (wrmsr_safe(MSR_IA32_L3_CBM_BASE, max_cbm, 0))
>  		return;
>  
> -	rdmsr(MSR_IA32_L3_CBM_BASE, l, h);
> +	rdmsrl(MSR_IA32_L3_CBM_BASE, l3_cbm_0);
>  
>  	/* If all the bits were set in MSR, return success */
> -	if (l != max_cbm)
> +	if (l3_cbm_0 != max_cbm)
>  		return;
>  
>  	hw_res->num_closid = 4;

No noticeable regressions on my Acer Aspire E15 (the laptop uses Intel Core
i3 Haswell), thanks!

Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* RE: [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-01  9:43 ` Bagas Sanjaya
@ 2023-11-01 14:33   ` Luck, Tony
  0 siblings, 0 replies; 13+ messages in thread
From: Luck, Tony @ 2023-11-01 14:33 UTC (permalink / raw)
  To: Bagas Sanjaya, Yu, Fenghua, Chatre, Reinette, Peter Newman, x86
  Cc: Shaopeng Tan, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
	linux-kernel, patches

> No noticeable regressions on my Acer Aspire E15 (the laptop uses Intel Core
> i3 Haswell), thanks!
>
> Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>

Thanks for reporting that you tested. I don't think a Haswell i3 gets as far as
the piece of code that I changed. the wrmsr_safe() will return non-zero and
the function returns before getting to the piece that I changed.

-Tony

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

* Re: [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-10-31 22:05 [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe() Tony Luck
  2023-11-01  9:43 ` Bagas Sanjaya
@ 2023-11-01 20:26 ` Moger, Babu
  2023-11-01 20:33   ` Luck, Tony
  1 sibling, 1 reply; 13+ messages in thread
From: Moger, Babu @ 2023-11-01 20:26 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu, Reinette Chatre, Peter Newman, x86
  Cc: Shaopeng Tan, James Morse, Jamie Iles, Randy Dunlap,
	linux-kernel, patches

Hi Tony,

On 10/31/23 17:05, Tony Luck wrote:
> In a "W=1" build gcc throws a warning:
> 
> arch/x86/kernel/cpu/resctrl/core.c: In function ‘cache_alloc_hsw_probe’:
> arch/x86/kernel/cpu/resctrl/core.c:139:16: warning: variable ‘h’ set but not used
> 
> Fix by switching from rdmsr() to rdmsrl() using a single u64 argument
> for the MSR value instead of the pair of u32 for the high and low
> halves.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---
> This has been annoying me for a while as the only warning from the
> resctrl code when building with W=1.
> 
> N.B. compile tested only. I don't have a Haswell system to check this works.
> 
>  arch/x86/kernel/cpu/resctrl/core.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> index 19e0681f0435..4084131d391d 100644
> --- a/arch/x86/kernel/cpu/resctrl/core.c
> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> @@ -136,15 +136,16 @@ static inline void cache_alloc_hsw_probe(void)
>  {
>  	struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_L3];
>  	struct rdt_resource *r  = &hw_res->r_resctrl;
> -	u32 l, h, max_cbm = BIT_MASK(20) - 1;
> +	u32 max_cbm = BIT_MASK(20) - 1;
> +	u64 l3_cbm_0;
>  
>  	if (wrmsr_safe(MSR_IA32_L3_CBM_BASE, max_cbm, 0))
>  		return;
>  
> -	rdmsr(MSR_IA32_L3_CBM_BASE, l, h);
> +	rdmsrl(MSR_IA32_L3_CBM_BASE, l3_cbm_0);

You are writing 32 bit and reading 64 bit. Why don't you change both to 64
bit?

>  
>  	/* If all the bits were set in MSR, return success */
> -	if (l != max_cbm)
> +	if (l3_cbm_0 != max_cbm)
>  		return;
>  
>  	hw_res->num_closid = 4;

-- 
Thanks
Babu Moger

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

* RE: [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-01 20:26 ` Moger, Babu
@ 2023-11-01 20:33   ` Luck, Tony
  2023-11-01 20:42     ` Moger, Babu
  0 siblings, 1 reply; 13+ messages in thread
From: Luck, Tony @ 2023-11-01 20:33 UTC (permalink / raw)
  To: babu.moger, Yu, Fenghua, Chatre, Reinette, Peter Newman, x86
  Cc: Shaopeng Tan, James Morse, Jamie Iles, Randy Dunlap,
	linux-kernel, patches

> >     if (wrmsr_safe(MSR_IA32_L3_CBM_BASE, max_cbm, 0))
> >             return;
> >
> > -   rdmsr(MSR_IA32_L3_CBM_BASE, l, h);
> > +   rdmsrl(MSR_IA32_L3_CBM_BASE, l3_cbm_0);
>
> You are writing 32 bit and reading 64 bit. Why don't you change both to 64
> bit?

wrmsr_safe() writes all 64-bits ... just gets those bits as a pair
of 32-bit arguments for the low and high halves.

I could switch that to wrmsrl_safe() and change max_cbm to be "u64"
to make write & read match. Would that be better?

-Tony

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

* Re: [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-01 20:33   ` Luck, Tony
@ 2023-11-01 20:42     ` Moger, Babu
  2023-11-01 21:26       ` [PATCH v2] " Tony Luck
  0 siblings, 1 reply; 13+ messages in thread
From: Moger, Babu @ 2023-11-01 20:42 UTC (permalink / raw)
  To: Luck, Tony, Yu, Fenghua, Chatre, Reinette, Peter Newman, x86
  Cc: Shaopeng Tan, James Morse, Jamie Iles, Randy Dunlap,
	linux-kernel, patches


On 11/1/23 15:33, Luck, Tony wrote:
>>>     if (wrmsr_safe(MSR_IA32_L3_CBM_BASE, max_cbm, 0))
>>>             return;
>>>
>>> -   rdmsr(MSR_IA32_L3_CBM_BASE, l, h);
>>> +   rdmsrl(MSR_IA32_L3_CBM_BASE, l3_cbm_0);
>>
>> You are writing 32 bit and reading 64 bit. Why don't you change both to 64
>> bit?
> 
> wrmsr_safe() writes all 64-bits ... just gets those bits as a pair
> of 32-bit arguments for the low and high halves.
> 
> I could switch that to wrmsrl_safe() and change max_cbm to be "u64"
> to make write & read match. Would that be better?

Yes. That is better.
-- 
Thanks
Babu Moger

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

* [PATCH v2] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-01 20:42     ` Moger, Babu
@ 2023-11-01 21:26       ` Tony Luck
  2023-11-02 13:02         ` Moger, Babu
  2023-11-02 21:34         ` Reinette Chatre
  0 siblings, 2 replies; 13+ messages in thread
From: Tony Luck @ 2023-11-01 21:26 UTC (permalink / raw)
  To: Moger, Babu
  Cc: Yu, Fenghua, Chatre, Reinette, Peter Newman, x86, Shaopeng Tan,
	James Morse, Jamie Iles, Randy Dunlap, linux-kernel, patches

In a "W=1" build gcc throws a warning:

arch/x86/kernel/cpu/resctrl/core.c: In function ‘cache_alloc_hsw_probe’:
arch/x86/kernel/cpu/resctrl/core.c:139:16: warning: variable ‘h’ set but not used

Fix by switching from wrmsr_safe() to wrmsrl_safe(), and from rdmsr()
to rdmsrl() using a single u64 argument for the MSR value instead of
the pair of u32 for the high and low halves.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
Changes since v1 (suggested by Babu)

Switch both the wrmsr() and rdmsr() to the 64-bit versions.

 arch/x86/kernel/cpu/resctrl/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 19e0681f0435..d29ebe345de6 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -136,15 +136,15 @@ static inline void cache_alloc_hsw_probe(void)
 {
 	struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_L3];
 	struct rdt_resource *r  = &hw_res->r_resctrl;
-	u32 l, h, max_cbm = BIT_MASK(20) - 1;
+	u64 max_cbm = BIT_ULL_MASK(20) - 1, l3_cbm_0;
 
-	if (wrmsr_safe(MSR_IA32_L3_CBM_BASE, max_cbm, 0))
+	if (wrmsrl_safe(MSR_IA32_L3_CBM_BASE, max_cbm))
 		return;
 
-	rdmsr(MSR_IA32_L3_CBM_BASE, l, h);
+	rdmsrl(MSR_IA32_L3_CBM_BASE, l3_cbm_0);
 
 	/* If all the bits were set in MSR, return success */
-	if (l != max_cbm)
+	if (l3_cbm_0 != max_cbm)
 		return;
 
 	hw_res->num_closid = 4;
-- 
2.41.0


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

* Re: [PATCH v2] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-01 21:26       ` [PATCH v2] " Tony Luck
@ 2023-11-02 13:02         ` Moger, Babu
  2023-11-02 21:34         ` Reinette Chatre
  1 sibling, 0 replies; 13+ messages in thread
From: Moger, Babu @ 2023-11-02 13:02 UTC (permalink / raw)
  To: Tony Luck
  Cc: Yu, Fenghua, Chatre, Reinette, Peter Newman, x86, Shaopeng Tan,
	James Morse, Jamie Iles, Randy Dunlap, linux-kernel, patches

Looks good.

On 11/1/23 16:26, Tony Luck wrote:
> In a "W=1" build gcc throws a warning:
> 
> arch/x86/kernel/cpu/resctrl/core.c: In function ‘cache_alloc_hsw_probe’:
> arch/x86/kernel/cpu/resctrl/core.c:139:16: warning: variable ‘h’ set but not used
> 
> Fix by switching from wrmsr_safe() to wrmsrl_safe(), and from rdmsr()
> to rdmsrl() using a single u64 argument for the MSR value instead of
> the pair of u32 for the high and low halves.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>

Reviewed-by: Babu Moger <babu.moger@amd.com>

> ---
> Changes since v1 (suggested by Babu)
> 
> Switch both the wrmsr() and rdmsr() to the 64-bit versions.
> 
>  arch/x86/kernel/cpu/resctrl/core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> index 19e0681f0435..d29ebe345de6 100644
> --- a/arch/x86/kernel/cpu/resctrl/core.c
> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> @@ -136,15 +136,15 @@ static inline void cache_alloc_hsw_probe(void)
>  {
>  	struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_L3];
>  	struct rdt_resource *r  = &hw_res->r_resctrl;
> -	u32 l, h, max_cbm = BIT_MASK(20) - 1;
> +	u64 max_cbm = BIT_ULL_MASK(20) - 1, l3_cbm_0;
>  
> -	if (wrmsr_safe(MSR_IA32_L3_CBM_BASE, max_cbm, 0))
> +	if (wrmsrl_safe(MSR_IA32_L3_CBM_BASE, max_cbm))
>  		return;
>  
> -	rdmsr(MSR_IA32_L3_CBM_BASE, l, h);
> +	rdmsrl(MSR_IA32_L3_CBM_BASE, l3_cbm_0);
>  
>  	/* If all the bits were set in MSR, return success */
> -	if (l != max_cbm)
> +	if (l3_cbm_0 != max_cbm)
>  		return;
>  
>  	hw_res->num_closid = 4;

-- 
Thanks
Babu Moger

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

* Re: [PATCH v2] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-01 21:26       ` [PATCH v2] " Tony Luck
  2023-11-02 13:02         ` Moger, Babu
@ 2023-11-02 21:34         ` Reinette Chatre
  2023-11-02 22:02           ` Luck, Tony
  1 sibling, 1 reply; 13+ messages in thread
From: Reinette Chatre @ 2023-11-02 21:34 UTC (permalink / raw)
  To: Tony Luck, Moger, Babu
  Cc: Yu, Fenghua, Peter Newman, x86, Shaopeng Tan, James Morse,
	Jamie Iles, Randy Dunlap, linux-kernel, patches

Hi Tony,

On 11/1/2023 2:26 PM, Tony Luck wrote:
> In a "W=1" build gcc throws a warning:

This is strange, I am not able to encounter this warning. Is my gcc perhaps
too old? I know there were some specific versions needed to reproduce similar
warnings with clang (see reference commit 793207bad71c ("x86/resctrl: Fix a silly
-Wunused-but-set-variable warning")).

> 
> arch/x86/kernel/cpu/resctrl/core.c: In function ‘cache_alloc_hsw_probe’:
> arch/x86/kernel/cpu/resctrl/core.c:139:16: warning: variable ‘h’ set but not used
> 
> Fix by switching from wrmsr_safe() to wrmsrl_safe(), and from rdmsr()
> to rdmsrl() using a single u64 argument for the MSR value instead of
> the pair of u32 for the high and low halves.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>

I do not know if all the text from that reference commit applies here, but
for what it is worth:

Acked-by: Reinette Chatre <reinette.chatre@intel.com>

Reinette

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

* RE: [PATCH v2] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-02 21:34         ` Reinette Chatre
@ 2023-11-02 22:02           ` Luck, Tony
  2023-11-02 22:23             ` Reinette Chatre
  0 siblings, 1 reply; 13+ messages in thread
From: Luck, Tony @ 2023-11-02 22:02 UTC (permalink / raw)
  To: Chatre, Reinette, Moger, Babu
  Cc: Yu, Fenghua, Peter Newman, x86, Shaopeng Tan, James Morse,
	Jamie Iles, Randy Dunlap, linux-kernel, patches

> This is strange, I am not able to encounter this warning. Is my gcc perhaps
> too old? I know there were some specific versions needed to reproduce similar
> warnings with clang (see reference commit 793207bad71c ("x86/resctrl: Fix a silly
> -Wunused-but-set-variable warning")).

I'm using the default install from Fedora 38:

$ gcc --version
gcc (GCC) 13.2.1 20230728 (Red Hat 13.2.1-1)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-Tony

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

* Re: [PATCH v2] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-02 22:02           ` Luck, Tony
@ 2023-11-02 22:23             ` Reinette Chatre
  2023-11-02 22:50               ` Luck, Tony
  0 siblings, 1 reply; 13+ messages in thread
From: Reinette Chatre @ 2023-11-02 22:23 UTC (permalink / raw)
  To: Luck, Tony, Moger, Babu
  Cc: Yu, Fenghua, Peter Newman, x86, Shaopeng Tan, James Morse,
	Jamie Iles, Randy Dunlap, linux-kernel, patches

Hi Tony,

On 11/2/2023 3:02 PM, Luck, Tony wrote:
>> This is strange, I am not able to encounter this warning. Is my gcc perhaps
>> too old? I know there were some specific versions needed to reproduce similar
>> warnings with clang (see reference commit 793207bad71c ("x86/resctrl: Fix a silly
>> -Wunused-but-set-variable warning")).
> 
> I'm using the default install from Fedora 38:
> 
> $ gcc --version
> gcc (GCC) 13.2.1 20230728 (Red Hat 13.2.1-1)
> Copyright (C) 2023 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Thank you for confirming. I tested with the same version. Strange, I see other
instances of this warning but not the resctrl one:

$ grep "set but not used" ~/t/log | wc -l
20
$ grep resctrl ~/t/log
  CC      arch/x86/kernel/cpu/resctrl/core.o
  CC      arch/x86/kernel/cpu/resctrl/rdtgroup.o
  CC      arch/x86/kernel/cpu/resctrl/monitor.o
  CC      arch/x86/kernel/cpu/resctrl/ctrlmondata.o
  CC      arch/x86/kernel/cpu/resctrl/pseudo_lock.o
  AR      arch/x86/kernel/cpu/resctrl/built-in.a

This does seem a valid issue and my Ack remains. I'm just puzzled why I do not
encounter the same warning.

Reinette

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

* RE: [PATCH v2] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-02 22:23             ` Reinette Chatre
@ 2023-11-02 22:50               ` Luck, Tony
  2023-11-03 20:23                 ` Reinette Chatre
  0 siblings, 1 reply; 13+ messages in thread
From: Luck, Tony @ 2023-11-02 22:50 UTC (permalink / raw)
  To: Chatre, Reinette, Moger, Babu
  Cc: Yu, Fenghua, Peter Newman, x86, Shaopeng Tan, James Morse,
	Jamie Iles, Randy Dunlap, linux-kernel, patches

> This does seem a valid issue and my Ack remains. I'm just puzzled why I do not
> encounter the same warning.

Reinette,

Some other CONFIG option changing CFLAGS?

Here's what I have for a "make V=1 W=1" for core.o

# CC      arch/x86/kernel/cpu/resctrl/core.o
  gcc -Wp,-MMD,arch/x86/kernel/cpu/resctrl/.core.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Wundef -DKBUILD_EXTRA_WARN1 -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -mharden-sls=all -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -falign-functions=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-dangling-pointer -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wextra -Wunused -Wno-unused-parameter -Wmissing-declarations -Wrestrict -Wmissing-format-attribute -Wmissing-prototypes -Wold-style-definition -Wmissing-include-dirs -Wunused-but-set-variable -Wunused-const-variable -Wpacked-not-aligned -Wformat-overflow -Wformat-truncation -Wstringop-overflow -Wstringop-truncation -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -g    -DKBUILD_MODFILE='"arch/x86/kernel/cpu/resctrl/core"' -DKBUILD_BASENAME='"core"' -DKBUILD_MODNAME='"core"' -D__KBUILD_MODNAME=kmod_core -c -o arch/x86/kernel/cpu/resctrl/core.o arch/x86/kernel/cpu/resctrl/core.c   ; ./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --hacks=skylake --orc --retpoline --rethunk --sls --static-call --uaccess --prefix=16   arch/x86/kernel/cpu/resctrl/core.o
arch/x86/kernel/cpu/resctrl/core.c: In function ‘cache_alloc_hsw_probe’:
arch/x86/kernel/cpu/resctrl/core.c:139:16: warning: variable ‘h’ set but not used [-Wunused-but-set-variable]
  139 |         u32 l, h, max_cbm = BIT_MASK(20) - 1;
      |                ^

Dropping just the "-Wunused-but-set-variable" from that big mess does make the warning disappear for me.

But maybe some option can result in the argument list being built in a different order? I see there is an earlier " -Wno-unused-but-set-variable"

-Tony

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

* Re: [PATCH v2] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe()
  2023-11-02 22:50               ` Luck, Tony
@ 2023-11-03 20:23                 ` Reinette Chatre
  0 siblings, 0 replies; 13+ messages in thread
From: Reinette Chatre @ 2023-11-03 20:23 UTC (permalink / raw)
  To: Luck, Tony, Moger, Babu
  Cc: Yu, Fenghua, Peter Newman, x86, Shaopeng Tan, James Morse,
	Jamie Iles, Randy Dunlap, linux-kernel, patches



On 11/2/2023 3:50 PM, Luck, Tony wrote:
>> This does seem a valid issue and my Ack remains. I'm just puzzled why I do not
>> encounter the same warning.
> 
> Reinette,
> 
> Some other CONFIG option changing CFLAGS?
> 
> Here's what I have for a "make V=1 W=1" for core.o
> 

Tony and I went a bit more back-and-forth on this one and it appears that the
relevant code is optimized out in my build while the same did not happen
for him. 

I can now trigger the warning by enabling Xen support, with CONFIG_PARAVIRT_XXL
causing rdmsr() to be replaced by paravirt_read_msr(). With the relevant code
no longer optimized out, the warning is triggered.

Thanks Tony!

Reinette



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

end of thread, other threads:[~2023-11-03 20:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-31 22:05 [PATCH] x86/resctrl: Fix unused variable warning in cache_alloc_hsw_probe() Tony Luck
2023-11-01  9:43 ` Bagas Sanjaya
2023-11-01 14:33   ` Luck, Tony
2023-11-01 20:26 ` Moger, Babu
2023-11-01 20:33   ` Luck, Tony
2023-11-01 20:42     ` Moger, Babu
2023-11-01 21:26       ` [PATCH v2] " Tony Luck
2023-11-02 13:02         ` Moger, Babu
2023-11-02 21:34         ` Reinette Chatre
2023-11-02 22:02           ` Luck, Tony
2023-11-02 22:23             ` Reinette Chatre
2023-11-02 22:50               ` Luck, Tony
2023-11-03 20:23                 ` Reinette Chatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®