[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <OFD776C320.26C485FF-ON43257C0D.00264F32-43257C0D.002A1BA7@il.ibm.com>
Date: Wed, 23 Oct 2013 10:39:55 +0300
From: Victor Kaplansky <VICTORK@...ibm.com>
To: Michael Neuling <mikey@...ling.org>
Cc: anton@...ba.org, benh@...nel.crashing.org,
Frederic Weisbecker <fweisbec@...il.com>,
linux-kernel@...r.kernel.org,
Linux PPC dev <linuxppc-dev@...abs.org>,
Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>,
michael@...erman.id.au
Subject: Re: perf events ring buffer memory barrier on powerpc
See below.
Michael Neuling <mikey@...ling.org> wrote on 10/23/2013 02:54:54 AM:
>
> diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
> index cd55144..95768c6 100644
> --- a/kernel/events/ring_buffer.c
> +++ b/kernel/events/ring_buffer.c
> @@ -87,10 +87,10 @@ again:
> goto out;
>
> /*
> - * Publish the known good head. Rely on the full barrier implied
> - * by atomic_dec_and_test() order the rb->head read and this
> - * write.
> + * Publish the known good head. We need a memory barrier to order the
> + * order the rb->head read and this write.
> */
> + smp_mb ();
> rb->user_page->data_head = head;
>
> /*
1. As far as I understand, smp_mb() is superfluous in this case, smp_wmb()
should be enough.
(same for the space between the name of function and open
parenthesis :-) )
2. Again, as far as I understand from ./Documentation/atomic_ops.txt, it is
mistake in architecture independent
code to rely on memory barriers in atomic operations, all the more so in
"local" operations.
3. The solution above is sub-optimal on architectures where memory barrier
is part of "local", since we are going to execute
two consecutive barriers. So, maybe, it would be better to use
smp_mb__after_atomic_dec().
4. I'm not sure, but I think there is another, unrelated potential problem
in function perf_output_put_handle()
- the write to "data_head" -
kernel/events/ring_buffer.c:
77 /*
78 * Publish the known good head. Rely on the full barrier
implied
79 * by atomic_dec_and_test() order the rb->head read and this
80 * write.
81 */
82 rb->user_page->data_head = head;
As data_head is 64-bit wide, the update should be done by an atomic64_set
().
Regards,
-- Victor
--
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