Thread (140 messages) 140 messages, 21 authors, 2018-12-04

Re: [PATCH 08/17] prmem: struct page: track vmap_area

From: Igor Stoppa <hidden>
Date: 2018-10-29 18:21:25
Also in: linux-integrity, linux-mm, lkml

On 25/10/2018 03:13, Matthew Wilcox wrote:
On Thu, Oct 25, 2018 at 02:01:02AM +0300, Igor Stoppa wrote:
quoted
quoted
quoted
@@ -1747,6 +1750,10 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
   	if (!addr)
   		return NULL;
+	va = __find_vmap_area((unsigned long)addr);
+	for (i = 0; i < va->vm->nr_pages; i++)
+		va->vm->pages[i]->area = va;
I don't like it that you're calling this for _every_ vmalloc() caller
when most of them will never use this.  Perhaps have page->va be initially
NULL and then cache the lookup in it when it's accessed for the first time.
If __find_vmap_area() was part of the API, this loop could be left out from
__vmalloc_node_range() and the user of the allocation could initialize the
field, if needed.

What is the reason for keeping __find_vmap_area() private?
Well, for one, you're walking the rbtree without holding the spinlock,
so you're going to get crashes.  I don't see why we shouldn't export
find_vmap_area() though.
Argh, yes, sorry. But find_vmap_area() would be enough for what I need.
Another way we could approach this is to embed the vmap_area in the
vm_struct.  It'd require a bit of juggling of the alloc/free paths in
vmalloc, but it might be worthwhile.
I have a feeling of unease about the whole vmap_area / vm_struct 
duality. They clearly are different types, with different purposes, but 
here and there there are functions that are named after some "area", yet 
they actually refer to vm_struct pointers.

I wouldn't mind spending some time understanding the reason for this 
apparently bizarre choice, but after I have emerged from the prmem swamp.

For now I'd stick to find_vmap_area().

--
igor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help