Canonical ring-buffer code : SMP, single-reader/writer

From: Tom Brown
Date: Sun Oct 17 2010 - 17:50:36 EST


Does anyone happen to know of any good example code that I could use in a driver for a simple single-reader, single-writer, ring buffer, on an SMP system?

My own code doesn't use any locks, but I'm concerned that it may be flaky. It's running on an 8-core processor, and I'm worried that I may be seeing SMP locking issues which I don't understand because the driver is on one core, while the user is on another core.

In my case, the producer is the driver, and the consumer is the user. I could just lock all the driver writes to the buffer and the driver's update of the shared 'last written' pointer, but that seems a really poor design.

Thanks -

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