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]
Date:   Thu, 6 Feb 2020 12:08:20 -0500
From:   Waiman Long <longman@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...hat.com>, Will Deacon <will.deacon@....com>,
        linux-kernel@...r.kernel.org, Bart Van Assche <bvanassche@....org>
Subject: Re: [PATCH v6 6/6] locking/lockdep: Reuse freed chain_hlocks entries

On 2/6/20 11:16 AM, Peter Zijlstra wrote:
> On Thu, Feb 06, 2020 at 10:24:08AM -0500, Waiman Long wrote:
>> +static int alloc_chain_hlocks(int req)
>> +{
>> +	int bucket, curr, size;
>> +
>> +	/*
>> +	 * We rely on the MSB to act as an escape bit to denote freelist
>> +	 * pointers. Make sure this bit isn't set in 'normal' class_idx usage.
>> +	 */
>> +	BUILD_BUG_ON((MAX_LOCKDEP_KEYS-1) & CHAIN_BLK_FLAG);
>> +
>> +	init_data_structures_once();
>> +
>> +	if (nr_free_chain_hlocks < req)
>> +		return -1;
>> +
>> +	/*
>> +	 * We require a minimum of 2 (u16) entries to encode a freelist
>> +	 * 'pointer'.
>> +	 */
>> +	req = max(req, 2);
>> +	bucket = size_to_bucket(req);
>> +	curr = chain_block_buckets[bucket];
>> +
>> +	if (bucket && (curr >= 0)) {
>> +		del_chain_block(bucket, req, chain_block_next(curr));
>> +		return curr;
>> +	} else if (bucket) {
>> +		/* Try bucket 0 */
>> +		curr = chain_block_buckets[0];
>> +	}
> 	if (bucket) {
> 		if (curr >= 0) {
> 			del_chain_block(bucket, req, chain_block_next(curr));
> 			return curr;
> 		}
> 		/* Try bucket 0 */
> 		curr = chain_block_bucket[0];
> 	}
>
> reads much easier IMO.

Yes, that is simpler. I can send out an updated patch if you want, or
you can apply the change when you pull the patch.

Thanks,
Longman

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ