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: <5caa74a5-a73d-a5ce-9169-396ad3727386@arm.com>
Date:   Tue, 31 Aug 2021 17:25:01 +0100
From:   James Morse <james.morse@....com>
To:     Jamie Iles <jamie@...iainc.com>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org,
        Fenghua Yu <fenghua.yu@...el.com>,
        Reinette Chatre <reinette.chatre@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        H Peter Anvin <hpa@...or.com>,
        Babu Moger <Babu.Moger@....com>,
        shameerali.kolothum.thodi@...wei.com,
        D Scott Phillips OS <scott@...amperecomputing.com>,
        lcherian@...vell.com, bobo.shaobowang@...wei.com
Subject: Re: [PATCH v1 12/20] x86/recstrl: Add per-rmid arch private storage
 for overflow and chunks

Hi Jamie,

On 11/08/2021 18:14, Jamie Iles wrote:
> On Thu, Jul 29, 2021 at 10:36:02PM +0000, James Morse wrote:
>> resctrl_arch_rmid_read() is intended as the function that an
>> architecture agnostic resctrl filesystem driver can use to
>> read a value in bytes from a counter. Currently the function returns
>> the mbm values in chunks directly from hardware. For bandwidth
>> counters the resctrl filesystem provides the number of bytes
>> ever seen. Internally mba_sc uses a second prev_bw_msr to calculate
>> the bytes read since the last mba_sc invocation.
>>
>> MPAM's scaling of counters can be changed at runtime, reducing the
>> resolution but increasing the range. When this is changed the prev_msr
>> values need to be converted by the architecture code.
>>
>> Add storage for per-rmid private storage. The prev_msr and chunks
>> values will move here to allow resctrl_arch_rmid_read() to always
>> return the number of bytes read by this counter.

>> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
>> index 8a3c13c6c19f..27c93d12ca27 100644
>> --- a/arch/x86/kernel/cpu/resctrl/core.c
>> +++ b/arch/x86/kernel/cpu/resctrl/core.c
>> @@ -432,6 +432,28 @@ static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d)

>> +static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_domain *hw_dom)
>> +{
>> +	size_t tsize;
>> +
>> +	if (is_mbm_total_enabled()) {
>> +		tsize = sizeof(*hw_dom->arch_mbm_total);
>> +		hw_dom->arch_mbm_total = kcalloc(num_rmid, tsize, GFP_KERNEL);
>> +		if (!hw_dom->arch_mbm_total)
>> +			return -ENOMEM;
>> +	}
>> +	if (is_mbm_local_enabled()) {
>> +		tsize = sizeof(*hw_dom->arch_mbm_local);
>> +		hw_dom->arch_mbm_local = kcalloc(num_rmid, tsize, GFP_KERNEL);
>> +		if (!hw_dom->arch_mbm_local) {
>> +			kfree(hw_dom->arch_mbm_total);
>> +			return -ENOMEM;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +

>> @@ -481,6 +503,11 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r)
>>  		return;
>>  	}
>>  
>> +	if (r->mon_capable && arch_domain_mbm_alloc(r->num_rmid, hw_dom)) {
>> +		kfree(d);
> 
> Does this error path and subsequent ones in domain_add_cpu also need to 
> undo the allocations from arch_domain_mbm_alloc?

This one needs to free the ctrl_val array, as does the path from resctrl_online_domain().
Yes, resctrl_online_domain() needs to free the two mbm arrays. Thanks!

Its probably cleanest to add some helper in patch 3 that kfree()s anything that might have
been allocated, and add-to/remote-from that over time. The root structure is kzalloc()d ,
so shouldn't need an elaborate and verbose unwind/goto-nest.


Thanks,

James

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ