[linux-dvb] [PATCH] 2/3: implement DMX_SET_BUFFER_SIZE for dvr
Andrea
mariofutire at googlemail.com
Mon Mar 24 21:49:11 CET 2008
linux-dvb-request at linuxtv.org wrote:
> What about this fragment:
> ...
> if (!size)
> return -EINVAL;
>
> mem = vmalloc(size);
> if (!mem)
> return -ENOMEM;
>
> mem2 = buf->data;
>
> spin_lock_irqsave(&dmxdev->lock);
> buf->pread = buf->pwrite = 0;
> buf->data = mem;
> buf->size = size;
> spin_unlock_irqrestore(&dmxdev->lock);
>
> vfree(mem2);
> return 0;
Maybe I can think of one reason while the current code is not implemented this way:
In your version the new buffer is allocated before the old one is released.
In the current implementation the old buffer is released and afterwards the new one allocated.
One could argue that the new implementation has a maximum memory requirement higher than the old one.
It's not much but I am not too familiar with kernel development, so I don't know how important that
could be.
What do you think?
About the spin_lock_irqsave: currently it is not used anywhere in the code for the demux in dmxdev.c.
I am always a bit scared when I introduce something new, maybe I am missing the current logic.
Cheers
Andrea
More information about the linux-dvb
mailing list