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
| ||
|
Date: Thu, 12 Sep 2013 03:25:31 +0200 From: Peter Zijlstra <peterz@...radead.org> To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com> Cc: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>, John Stultz <john.stultz@...aro.org>, Thomas Gleixner <tglx@...utronix.de>, Richard Cochran <richardcochran@...il.com>, Prarit Bhargava <prarit@...hat.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Steven Rostedt <rostedt@...dmis.org>, Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org, lttng-dev@...ts.lttng.org Subject: Re: [RFC PATCH] timekeeping: introduce timekeeping_is_busy() On Wed, Sep 11, 2013 at 08:48:11PM -0400, Mathieu Desnoyers wrote: > Thoughts ? struct foo { ... }; spinlock_t foo_lock; unsigned int foo_head = 0; unsigned int foo_tail = 0; struct foo foo_array[2]; void foo_assign(struct foo f) { spin_lock(&foo_lock); foo_head++; smp_wmb(); foo_array[foo_head & 1] = f; smp_wmb(); foo_tail++; spin_unlock(&foo_lock); } struct foo foo_get(void) { unsigned int tail, head; struct foo ret; again: tail = ACCESS_ONCE(foo_tail); smp_rmb(); ret = foo_array[tail & 1]; smp_rmb(); head = ACCESS_ONCE(foo_head); if (head - tail >= 2) goto again; return ret; } Should work and get you the most recent 'complete' foo even when foo_get() is called nested inside foo_assign(). -- 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