Re: [PATCH] trace: Check for waiting readers before callingwakeup()

From: Steven Rostedt
Date: Thu May 05 2011 - 08:39:18 EST


On Wed, 2011-05-04 at 20:53 -0700, Linus Torvalds wrote:

> I dunno. It's sometimes safe, but it's equally often not safe unless
> there is some other locking around the thing. So I'd be a bit nervous.
> The tracer people would need to do some serious thinking about it.

The problem with tracing is that it can be very intrusive. We want the
data but we also do not want to affect the system either. We are
constantly fighting with Heissenberg on this.

Perhaps we could do what perf currently does and use irq_work() instead.
This should be lighter weight. The wakeup should not be at the tracing
event itself as the wakeup is too invasive.

Maybe we could use bitmasks in this case, but I would also hate to use
memory barriers here, although a memory barrier might be much lighter
weight than spinlocks that we currently are fighting with.

If irq_work() doesn't work, perhaps just have something like:

event() {
write_data();
smp_mb();
if (test_and_clear_bit())
wakeup();
}

reader() {
set_bit();
smp_mb();
if (data_empty())
schedule();
clear_bit();
smp_mb();
wake_up_other_readers_if_needed()
}

This is probably better than a spinlock.

-- Steve


--
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/