Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1494774 > unrolled thread
| Started by | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| First post | 2016-10-03 11:30 +0200 |
| Last post | 2016-10-05 08:30 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() Peter Zijlstra <peterz@infradead.org> - 2016-10-03 11:30 +0200
Re: [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() Steven Rostedt <rostedt@goodmis.org> - 2016-10-03 16:20 +0200
Re: [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() Davidlohr Bueso <dave@stgolabs.net> - 2016-10-05 06:00 +0200
Re: [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() Peter Zijlstra <peterz@infradead.org> - 2016-10-05 08:30 +0200
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-10-03 11:30 +0200 |
| Subject | [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() |
| Message-ID | <so7Jo-32K-11@gated-at.bofh.it> |
Since the futex_q can dissapear the instruction after assigning NULL, this really should be a RELEASE barrier. That stops loads from hitting dead memory too. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> --- kernel/futex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/kernel/futex.c +++ b/kernel/futex.c @@ -1288,8 +1288,7 @@ static void mark_wake_futex(struct wake_ * memory barrier is required here to prevent the following * store to lock_ptr from getting ahead of the plist_del. */ - smp_wmb(); - q->lock_ptr = NULL; + smp_store_release(&q->lock_ptr, NULL); } static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *top_waiter,
[toc] | [next] | [standalone]
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2016-10-03 16:20 +0200 |
| Subject | Re: [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() |
| Message-ID | <socg1-62h-15@gated-at.bofh.it> |
| In reply to | #1494774 |
On Mon, 03 Oct 2016 11:12:36 +0200 Peter Zijlstra <peterz@infradead.org> wrote: > Since the futex_q can dissapear the instruction after assigning NULL, > this really should be a RELEASE barrier. That stops loads from hitting > dead memory too. > > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> > --- > kernel/futex.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -1288,8 +1288,7 @@ static void mark_wake_futex(struct wake_ > * memory barrier is required here to prevent the following > * store to lock_ptr from getting ahead of the plist_del. > */ > - smp_wmb(); > - q->lock_ptr = NULL; > + smp_store_release(&q->lock_ptr, NULL); > } > > static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *top_waiter, > Reviewed-by: Steven Rostedt <rostedt@goodmis.org> -- Steve
[toc] | [prev] | [next] | [standalone]
| From | Davidlohr Bueso <dave@stgolabs.net> |
|---|---|
| Date | 2016-10-05 06:00 +0200 |
| Subject | Re: [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() |
| Message-ID | <soLx7-3Dg-1@gated-at.bofh.it> |
| In reply to | #1494774 |
On Mon, 03 Oct 2016, Peter Zijlstra wrote: >Since the futex_q can dissapear the instruction after assigning NULL, >this really should be a RELEASE barrier. That stops loads from hitting >dead memory too. > >Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> >--- > kernel/futex.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > >--- a/kernel/futex.c >+++ b/kernel/futex.c >@@ -1288,8 +1288,7 @@ static void mark_wake_futex(struct wake_ > * memory barrier is required here to prevent the following > * store to lock_ptr from getting ahead of the plist_del. > */ >- smp_wmb(); >- q->lock_ptr = NULL; >+ smp_store_release(&q->lock_ptr, NULL); > } Hmm, what if we relied on the implicit barrier in the wake_q_add() above and got rid of the smp_wmb altogether? We'd obviously have to move up __unqueue_futex(), but all we care about is the publishing store to lock_ptr being the last operation, or at least the plist_del, such that the wakeup order is respected; ie: __unqueue_futex(q); wake_q_add(wake_q, p); q->lock_ptr = NULL; Thanks, Davidlohr
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-10-05 08:30 +0200 |
| Subject | Re: [RFC][PATCH 2/4] futex: Use smp_store_release() in mark_wake_futex() |
| Message-ID | <soNSh-5sp-19@gated-at.bofh.it> |
| In reply to | #1495688 |
On Tue, Oct 04, 2016 at 08:57:55PM -0700, Davidlohr Bueso wrote: > On Mon, 03 Oct 2016, Peter Zijlstra wrote: > > >Since the futex_q can dissapear the instruction after assigning NULL, > >this really should be a RELEASE barrier. That stops loads from hitting > >dead memory too. > > > >Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> > >--- > >kernel/futex.c | 3 +-- > >1 file changed, 1 insertion(+), 2 deletions(-) > > > >--- a/kernel/futex.c > >+++ b/kernel/futex.c > >@@ -1288,8 +1288,7 @@ static void mark_wake_futex(struct wake_ > > * memory barrier is required here to prevent the following > > * store to lock_ptr from getting ahead of the plist_del. > > */ > >- smp_wmb(); > >- q->lock_ptr = NULL; > >+ smp_store_release(&q->lock_ptr, NULL); > >} > > Hmm, what if we relied on the implicit barrier in the wake_q_add() > above and got rid of the smp_wmb altogether? We'd obviously have to > move up __unqueue_futex(), but all we care about is the publishing > store to lock_ptr being the last operation, or at least the plist_del, > such that the wakeup order is respected; ie: > > __unqueue_futex(q); > wake_q_add(wake_q, p); > q->lock_ptr = NULL; Less obvious but would work I suppose, I didn't look too hard at the ordering requirements on __unqueue_futex(), but an early morning glance (without tea) doesn't show any obvious problems with that.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web