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:	Wed, 20 Apr 2016 16:18:19 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Pan Xinhui <xinhui@...ux.vnet.ibm.com>
Cc:	Waiman Long <Waiman.Long@....com>, Ingo Molnar <mingo@...hat.com>,
	linux-kernel@...r.kernel.org,
	Scott J Norton <scott.norton@....com>,
	Douglas Hatch <doug.hatch@....com>
Subject: Re: [PATCH v2] locking/pvqspinlock: Add lock holder CPU argument to
 pv_wait()

On Wed, Apr 20, 2016 at 10:15:09PM +0800, Pan Xinhui wrote:
> >> +static struct pv_node *pv_lookup_hash(struct qspinlock *lock)
> >> +{
> >> +	unsigned long offset, hash = hash_ptr(lock, pv_lock_hash_bits);
> >> +	struct pv_hash_entry *he;
> >> +
> >> +	for_each_hash_entry(he, offset, hash) {
> >> +		struct qspinlock *l = READ_ONCE(he->lock);
> >> +
> >> +		if (l == lock)
> > 
> > The other loop writes:
> > 
> > 		if (READ_ONCE(he->lock) == lock)
> > 
> Maybe because we check l is NULL or not later. So save one load.

Ah duh, yes.

> >> +			return READ_ONCE(he->node);
> >> +		/*
> >> +		 * Presence of an empty slot signal the end of search. We
> >> +		 * may miss the entry, but that will limit the amount of
> >> +		 * time doing the search when the desired entry isn't there.
> >> +		 */
> >> +		else if (!l)
> >> +			break;
> > 
> > That 'else' is entirely pointless. Also, why isn't this: return NULL;
> > 
> >> +	}
> >> +	return NULL;
> > 
> > and this BUG() ?
> > 
> It's not a bug, the lock might not be stored in the hashtable. in unlock function, we will unhash the lock, then what will happen is:

It should be if the above becomes a return NULL, no?

If we can iterate the _entire_ hashtable, this lookup can be immensely
expensive and we should not be doing it inside of a wait-loop.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ