Should I use kmap or kmap_atomic to map user pages that will be written in a loop ?



Hi everybody,

I'm trying to implement the USERPTR V4L2 streaming I/O method in the uvcvideo
driver. In a nutshell, that methods uses userspace-allocated buffers to
transfer video data from kernelspace to userspace. The buffers are reused
during the whole video stream in a circular fashion.

The kernel driver receives userspace pointers to those buffers, which can have
been allocated using different methods (malloc, Xv alloc, mmap() on a reserved
memory region, ...). I get the list of underlying pages using
get_user_pages(), and I then need to map those pages to the kernel virtual
address space.

Pages will be written to from the kernel in USB interrupt context. I can then
either kmap_atomic() pages before copying data and kunmap_atomic() them right
after, or kmap() them once at the beginning of the video stream and keep them
mapped until the end.

As I don't have much experience with the memory management subsystem, I'd
appreciate if someone could give me a few advices regarding the best way to
proceed. kmap() is expensive, but it would only be called once, while
kmap_atomic() would be called many times (4500 times per second for a 640x480
30fps video stream). On the other hand, I'm not sure how much pressure keeping
all those kmap() pages mapped into kernel virtual memory for a long time would
put on the memory subsystem.

Please CC me on answers.

Regards,

Laurent Pinchart

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



Relevant Pages

  • Re: Live event streaming hangs and delays - increasing WMS buffers
    ... You'll need to do some digging to find out why the stream going to WMS is ... Indeed the buffering happens on the server too, ... Any idea what can be done to improve the streaming and prevent these buffers ... video over slow line. ...
    (microsoft.public.windowsmedia.sdk)
  • 2.6.38-rc2+ - regresiion copying DVDs
    ... I'm trying to copy the3 contents of a video DVD from one disc to another, ... There are no messages in the kernel log file, ... Overwrite, Layer Jump, Random Recording, Sequential Recording, Sequential ... # Infrared-port device drivers ...
    (Linux-Kernel)
  • tsc problems in 2.6.0-test11
    ... I'm not using speedstep or any voltage altering cpu code in the kernel. ... Using tsc for high-res timesource ... Doing some strenuous video ... # ACPI Support ...
    (Linux-Kernel)
  • Re: VMR Mixing Mode and Seeking Problem
    ... decoder's output pin, and called SetStreamActiveState*before* ... passing BeginFlush downstream to the VMR. ... the VMR connected to the 2nd video stream has ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Digital Signage, Multimedia Steaming etc.
    ... A full featured video editing software is a major undertaking imo. ... However if you need to stream different video streams to each client, ... simultanious clients is no small task. ... 4.There will be 5-10 distribution servers. ...
    (borland.public.delphi.thirdpartytools.general)