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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <deed72cb-53a5-f80a-03e9-623288c5d6e5@intel.com>
Date:   Mon, 16 Mar 2020 11:42:40 -0700
From:   Reinette Chatre <reinette.chatre@...el.com>
To:     James Morse <james.morse@....com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Cc:     Fenghua Yu <fenghua.yu@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H . Peter Anvin" <hpa@...or.com>, Babu Moger <Babu.Moger@....com>
Subject: Re: [PATCH 08/10] x86/resctrl: Merge AMD/Intel parse_bw() calls

Hi James,

On 2/14/2020 10:23 AM, James Morse wrote:
> Now that we've explained arch_needs_linear to resctrl, the parse_bw()
> calls are almost the same between AMD and Intel.
> 
> The difference is '!is_mba_sc()', which is not checked on AMD. This
> will always be true on AMD CPUs as mba_sc cannot be enabled as
> is_mba_linear() is false.
> 
> Removing this duplication means user-space visible behaviour and
> error messages are not validated or generated in different places.
> 
> Signed-off-by: James Morse <james.morse@....com>
> ---
>  arch/x86/kernel/cpu/resctrl/core.c        |  4 +-
>  arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 55 +----------------------
>  arch/x86/kernel/cpu/resctrl/internal.h    |  6 +--
>  3 files changed, 5 insertions(+), 60 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> index f022dc823c53..e90c10ca85f4 100644
> --- a/arch/x86/kernel/cpu/resctrl/core.c
> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> @@ -924,7 +924,7 @@ static __init void rdt_init_res_defs_intel(void)
>  		else if (r->rid == RDT_RESOURCE_MBA) {
>  			r->msr_base = MSR_IA32_MBA_THRTL_BASE;
>  			r->msr_update = mba_wrmsr_intel;
> -			r->parse_ctrlval = parse_bw_intel;
> +			r->parse_ctrlval = parse_bw;
>  		}
>  	}
>  }
> @@ -944,7 +944,7 @@ static __init void rdt_init_res_defs_amd(void)
>  		else if (r->rid == RDT_RESOURCE_MBA) {
>  			r->msr_base = MSR_IA32_MBA_BW_BASE;
>  			r->msr_update = mba_wrmsr_amd;
> -			r->parse_ctrlval = parse_bw_amd;
> +			r->parse_ctrlval = parse_bw;
>  		}
>  	}
>  }

Now that these values are identical more duplication can be avoided by
moving the initialization to earlier where rdt_resources_all[] is
initialized. Could you please modify this patch to do so?

> diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
> index db8e6c0cadb1..416becb591d1 100644
> --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
> +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
> @@ -21,59 +21,6 @@
>  #include <linux/slab.h>
>  #include "internal.h"
>  
> -/*
> - * Check whether MBA bandwidth percentage value is correct. The value is
> - * checked against the minimum and maximum bandwidth values specified by
> - * the hardware. The allocated bandwidth percentage is rounded to the next
> - * control step available on the hardware.
> - */
> -static bool bw_validate_amd(char *buf, unsigned long *data,
> -			    struct rdt_resource *r)
> -{
> -	unsigned long bw;
> -	int ret;
> -
> -	/* temporary: always false on AMD */
> -	if (!r->membw.delay_linear && r->membw.arch_needs_linear) {
> -		rdt_last_cmd_puts("No support for non-linear MB domains\n");
> -		return false;
> -	}
> -
> -	ret = kstrtoul(buf, 10, &bw);
> -	if (ret) {
> -		rdt_last_cmd_printf("Non-decimal digit in MB value %s\n", buf);
> -		return false;
> -	}
> -
> -	if (bw < r->membw.min_bw || bw > r->default_ctrl) {
> -		rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", bw,
> -				    r->membw.min_bw, r->default_ctrl);
> -		return false;
> -	}
> -
> -	*data = roundup(bw, (unsigned long)r->membw.bw_gran);
> -	return true;
> -}
> -
> -int parse_bw_amd(struct rdt_parse_data *data, struct rdt_resource *r,
> -		 struct rdt_domain *d)
> -{
> -	unsigned long bw_val;
> -
> -	if (d->have_new_ctrl) {
> -		rdt_last_cmd_printf("Duplicate domain %d\n", d->id);
> -		return -EINVAL;
> -	}
> -
> -	if (!bw_validate_amd(data->buf, &bw_val, r))
> -		return -EINVAL;
> -
> -	d->new_ctrl = bw_val;
> -	d->have_new_ctrl = true;
> -
> -	return 0;
> -}
> -
>  /*
>   * Check whether MBA bandwidth percentage value is correct. The value is
>   * checked against the minimum and max bandwidth values specified by the
> @@ -110,7 +57,7 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
>  	return true;
>  }
>  
> -int parse_bw_intel(struct rdt_parse_data *data, struct rdt_resource *r,
> +int parse_bw(struct rdt_parse_data *data, struct rdt_resource *r,
>  		   struct rdt_domain *d)

This change affects the alignment here ... could you please fix the
alignment to match open parenthesis?

>  {
>  	unsigned long bw_val;
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index 1fa692c54e15..45fc695081d1 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -462,10 +462,8 @@ struct rdt_resource {
>  
>  int parse_cbm(struct rdt_parse_data *data, struct rdt_resource *r,
>  	      struct rdt_domain *d);
> -int parse_bw_intel(struct rdt_parse_data *data, struct rdt_resource *r,
> -		   struct rdt_domain *d);
> -int parse_bw_amd(struct rdt_parse_data *data, struct rdt_resource *r,
> -		 struct rdt_domain *d);
> +int parse_bw(struct rdt_parse_data *data, struct rdt_resource *r,
> +	     struct rdt_domain *d);
>  
>  extern struct mutex rdtgroup_mutex;
>  
> 

Babu may want to take a look also.

Thank you

Reinette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ