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: <ZwldvDBjEA3TSw2k@agluck-desk3.sc.intel.com>
Date: Fri, 11 Oct 2024 10:17:48 -0700
From: Tony Luck <tony.luck@...el.com>
To: Babu Moger <babu.moger@....com>
Cc: corbet@....net, fenghua.yu@...el.com, reinette.chatre@...el.com,
	tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
	dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
	paulmck@...nel.org, rdunlap@...radead.org, tj@...nel.org,
	peterz@...radead.org, yanjiewtw@...il.com, kim.phillips@....com,
	lukas.bulwahn@...il.com, seanjc@...gle.com, jmattson@...gle.com,
	leitao@...ian.org, jpoimboe@...nel.org, rick.p.edgecombe@...el.com,
	kirill.shutemov@...ux.intel.com, jithu.joseph@...el.com,
	kai.huang@...el.com, kan.liang@...ux.intel.com,
	daniel.sneddon@...ux.intel.com, pbonzini@...hat.com,
	sandipan.das@....com, ilpo.jarvinen@...ux.intel.com,
	peternewman@...gle.com, maciej.wieczor-retman@...el.com,
	linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
	eranian@...gle.com, james.morse@....com
Subject: Re: [PATCH v8 19/25] x86/resctrl: Auto assign/unassign counters when
 mbm_cntr_assign is enabled

On Wed, Oct 09, 2024 at 12:39:44PM -0500, Babu Moger wrote:
> +/*
> + * Called when a new group is created. If `mbm_cntr_assign` mode is enabled,
> + * counters are automatically assigned. Each group requires two counters:
> + * one for the total event and one for the local event. Due to the limited
> + * number of counters, assignments may fail in some cases. However, it is
> + * not necessary to fail the group creation. Users have the option to
> + * modify the assignments after the group has been created.
> + */
> +static int rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp)
> +{
> +	struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
> +	int ret = 0;
> +
> +	if (!resctrl_arch_mbm_cntr_assign_enabled(r))
> +		return 0;
> +
> +	if (is_mbm_total_enabled())
> +		ret = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID);
> +
> +	if (!ret && is_mbm_local_enabled())
> +		ret = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);

This overwrites the value from allocating the counter for total event.

> +
> +	return ret;

But none of the callers check the return. Indeed it is ok (and
expected) that counter allocation can fail.

Just make this a "void" function and delete the "ret" local variable.
> +}
> +
> +/*
> + * Called when a group is deleted. Counters are unassigned if it was in
> + * assigned state.
> + */
> +static int rdtgroup_unassign_cntrs(struct rdtgroup *rdtgrp)
> +{
> +	struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
> +	int ret = 0;
> +
> +	if (!resctrl_arch_mbm_cntr_assign_enabled(r))
> +		return 0;
> +
> +	if (is_mbm_total_enabled())
> +		ret = rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID);
> +
> +	if (!ret && is_mbm_local_enabled())
> +		ret = rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);
> +
> +	return ret;

Ditto. No caller checks. Make this a void function. Dig down the
call chain here. It looks like rdtgroup_unassign_cntr_event() can't
fail, so it should be a void function too. Ditto resctrl_arch_config_cntr()
> +}

-Tony

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ