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: <95829e55-adb3-499e-9285-34a47839e2da@linux.intel.com>
Date: Thu, 20 Jun 2024 12:02:05 -0400
From: "Liang, Kan" <kan.liang@...ux.intel.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: mingo@...nel.org, acme@...nel.org, namhyung@...nel.org,
 irogers@...gle.com, adrian.hunter@...el.com,
 alexander.shishkin@...ux.intel.com, linux-kernel@...r.kernel.org,
 ak@...ux.intel.com, eranian@...gle.com, Sandipan Das <sandipan.das@....com>,
 Ravi Bangoria <ravi.bangoria@....com>, silviazhao
 <silviazhao-oc@...oxin.com>, CodyYao-oc <CodyYao-oc@...oxin.com>
Subject: Re: [RESEND PATCH 02/12] perf/x86: Support counter mask



On 2024-06-20 3:06 a.m., Peter Zijlstra wrote:
> On Tue, Jun 18, 2024 at 08:10:34AM -0700, kan.liang@...ux.intel.com wrote:
> 
>> +	for_each_set_bit(idx, c->idxmsk, x86_pmu_num_counters(NULL)) {
>>  		if (new == -1 || hwc->idx == idx)
>>  			/* assign free slot, prefer hwc->idx */
>>  			old = cmpxchg(nb->owners + idx, NULL, event);
> 
>> +static inline int x86_pmu_num_counters_fixed(struct pmu *pmu)
>> +{
>> +	return hweight64(hybrid(pmu, fixed_cntr_mask64));
>> +}
> 
> 
> This is wrong. You don't iterate a bitmask by the number of bits set,
> but by the highest set bit in the mask.

It seems we need two functions for the number.
For the above iterate case, yes, we need the highest set bit to tell the
possible max number.

There could be other cases as below. An exact number of available
counters are required.

-void x86_pmu_show_pmu_cap(int num_counters, int num_counters_fixed,
-                         u64 intel_ctrl)
+void x86_pmu_show_pmu_cap(struct pmu *pmu)
 {
        pr_info("... version:                %d\n",     x86_pmu.version);
        pr_info("... bit width:              %d\n",
x86_pmu.cntval_bits);
-       pr_info("... generic registers:      %d\n",     num_counters);
+       pr_info("... generic registers:      %d\n",
x86_pmu_num_counters(pmu));
I will add two functions,  x86_pmu_max_num_counters() and
x86_pmu_num_counters().

Thanks,
Kan


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ