Re: Buffer allocation question
From: Clemens Ladisch
Date: Tue Sep 14 2010 - 02:52:51 EST
Ian Molton wrote:
> I need to allocate some fairly large buffers which will be transferred
> via virtio to a hypervisor.
>
> the pages dont have to be contiguous physically and aside from the first
> page int he transfer, the kernel wont really care about the contents of
> the buffer.
>
> the pages do need to be mapped into userspace contiguously, however.
See drivers/firewire/core-iso.c, which uses fixed-size buffers.
> They are also often dynamically resized.
> ...
> my first thought (before realising how limited vmalloc space is) was to
> vmalloc() them in my mmap() function, but this approach ran into trouble
> when I discovered that the mmap() call does not get called if the vma
> grows, so I cant then hook in and allocate more vmalloc() space.
You can set vma->vm_ops.
> the buffers will usually be filled all in one go, so it seems silly to
> fault them in a page at a time.
AFAICS you don't have a choice when resizing.
Regards,
Clemens
--
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/