Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1559860

Re: [PATCH 7/8] x86/intel_rdt/mba: Add schemata file support for MBA

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH 7/8] x86/intel_rdt/mba: Add schemata file support for MBA
Date 2017-01-16 17:10 +0100
Message-ID <t0i13-2KF-3@gated-at.bofh.it> (permalink)
References <sYaqZ-5m6-3@gated-at.bofh.it> <sYar1-5m6-59@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 10 Jan 2017, Vikas Shivappa wrote:
> + * @display_str:		Format string to show schemata
> + * @validate:			API to validate the ctrl values.
>   * @info_files:		resctrl info files for the resource
>   * @infofiles_len:		Number of info files
>   * @max_delay:		Max throttle delay
> @@ -99,6 +101,9 @@ struct rdt_resource {
>  	int			cbm_len;
>  	int			min_cbm_bits;
>  	u32			no_ctrl;
> +	char			*display_str;
> +	int (*validate)		(char *buf, unsigned long *data,
> +				  struct rdt_resource *r);

Again this display and validation change wants to be seperate from the
bandwidth stuff.

It's not rocket science to split patches into preparatory and
implementation parts.

> +	r->display_str = kstrdup("%d=%d", GFP_KERNEL);
> +	if (!r->display_str)
> +		return -ENOMEM;

And the point of this allocation is? To consume extra memory for a constant
string which is in const data anyway.

       r->display_str = "%d=%d";

does not need allcotion and consumes exactly the same amount of const data
as the above. Oh well...

> -static inline bool get_rdt_resources(void)
> +static inline int get_rdt_resources(void)
>  {

And the point of this change is? Lots of churn to return the same -ENODEV
value at the call site. So why are you trying to return other values
instead of the simple boolean success/fail decision?

>  /*
> + * Check whether MBE 'throttle by' value is correct.
> + *	As per the SDM, when the scale is linear the
> + *	throttle_by granularity is '100 - max_thrtl_by'
> + *	and when its non-linear it is 'power of 2'.

That's wrong. We really want to let the user set a bandwidth percentage
value from 0 - 100 %. And then adjust it to the proper value which the
hardware can provide. So the user value is independent from granularity,
linear and the max throttling allowed.

>  /*
> - * Read one cache bit mask (hex). Check that it is valid for the current
> - * resource type.
> + * Read the user RDT control value into tempory buffer:
> + * Cache bit mask (hex) or Memory b/w throttle (decimal).
> + * Check that it is valid for the current resource type.
>   */
> -static int parse_cbm(char *buf, struct rdt_resource *r)
> +static int parse_ctrls(char *buf, struct rdt_resource *r)
>  {
>  	unsigned long data;
> -	int ret;
> +	int ret = 0;

What's the purpose of initializing ret to 0 if the next action is assigning
ret the return value of the validate function?

> -	ret = kstrtoul(buf, 16, &data);
> -	if (ret)
> -		return ret;
> -	if (!cbm_validate(data, r))
> -		return -EINVAL;
> +	ret = r->validate(buf, &data, r);
>  	r->tmp_ctrl[r->num_tmp_ctrl++] = data;
>  
> -	return 0;
> +	return ret;
>  }

Thanks,

	tglx

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/8 V1] x86/intel_rdt: Memory b/w Allocation support Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-01-10 20:40 +0100
  [PATCH 7/8] x86/intel_rdt/mba: Add schemata file support for MBA Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-01-10 20:40 +0100
    Re: [PATCH 7/8] x86/intel_rdt/mba: Add schemata file support for  MBA Thomas Gleixner <tglx@linutronix.de> - 2017-01-16 17:10 +0100
      Re: [PATCH 7/8] x86/intel_rdt/mba: Add schemata file support for  MBA Shivappa Vikas <vikas.shivappa@intel.com> - 2017-01-18 02:10 +0100
  [PATCH 5/8] x86/intel_rct/mba: Add MBA structures and initialize MBA Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-01-10 20:40 +0100
    Re: [PATCH 5/8] x86/intel_rct/mba: Add MBA structures and initialize  MBA Thomas Gleixner <tglx@linutronix.de> - 2017-01-16 15:10 +0100
      Re: [PATCH 5/8] x86/intel_rct/mba: Add MBA structures and initialize  MBA Shivappa Vikas <vikas.shivappa@intel.com> - 2017-01-18 02:00 +0100
  [PATCH 8/8] x86/intel_rdt: rmdir,umount and hotcpu updates for MBA Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-01-10 20:40 +0100
    Re: [PATCH 8/8] x86/intel_rdt: rmdir,umount and hotcpu updates for  MBA Thomas Gleixner <tglx@linutronix.de> - 2017-01-16 17:20 +0100
      Re: [PATCH 8/8] x86/intel_rdt: rmdir,umount and hotcpu updates for  MBA Shivappa Vikas <vikas.shivappa@intel.com> - 2017-01-23 21:20 +0100

csiph-web