Re: [PATCH v5 11/18] x86/intel_rdt: Add basic resctrl filesystem support
From: Thomas Gleixner
Date:  Wed Oct 26 2016 - 11:04:41 EST
On Sat, 22 Oct 2016, Fenghua Yu wrote:
> +static void l3_qos_cfg_update(void *arg)
> +{
> +	bool enable = *(bool *)arg;
> +
> +	wrmsrl(IA32_L3_QOS_CFG, enable);
Bah. What's wrong with
	bool *enable = arg;
	wrmsrl(IA32_L3_QOS_CFG, *enable);
That does not have this cute type cast, right?
> +static int set_l3_qos_cfg(struct rdt_resource *r, bool enable)
> +{
> +	struct rdt_domain *d;
> +	cpumask_var_t cpu_mask;
> +	int cpu;
That's the last time I ask for consistent variable ordering politely:
	cpumask_var_t cpu_mask;
	struct rdt_domain *d;
	int cpu;
> +static struct dentry *rdt_mount(struct file_system_type *fs_type,
> +				int flags, const char *unused_dev_name,
> +				void *data)
> +{
> +	struct dentry *dentry;
> +	int ret;
> +
> +	mutex_lock(&rdtgroup_mutex);
> +	/*
> +	 * resctrl file system can only be mounted once.
> +	 */
> +	if (static_branch_unlikely(&rdt_enable_key)) {
> +		dentry = ERR_PTR(-EBUSY);
> +		goto out;
> +	}
> +
> +	ret = parse_rdtgroupfs_options(data);
> +	if (ret) {
> +		dentry = ERR_PTR(ret);
> +		goto out;
> +	}
> +
> +	dentry = kernfs_mount(fs_type, flags, rdt_root,
> +			      RDTGROUP_SUPER_MAGIC, NULL);
> +	if (IS_ERR(dentry))
> +		goto out;
> +
> +	if (rdt_resources_all[RDT_RESOURCE_L3DATA].enabled &&
> +	    rdt_resources_all[RDT_RESOURCE_L3CODE].enabled) {
> +		ret = set_l3_qos_cfg(&rdt_resources_all[RDT_RESOURCE_L3], true);
> +		if (ret)
> +			goto out;
So you skip the key enable, but the mount persists and the return value of
that function is not propagated. 
> +	}
> +	static_branch_enable(&rdt_enable_key);
> +
> +out:
> +	mutex_unlock(&rdtgroup_mutex);
> +
> +	return dentry;
> +}
> +
> +static int reset_all_cbms(struct rdt_resource *r)
> +{
> +	struct rdt_domain *d;
> +	struct msr_param msr_param;
> +	cpumask_var_t cpu_mask;
> +	int i, cpu;
See above and everywhere ....
> +	if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL))
> +		return -ENOMEM;
> +
> +	msr_param.res = r;
> +	msr_param.low = 0;
> +	msr_param.high = r->num_closid;
> +
> +	/*
> +	 * Reset each domain's all CBMs to max value and copy the domain's
What means 'reset CBMs to max value'? I know what it means as do you and a
few others. 3 month from now we all scratch our heads...
> +static void rdt_kill_sb(struct super_block *sb)
> +{
> +	struct rdt_resource *r;
> +
> +	mutex_lock(&rdtgroup_mutex);
> +
> +	/*Put everything back to default values. */
> +	for_each_enabled_rdt_resource(r)
> +		reset_all_cbms(r);
> +	r = &rdt_resources_all[RDT_RESOURCE_L3];
> +	r->enabled = r->capable;
> +	if (boot_cpu_has(X86_FEATURE_CDP_L3)) {
Why?
	if (rdt_resources_all[RDT_RESOURCE_L3DATA].enabled) {
only executes that if the thing was enabled.
> +		rdt_resources_all[RDT_RESOURCE_L3DATA].enabled = false;
> +		rdt_resources_all[RDT_RESOURCE_L3CODE].enabled = false;
> +		set_l3_qos_cfg(r, false);
> +	}
> +
> +	static_branch_disable(&rdt_enable_key);
> +	kernfs_kill_sb(sb);
> +	mutex_unlock(&rdtgroup_mutex);
> +}
Thanks,
	tglx