* [PATCH] events/uprobes: move smp_read_barrier_depends() where needed
@ 2016-06-09 18:18 Andrea Parri
2016-06-10 7:03 ` Oleg Nesterov
0 siblings, 1 reply; 7+ messages in thread
From: Andrea Parri @ 2016-06-09 18:18 UTC (permalink / raw)
To: Oleg Nesterov, Peter Zijlstra; +Cc: LKML, Andrea Parri
There is no need to use the barrier if there is no dereference/
memory access; move it where needed (currently, affecting only
Alpha). While touching this, also make the reads _ONCE().
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
---
kernel/events/uprobes.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index b7a525ab2083..b1364acd683e 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1520,10 +1520,11 @@ static unsigned long get_trampoline_vaddr(void)
struct xol_area *area;
unsigned long trampoline_vaddr = -1;
- area = current->mm->uprobes_state.xol_area;
- smp_read_barrier_depends();
- if (area)
- trampoline_vaddr = area->vaddr;
+ area = READ_ONCE(current->mm->uprobes_state.xol_area);
+ if (area) {
+ smp_read_barrier_depends();
+ trampoline_vaddr = READ_ONCE(area->vaddr);
+ }
return trampoline_vaddr;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] events/uprobes: move smp_read_barrier_depends() where needed
2016-06-09 18:18 [PATCH] events/uprobes: move smp_read_barrier_depends() where needed Andrea Parri
@ 2016-06-10 7:03 ` Oleg Nesterov
2016-06-10 12:26 ` Oleg Nesterov
[not found] ` <CAPZ9YJaxdqpCh9DyD7ubrTEhCL9jEdMzNN6zJHsOPYGN5NNPXg@mail.gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Oleg Nesterov @ 2016-06-10 7:03 UTC (permalink / raw)
To: Andrea Parri; +Cc: Peter Zijlstra, LKML
On 06/09, Andrea Parri wrote:
>
> There is no need to use the barrier if there is no dereference/
> memory access; move it where needed (currently, affecting only
> Alpha).
OK, although area == NULL is unlikely case,
> While touching this, also make the reads _ONCE().
Why? both xol_area/vaddr can't change.
> Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
> ---
> kernel/events/uprobes.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index b7a525ab2083..b1364acd683e 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1520,10 +1520,11 @@ static unsigned long get_trampoline_vaddr(void)
> struct xol_area *area;
> unsigned long trampoline_vaddr = -1;
>
> - area = current->mm->uprobes_state.xol_area;
> - smp_read_barrier_depends();
> - if (area)
> - trampoline_vaddr = area->vaddr;
> + area = READ_ONCE(current->mm->uprobes_state.xol_area);
> + if (area) {
> + smp_read_barrier_depends();
> + trampoline_vaddr = READ_ONCE(area->vaddr);
> + }
>
> return trampoline_vaddr;
> }
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] events/uprobes: move smp_read_barrier_depends() where needed
2016-06-10 7:03 ` Oleg Nesterov
@ 2016-06-10 12:26 ` Oleg Nesterov
[not found] ` <CAPZ9YJY_6mB797YRG4=byTbz6WTH91GZjba9zDQhZ+J0C-khSg@mail.gmail.com>
[not found] ` <CAPZ9YJaxdqpCh9DyD7ubrTEhCL9jEdMzNN6zJHsOPYGN5NNPXg@mail.gmail.com>
1 sibling, 1 reply; 7+ messages in thread
From: Oleg Nesterov @ 2016-06-10 12:26 UTC (permalink / raw)
To: Andrea Parri; +Cc: Peter Zijlstra, LKML
On 06/10, Oleg Nesterov wrote:
>
> On 06/09, Andrea Parri wrote:
> >
> > There is no need to use the barrier if there is no dereference/
> > memory access; move it where needed (currently, affecting only
> > Alpha).
>
> OK, although area == NULL is unlikely case,
>
> > While touching this, also make the reads _ONCE().
>
> Why? both xol_area/vaddr can't change.
and perhaps it would be better to eliminate this smp_read_barrier_depends()
altogether, we have a lot of helpers. I mean,
static unsigned long get_trampoline_vaddr(void)
{
struct xol_area *area;
area = lockless_dereference(current->mm->uprobes_state.xol_area);
if (area)
return area->vaddr;
return -1;
}
looks a bit more simple/clean. Note also another smp_read_barrier_depends()
in get_xol_area() which can be changed the same way.
What do you think?
Oleg.
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CAPZ9YJaxdqpCh9DyD7ubrTEhCL9jEdMzNN6zJHsOPYGN5NNPXg@mail.gmail.com>]
* Re: [PATCH] events/uprobes: move smp_read_barrier_depends() where needed
[not found] ` <CAPZ9YJaxdqpCh9DyD7ubrTEhCL9jEdMzNN6zJHsOPYGN5NNPXg@mail.gmail.com>
@ 2016-06-10 12:59 ` Oleg Nesterov
0 siblings, 0 replies; 7+ messages in thread
From: Oleg Nesterov @ 2016-06-10 12:59 UTC (permalink / raw)
To: Andrea Parri; +Cc: Peter Zijlstra, LKML
On 06/10, Andrea Parri wrote:
>
> On Fri, Jun 10, 2016 at 9:03 AM, Oleg Nesterov <oleg@redhat.com> wrote:
>
> > On 06/09, Andrea Parri wrote:
> > >
> > > There is no need to use the barrier if there is no dereference/
> > > memory access; move it where needed (currently, affecting only
> > > Alpha).
> >
> > OK, although area == NULL is unlikely case,
> >
> > > While touching this, also make the reads _ONCE().
> >
> > Why? both xol_area/vaddr can't change.
> >
>
> This is to ensure current (and future) compiler transformations
> won't optimize out or reorder the reads (do not ask me how ...,
> IAC the volatile casts will prevent this to happen).
>
> AFAICT, xol_area can be "== NULL" and "!= NULL" ...
Yes, but it can't change if it is not NULL. So we do not care if gcc
reads xol_area/vaddr twice or reorderes this with other LOADs.
Oleg.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-06-10 19:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-09 18:18 [PATCH] events/uprobes: move smp_read_barrier_depends() where needed Andrea Parri
2016-06-10 7:03 ` Oleg Nesterov
2016-06-10 12:26 ` Oleg Nesterov
[not found] ` <CAPZ9YJY_6mB797YRG4=byTbz6WTH91GZjba9zDQhZ+J0C-khSg@mail.gmail.com>
2016-06-10 13:07 ` Oleg Nesterov
2016-06-10 14:39 ` Oleg Nesterov
[not found] ` <CAPZ9YJYPynX2vGgFarhiyUN0GF--h6r2kbhJ4pRt2NMY1qCODg@mail.gmail.com>
2016-06-10 19:36 ` Oleg Nesterov
[not found] ` <CAPZ9YJaxdqpCh9DyD7ubrTEhCL9jEdMzNN6zJHsOPYGN5NNPXg@mail.gmail.com>
2016-06-10 12:59 ` Oleg Nesterov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.