lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b9131e12-e8dc-45ea-80e3-30281fd7222a@amd.com>
Date:   Thu, 9 Nov 2023 14:48:17 -0600
From:   "Moger, Babu" <babu.moger@....com>
To:     James Morse <james.morse@....com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Cc:     Fenghua Yu <fenghua.yu@...el.com>,
        Reinette Chatre <reinette.chatre@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        H Peter Anvin <hpa@...or.com>,
        shameerali.kolothum.thodi@...wei.com,
        D Scott Phillips OS <scott@...amperecomputing.com>,
        carl@...amperecomputing.com, lcherian@...vell.com,
        bobo.shaobowang@...wei.com, tan.shaopeng@...itsu.com,
        baolin.wang@...ux.alibaba.com, Jamie Iles <quic_jiles@...cinc.com>,
        Xin Hao <xhao@...ux.alibaba.com>, peternewman@...gle.com,
        dfustini@...libre.com, amitsinght@...vell.com
Subject: Re: [PATCH v7 18/24] x86/resctrl: Make rdt_enable_key the arch's
 decision to switch



On 10/25/23 13:03, James Morse wrote:
> rdt_enable_key is switched when resctrl is mounted. It was also previously
> used to prevent a second mount of the filesystem.
> 
> Any other architecture that wants to support resctrl has to provide
> identical static keys.
> 
> Now that there are helpers for enabling and disabling the alloc/mon keys,
> resctrl doesn't need to switch this extra key, it can be done by the arch
> code. Use the static-key increment and decrement helpers, and change
> resctrl to ensure the calls are balanced.
> 
> Tested-by: Shaopeng Tan <tan.shaopeng@...itsu.com>
> Tested-by: Peter Newman <peternewman@...gle.com>
> Reviewed-by: Shaopeng Tan <tan.shaopeng@...itsu.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@...el.com>
> Signed-off-by: James Morse <james.morse@....com>

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

> ---
> No changes since v6
> 
>  arch/x86/include/asm/resctrl.h         |  4 ++++
>  arch/x86/kernel/cpu/resctrl/rdtgroup.c | 11 +++++------
>  2 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h
> index 3c9137b6ad4f..b74aa34dc9e8 100644
> --- a/arch/x86/include/asm/resctrl.h
> +++ b/arch/x86/include/asm/resctrl.h
> @@ -45,21 +45,25 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
>  static inline void resctrl_arch_enable_alloc(void)
>  {
>  	static_branch_enable_cpuslocked(&rdt_alloc_enable_key);
> +	static_branch_inc_cpuslocked(&rdt_enable_key);
>  }
>  
>  static inline void resctrl_arch_disable_alloc(void)
>  {
>  	static_branch_disable_cpuslocked(&rdt_alloc_enable_key);
> +	static_branch_dec_cpuslocked(&rdt_enable_key);
>  }
>  
>  static inline void resctrl_arch_enable_mon(void)
>  {
>  	static_branch_enable_cpuslocked(&rdt_mon_enable_key);
> +	static_branch_inc_cpuslocked(&rdt_enable_key);
>  }
>  
>  static inline void resctrl_arch_disable_mon(void)
>  {
>  	static_branch_disable_cpuslocked(&rdt_mon_enable_key);
> +	static_branch_dec_cpuslocked(&rdt_enable_key);
>  }
>  
>  /*
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 48418857b685..edfb37680046 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -2677,10 +2677,8 @@ static int rdt_get_tree(struct fs_context *fc)
>  	if (rdt_mon_capable)
>  		resctrl_arch_enable_mon();
>  
> -	if (rdt_alloc_capable || rdt_mon_capable) {
> -		static_branch_enable_cpuslocked(&rdt_enable_key);
> +	if (rdt_alloc_capable || rdt_mon_capable)
>  		resctrl_mounted = true;
> -	}
>  
>  	if (is_mbm_enabled()) {
>  		r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
> @@ -2951,9 +2949,10 @@ static void rdt_kill_sb(struct super_block *sb)
>  	rdtgroup_default.mode = RDT_MODE_SHAREABLE;
>  	schemata_list_destroy();
>  	rdtgroup_destroy_root();
> -	resctrl_arch_disable_alloc();
> -	resctrl_arch_disable_mon();
> -	static_branch_disable_cpuslocked(&rdt_enable_key);
> +	if (rdt_alloc_capable)
> +		resctrl_arch_disable_alloc();
> +	if (rdt_mon_capable)
> +		resctrl_arch_disable_mon();
>  	resctrl_mounted = false;
>  	kernfs_kill_sb(sb);
>  	mutex_unlock(&rdtgroup_mutex);

-- 
Thanks
Babu Moger

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ