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: <1370981396.9844.219.camel@gandalf.local.home>
Date:	Tue, 11 Jun 2013 16:09:56 -0400
From:	Steven Rostedt <rostedt@...dmis.org>
To:	paulmck@...ux.vnet.ibm.com
Cc:	Waiman Long <waiman.long@...com>, linux-kernel@...r.kernel.org,
	mingo@...e.hu, laijs@...fujitsu.com, dipankar@...ibm.com,
	akpm@...ux-foundation.org, mathieu.desnoyers@...icios.com,
	josh@...htriplett.org, niv@...ibm.com, tglx@...utronix.de,
	peterz@...radead.org, Valdis.Kletnieks@...edu, dhowells@...hat.com,
	edumazet@...gle.com, darren@...art.com, fweisbec@...il.com,
	sbw@....edu, torvalds@...ux-foundation.org,
	Davidlohr Bueso <davidlohr.bueso@...com>
Subject: Re: [PATCH RFC ticketlock] Auto-queued ticketlock

On Tue, 2013-06-11 at 12:49 -0700, Paul E. McKenney wrote:

> +bool tkt_spin_pass(arch_spinlock_t *ap, struct __raw_tickets inc)
> +{
> +	if (unlikely(inc.head & 0x1)) {
> +
> +		/* This lock has a queue, so go spin on the queue. */
> +		if (tkt_q_do_spin(ap, inc))
> +			return true;
> +
> +		/* Get here if the queue is in transition: Retry next time. */
> +

This looks better, but please add a comment, something to the likes of:

	/*
	 * Only the TKT_Q_SWITCH waiter will set up the queue to prevent
	 * a thundering herd of setups to occur. It is still possible for
	 * more than one task to perform a setup if the lock is released
	 * after this check, a waiter coming in may also match this test. But
	 * that's covered by the cmpxchg() setup in tkt_q_start_contend.
	 */


> +	} else if (inc.tail - TKT_Q_SWITCH == inc.head) {

Also shouldn't this be:

	} else if ((__ticket_t)(inc.tail - TKT_Q_SWITCH) == inc.head) {

As TKT_Q_SWITCH doesn't have a type, I'm not sure how C will evaluate
this. I always screw type conversions up, and just add in the type casts
to be safe.

You could also give TKT_Q_SWITCH a type too.

-- Steve

> +
> +		/*
> +		 * This lock has lots of spinners, but no queue.
> +		 * Go create a queue to spin on.
> +		 */
> +		if (tkt_q_start_contend(ap, inc))
> +			return true;
> +
> +		/* Get here if the queue is in transition: Retry next time. */
> +	}
> +
> +	/* Either no need for a queue or the queue is in transition.  Spin. */
> +	return false;
> +}
> +EXPORT_SYMBOL(tkt_spin_pass);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ