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: <2ef41d9a-b0a4-4cd4-a63b-8e79a42872d4@amd.com>
Date: Tue, 16 Jul 2024 16:04:41 -0500
From: "Moger, Babu" <babu.moger@....com>
To: Reinette Chatre <reinette.chatre@...el.com>, corbet@....net,
 fenghua.yu@...el.com, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
 dave.hansen@...ux.intel.com
Cc: 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 v5 16/20] x86/resctrl: Report "Unassigned" for MBM events
 in ABMC mode

Hi Reinette,


On 7/12/24 17:13, Reinette Chatre wrote:
> Hi Babu,
> 
> On 7/3/24 2:48 PM, Babu Moger wrote:
>> In ABMC mode, the hardware counter should be assigned to read the MBM
>> events.
>>
>> Report "Unassigned" in case the user attempts to read the events without
>> assigning the counter.
>>
>> Signed-off-by: Babu Moger <babu.moger@....com>
>> ---
>> v5: New patch.
>> ---
>>   Documentation/arch/x86/resctrl.rst        |  4 ++++
>>   arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 19 ++++++++++++++-----
>>   2 files changed, 18 insertions(+), 5 deletions(-)
>>
>> diff --git a/Documentation/arch/x86/resctrl.rst
>> b/Documentation/arch/x86/resctrl.rst
>> index 4907d0758118..11b7a5f26b40 100644
>> --- a/Documentation/arch/x86/resctrl.rst
>> +++ b/Documentation/arch/x86/resctrl.rst
>> @@ -284,6 +284,10 @@ with the following files:
>>       until the user unassigns it manually. There is no need to worry
>>       about counters being reset during this period.
>>   +    In ABMC mode, the MBM event counters will return "Unassigned" if
>> +    the hardware counter is not assigned to the event. Users need to
>> +    assign a counter manually to read the events.
> 
> This no longer seems accurate with counters assigned by default.

But, there are still cases where counters are not available for
assignment. Users can create more groups than the number of available
counters. I will add those details here.
> 
>> +
>>       Without ABMC enabled, monitoring will work in "legacy" mode
>>       without assignment option.
>>   diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>> b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>> index 50fa1fe9a073..e60b469b7d12 100644
>> --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>> +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>> @@ -562,7 +562,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void
>> *arg)
>>       struct rdtgroup *rdtgrp;
>>       struct rdt_resource *r;
>>       union mon_data_bits md;
>> -    int ret = 0;
>> +    int ret = 0, index;
>>         rdtgrp = rdtgroup_kn_lock_live(of->kn);
>>       if (!rdtgrp) {
>> @@ -609,12 +609,21 @@ int rdtgroup_mondata_show(struct seq_file *m, void
>> *arg)
>>     checkresult:
>>   -    if (rr.err == -EIO)
>> +    if (rr.err == -EIO) {
>>           seq_puts(m, "Error\n");
>> -    else if (rr.err == -EINVAL)
>> -        seq_puts(m, "Unavailable\n");
>> -    else
>> +    } else if (rr.err == -EINVAL) {
>> +        if (resctrl_arch_get_abmc_enabled()) {
>> +            index = mon_event_config_index_get(evtid);
>> +            if (rdtgrp->mon.cntr_id[index] == MON_CNTR_UNSET)
>> +                seq_puts(m, "Unassigned\n");
>> +            else
>> +                seq_puts(m, "Unavailable\n");
>> +        } else {
>> +            seq_puts(m, "Unavailable\n");
>> +        }
>> +    } else {
>>           seq_printf(m, "%llu\n", rr.val);
>> +    }
>>   
> 
> This still attempts to read from hardware that is futile to do knowing
> that a counter is not assigned. Why not just print "Unassigned" right away
> without trying to read data from hardware when knowing it will fail?

Yes. I will we can do that. Will do it.

> 
>>   out:
>>       rdtgroup_kn_unlock(of->kn);
> 
> Reinette
> 

-- 
Thanks
Babu Moger

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ