Skip to contentSkip to conversation

kmap_kiobuf()

DISCUSSION David Woodhouse 2 participants 3 messages Jun 28, 2000 – Jun 29, 2000 Memory management

lore
Share & tools
lore
#0 lore raw

I think it would be useful to provide a function which can be used to obtain a virtually-contiguous VM mapping of the pages of an iobuf.

Currently, to access the pages of an iobuf, you have to kmap() each page individually. For various purposes, it would be useful to be able to kmap the whole iobuf contiguously, so that you can guarantee that:

	page_address(iobuf->maplist[n]) + PAGE_SIZE 
		== page_address(iobuf->maplist[n+1])

    (for n such that n < iobuf->nr_pages, obviously. Don't be so pedantic.)

Rather than taking a kiobuf as an argument, the new function might as well be more generic:

unsigned long kremap_pages(struct page **maplist, int nr_pages); void kunmap_pages(struct page **maplist, int nr_pages);

I had a quick look at the code for kmap() and vmalloc() and decided that even if I attempted to do it myself, I'd probably bugger it up and a MM hacker would have to fix it anyway. So I'm not going to bother.

T'would be useful if someone else could find the time to do so, though.

--
dwmw2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

#1 lore raw

Hi,

Quoted 2 lines · David Woodhouse

I think it would be useful to provide a function which can be used to obtain a virtually-contiguous VM mapping of the pages of an iobuf.

Why? This is not as straightforward as it seems, so I'm curious as to the intended use.

Quoted 6 lines

Currently, to access the pages of an iobuf, you have to kmap() each page individually. For various purposes, it would be useful to be able to kmap the whole iobuf contiguously, so that you can guarantee that:

	page_address(iobuf->maplist[n]) + PAGE_SIZE 
		== page_address(iobuf->maplist[n+1])

For any moderately large sized kiobuf, that just means that we risk running out of kmaps. You need to treat kmaps as a scarce resource; on PAE36-configured machines we only have 512 of them right now.

For user-space access, the current kiobuf patches already have mmap() support for kiobufs so that getting a user-contiguous mapping of kiobufs is already done. That doesn't have the kmap problem, though, since we can map things into user page tables without pinning them in kernel memory.

Cheers,
Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

#2 lore raw
In reply to David Woodhouse

Hi,

Quoted 2 lines · David Woodhouse

I think it would be useful to provide a function which can be used to obtain a virtually-contiguous VM mapping of the pages of an iobuf.

Perhaps, but I really would rather resist this. The whole point of kiobufs is to let you deal cleanly with thinks which are unaligned by doing page lookups. They are specifically intended to _avoid_ nasty VM tricks.

Adding kiobuf support for things like memcpy_to/from_kiobuf is something I will do, but kiobufs are there to help get people out of the mindset that all buffers are virtually contiguous in the first place!

It would be fairly easy to add kiobuf support for this, but it would make it harder to get the diffs past Linus (who really wants vmalloc to go away as much as possible).

I'm open to arguments, but "I coded this way in the past and I'd rather the kernel did ugly things to let me keep coding this way in the future" isn't the sort of reasoning that helps me to get new functionality past Linus's sanity filters. :-)

Cheers,
Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/