2021-07-23 02:35:58

by Hui Su

[permalink] [raw]
Subject: [PATCH] x86/intel_rdt: use __this_cpu_read in pseudo_lock_fn()

The code is executed with interrupts disabled,
so it's safe to use __this_cpu_read().

Signed-off-by: Hui Su <[email protected]>
---
arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
index 2207916cae65..f0cc0a89333b 100644
--- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
+++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
@@ -464,8 +464,8 @@ static int pseudo_lock_fn(void *_rdtgrp)
* cache.
*/
__wrmsr(MSR_MISC_FEATURE_CONTROL, prefetch_disable_bits, 0x0);
- closid_p = this_cpu_read(pqr_state.cur_closid);
- rmid_p = this_cpu_read(pqr_state.cur_rmid);
+ closid_p = __this_cpu_read(pqr_state.cur_closid);
+ rmid_p = __this_cpu_read(pqr_state.cur_rmid);
mem_r = plr->kmem;
size = plr->size;
line_size = plr->line_size;
--
2.30.2


2021-07-27 18:57:21

by Reinette Chatre

[permalink] [raw]
Subject: Re: [PATCH] x86/intel_rdt: use __this_cpu_read in pseudo_lock_fn()

Hi,

On 7/22/2021 7:33 PM, Hui Su wrote:
> The code is executed with interrupts disabled,
> so it's safe to use __this_cpu_read().

True ... but could you please elaborate what the issue is with using
this_cpu_read()? It too is safe to use when interrupts are disabled.

>
> Signed-off-by: Hui Su <[email protected]>
> ---
> arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> index 2207916cae65..f0cc0a89333b 100644
> --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> @@ -464,8 +464,8 @@ static int pseudo_lock_fn(void *_rdtgrp)
> * cache.
> */
> __wrmsr(MSR_MISC_FEATURE_CONTROL, prefetch_disable_bits, 0x0);
> - closid_p = this_cpu_read(pqr_state.cur_closid);
> - rmid_p = this_cpu_read(pqr_state.cur_rmid);
> + closid_p = __this_cpu_read(pqr_state.cur_closid);
> + rmid_p = __this_cpu_read(pqr_state.cur_rmid);
> mem_r = plr->kmem;
> size = plr->size;
> line_size = plr->line_size;
>

Reinette

2021-07-30 08:23:29

by Hui Su

[permalink] [raw]
Subject: 回复: [PATCH] x86/intel_rdt: use __this_cpu_r ead in pseudo_lock_fn()

Hi, Reinette:

There is no issue here, i just think it's better to use __this_cpu_read when
interrupt disabled.

________________________________________
??????: Reinette Chatre <[email protected]>
????ʱ??: 2021??7??28?? 2:56
?ռ???: ?ջ?(Robert Su); [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
????: Re: [PATCH] x86/intel_rdt: use __this_cpu_read in pseudo_lock_fn()

Hi,

On 7/22/2021 7:33 PM, Hui Su wrote:
> The code is executed with interrupts disabled,
> so it's safe to use __this_cpu_read().

True ... but could you please elaborate what the issue is with using
this_cpu_read()? It too is safe to use when interrupts are disabled.

>
> Signed-off-by: Hui Su <[email protected]>
> ---
> arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> index 2207916cae65..f0cc0a89333b 100644
> --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> @@ -464,8 +464,8 @@ static int pseudo_lock_fn(void *_rdtgrp)
> * cache.
> */
> __wrmsr(MSR_MISC_FEATURE_CONTROL, prefetch_disable_bits, 0x0);
> - closid_p = this_cpu_read(pqr_state.cur_closid);
> - rmid_p = this_cpu_read(pqr_state.cur_rmid);
> + closid_p = __this_cpu_read(pqr_state.cur_closid);
> + rmid_p = __this_cpu_read(pqr_state.cur_rmid);
> mem_r = plr->kmem;
> size = plr->size;
> line_size = plr->line_size;
>

Reinette

2021-07-30 14:49:17

by Reinette Chatre

[permalink] [raw]
Subject: Re: 回复: [PATCH] x86/intel_rdt: use __t his_cpu_read in pseudo_lock_fn()

Hi,

On 7/30/2021 1:22 AM, ?ջ?(Robert Su) wrote:
> Hi, Reinette:
>
> There is no issue here, i just think it's better to use __this_cpu_read when
> interrupt disabled.

ok, could you please elaborate why it is better? I do not see a problem
with the change - I would just like to understand the motivation for it.

Thank you

Reinette