Question about smp_read_barrier_depends() in kernel/marker.c

From: Paul E. McKenney
Date: Fri May 30 2008 - 08:22:20 EST


Hello, Mathieu,

I am a bit confused by the smp_read_barrier_depends() in kernel/markers.c.
My (probably naive) view is that they need to move as shown in the patch
below. Help?

Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
---

marker.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff -urpNa -X dontdiff linux-2.6.26-rc4/kernel/marker.c linux-2.6.26-rc4-marker-srbd/kernel/marker.c
--- linux-2.6.26-rc4/kernel/marker.c 2008-05-30 04:39:01.000000000 -0700
+++ linux-2.6.26-rc4-marker-srbd/kernel/marker.c 2008-05-30 05:05:55.000000000 -0700
@@ -133,8 +133,8 @@ void marker_probe_cb(const struct marker
* data. Same as rcu_dereference, but we need a full smp_rmb()
* in the fast path, so put the explicit barrier here.
*/
- smp_read_barrier_depends();
multi = mdata->multi;
+ smp_read_barrier_depends();
for (i = 0; multi[i].func; i++) {
va_start(args, fmt);
multi[i].func(multi[i].probe_private, call_private, fmt,
@@ -183,8 +183,8 @@ void marker_probe_cb_noarg(const struct
* data. Same as rcu_dereference, but we need a full smp_rmb()
* in the fast path, so put the explicit barrier here.
*/
- smp_read_barrier_depends();
multi = mdata->multi;
+ smp_read_barrier_depends();
for (i = 0; multi[i].func; i++)
multi[i].func(multi[i].probe_private, call_private, fmt,
&args);
@@ -271,6 +271,7 @@ marker_entry_add_probe(struct marker_ent
new[nr_probes].func = probe;
new[nr_probes].probe_private = probe_private;
entry->refcount = nr_probes + 1;
+ smp_wmb(); /* Ensure struct is initialized before publication. *
entry->multi = new;
entry->ptype = 1;
debug_print_probes(entry);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/