Re: [PATCH 03/11] unpaged: sound nopage get_page

From: David S. Miller
Date: Thu Nov 17 2005 - 18:42:02 EST


From: Hugh Dickins <hugh@xxxxxxxxxxx>
Date: Thu, 17 Nov 2005 19:31:36 +0000 (GMT)

> Something noticed when studying use of VM_RESERVED in different drivers:
> snd_usX2Y_hwdep_pcm_vm_nopage omitted to get_page: fixed.
>
> And how did this work before? Aargh! That nopage is returning a page
> from within a buffer allocated by snd_malloc_pages, which allocates a
> high-order page, then does SetPageReserved on each 0-order page within.
>
> That would have worked in 2.6.14, because when the area was unmapped,
> PageReserved inhibited put_page. 2.6.15-rc1 removed that inhibition
> (while leaving ineffective PageReserveds around for now), but it hasn't
> caused trouble because.. we've not been freeing from VM_RESERVED at all.
>
> Signed-off-by: Hugh Dickins <hugh@xxxxxxxxxxx>

There is probably a lot of other grot like this in various drivers.

The amazing thing about this is that all of these drivers getting
snuffed up by VM_RESERVED issues are trying to do essentially the
same thing. They want to allocate some buffers, which the device
can DMA into and out of, and mmap() those buffers into user space
in some sane way.

The video capture driver layer drivers/media/video/video-buf.c is
probably the best known example, and all the other copies in the
tree of this logic is some derivative.

Note also that the AF_PACKET mmap() facility (in
net/packet/af_packet.c) does this VM_RESERVED stuff, but I think since
it never does the get_user_pages() bit like the video capture drivers
do, it didn't trigger any of the new messages or BUG() traps.

I say "I think" because I haven't tested this stuff out specifically.
-
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/