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:	Fri, 31 Jan 2014 20:45:35 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Waiman Long <waiman.long@...com>
Cc:	Tim Chen <tim.c.chen@...ux.intel.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, Arnd Bergmann <arnd@...db.de>,
	linux-arch@...r.kernel.org, x86@...nel.org,
	linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Michel Lespinasse <walken@...gle.com>,
	Andi Kleen <andi@...stfloor.org>,
	Rik van Riel <riel@...hat.com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Raghavendra K T <raghavendra.kt@...ux.vnet.ibm.com>,
	George Spelvin <linux@...izon.com>,
	Daniel J Blueman <daniel@...ascale.com>,
	Alexander Fyodorov <halcy@...dex.ru>,
	Aswin Chandramouleeswaran <aswin@...com>,
	Scott J Norton <scott.norton@...com>,
	Thavatchai Makphaibulchoke <thavatchai.makpahibulchoke@...com>
Subject: Re: [PATCH v3 1/2] qspinlock: Introducing a 4-byte queue spinlock
 implementation

On Fri, Jan 31, 2014 at 01:26:29PM -0500, Waiman Long wrote:
> >I don't get why we need the used thing at all; something like:
> >
> >struct qna {
> >	int cnt;
> >	struct qnode nodes[4];
> >};
> >
> >DEFINE_PER_CPU(struct qna, qna);
> >
> >struct qnode *get_qnode(void)
> >{
> >	struct qna *qna = this_cpu_ptr(&qna);
> >
> >	return qna->nodes[qna->cnt++]; /* RMW */
> >}
> >
> >void put_qnode(struct qnode *qnode)
> >{
> >	struct qna *qna = this_cpu_ptr(&qna);
> >	qna->cnt--;
> >}
> >
> >Should do fine, right?
> 
> Yes, we can do something like that. However I think put_qnode() needs to use
> atomic dec as well. As a result, we will need 2 additional atomic operations
> per slowpath invocation. The code may look simpler, but I don't think it
> will be faster than what I am currently doing as the cases where the used
> flag is set will be relatively rare.

No, put doesn't need an atomic; nor is it as well; because the inc
doesn't need an atomic either.

> >If we interrupt the RMW above the interrupted context hasn't yet used
> >the queue and once we return its free again, so all should be well even
> >on load-store archs.
> >
> >The nodes array might as well be 3, because NMIs should never contend on
> >a spinlock, so all we're left with is task, softirq and hardirq context.
> 
> I am not so sure about NMI not taking a spinlock. I seem to remember seeing
> code that did that. Actually, I think the NMI code is trying to printk
> something which, in turn, need to acquire a spinlock.

Yeah I know, terribly broken that, I've been waiting for that to explode
:-)
--
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