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: <SJ1PR11MB60838F3FFF40AE2718ED7833FC792@SJ1PR11MB6083.namprd11.prod.outlook.com>
Date: Fri, 11 Oct 2024 21:33:50 +0000
From: "Luck, Tony" <tony.luck@...el.com>
To: "babu.moger@....com" <babu.moger@....com>
CC: "corbet@....net" <corbet@....net>, "Yu, Fenghua" <fenghua.yu@...el.com>,
	"Chatre, Reinette" <reinette.chatre@...el.com>, "tglx@...utronix.de"
	<tglx@...utronix.de>, "mingo@...hat.com" <mingo@...hat.com>, "bp@...en8.de"
	<bp@...en8.de>, "dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
	"x86@...nel.org" <x86@...nel.org>, "hpa@...or.com" <hpa@...or.com>,
	"paulmck@...nel.org" <paulmck@...nel.org>, "rdunlap@...radead.org"
	<rdunlap@...radead.org>, "tj@...nel.org" <tj@...nel.org>,
	"peterz@...radead.org" <peterz@...radead.org>, "yanjiewtw@...il.com"
	<yanjiewtw@...il.com>, "kim.phillips@....com" <kim.phillips@....com>,
	"lukas.bulwahn@...il.com" <lukas.bulwahn@...il.com>, "seanjc@...gle.com"
	<seanjc@...gle.com>, "jmattson@...gle.com" <jmattson@...gle.com>,
	"leitao@...ian.org" <leitao@...ian.org>, "jpoimboe@...nel.org"
	<jpoimboe@...nel.org>, "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
	"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>, "Joseph,
 Jithu" <jithu.joseph@...el.com>, "Huang, Kai" <kai.huang@...el.com>,
	"kan.liang@...ux.intel.com" <kan.liang@...ux.intel.com>,
	"daniel.sneddon@...ux.intel.com" <daniel.sneddon@...ux.intel.com>,
	"pbonzini@...hat.com" <pbonzini@...hat.com>, "sandipan.das@....com"
	<sandipan.das@....com>, "ilpo.jarvinen@...ux.intel.com"
	<ilpo.jarvinen@...ux.intel.com>, "peternewman@...gle.com"
	<peternewman@...gle.com>, "Wieczor-Retman, Maciej"
	<maciej.wieczor-retman@...el.com>, "linux-doc@...r.kernel.org"
	<linux-doc@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "Eranian, Stephane" <eranian@...gle.com>,
	"james.morse@....com" <james.morse@....com>
Subject: RE: [PATCH v8 19/25] x86/resctrl: Auto assign/unassign counters when
 mbm_cntr_assign is enabled

> >> +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);

Consider that this call fails. "ret" indicates failure to allocate.

> >> +
> >> +  if (!ret && is_mbm_local_enabled())
> >> +          ret = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);

Now this call succeeds. The failure of the previous call is forgotten as "ret" is
overwritten with the success code.

> >
> > This overwrites the value from allocating the counter for total event.
>
> Total event and local events have two different indexes.
> Can you please elaborate?

See comments above.  If you want a return code you need

	int ret_local = 0, ret_total = 0;

	if (is_mbm_total_enabled())
		ret_total = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID);
	if (!ret && is_mbm_local_enabled())
		ret_local = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);


	return some_function of ret_local and ret_total;

Not sure if you want to say success only if both of these calls succeeded. Or maybe if either worked?

But it all seems complicated since callers don't have to take any different action depending on whether allocation of a counter succeeds or fails.

-Tony


	

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ