Re: [PATCH] LDT - Linux Driver Template

From: Constantine Shulyupin
Date: Wed Nov 14 2012 - 08:04:32 EST


On Wed, Nov 14, 2012 at 5:42 AM, Ryan Mallon <rmallon@xxxxxxxxx> wrote:
> On 14/11/12 05:46, Constantine Shulyupin wrote:
>> From: Constantine Shulyupin <const@xxxxxxxxxxxxx>
>> + if (kfifo_is_empty(&in_fifo)) {
>
> Doesn't this require locking against whatever is filling the fifo?
I seems doesn't.
Note from include/linux/kfifo.h
/*
* Note about locking : There is no locking required until only * one reader
* and one writer is using the fifo and no kfifo_reset() will be * called
* kfifo_reset_out() can be safely used, until it will be only called
* in the reader thread.
* For multiple writer and one reader there is only a need to lock the writer.
* And vice versa for only one writer and multiple reader there is only a need
* to lock the reader.
*/

>> + if (mutex_lock_interruptible(&read_lock)) {
> The read_lock is only used here, so would only protect against
> concurrent reads. Isn't the read for a device function already
> synchronised against itself by the caller?
I can't find locking for read/write in sys_read, vfs_read
I just found lock misc_mtx for misc_open, misc_register.

>> + ret = kfifo_from_user(&out_fifo, buf, count, &copied);
> Shouldn't this function be grabbing fifo_lock to prevent concurrent
> access to the fifo by the tasklet function? write_lock has the same
> issues described for read_lock above.

Accordingly note about kfifo locking is shouldn't.
kfifo supports asynchronous i/o.

Thank you.
--
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/