Skip to contentSkip to conversation

mm: why vfree() do not free page table memory?

RFC Xishi Qiu 3 participants 6 messages Dec 29, 2017 – Jan 17, 2018 Memory management

lore
Share & tools
lore

Xishi Qiu

author
#0 lore raw

When calling vfree(), it calls unmap_vmap_area() to clear page table, but do not free the memory of page table, why? just for performance?

If a driver use vmalloc() and vfree() frequently, we will lost much page table memory, maybe oom later.

Thanks,
Xishi Qiu

author
#1 lore raw
Quoted 9 lines · Xishi Qiu

When calling vfree(), it calls unmap_vmap_area() to clear page table, but do not free the memory of page table, why? just for performance?

If a driver use vmalloc() and vfree() frequently, we will lost much page table memory, maybe oom later.

Thanks,
Xishi Qiu

ping

Quoted 3 lines

.

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
In reply to Xishi Qiu
Quoted 2 lines · Xishi Qiu

When calling vfree(), it calls unmap_vmap_area() to clear page table, but do not free the memory of page table, why? just for performance?

I guess it's expected that the free virtual range and associated page tables it might be reused later.

Quoted 2 lines

If a driver use vmalloc() and vfree() frequently, we will lost much page table memory, maybe oom later.

If it's reused, then not really.

Did you notice an actual issue, or is this just theoretical concern.

Quoted 3 lines

Thanks,
Xishi Qiu

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#3 lore raw
Quoted 7 lines · Vlastimil Babka
Quoted 2 lines · Xishi Qiu

When calling vfree(), it calls unmap_vmap_area() to clear page table, but do not free the memory of page table, why? just for performance?

I guess it's expected that the free virtual range and associated page tables it might be reused later.

Hi Vlastimil,

If use vmalloc/vfree different size, then there will be some hols during VMALLOC_START to VMALLOC_END, and this holes takes page table memory, right?

Quoted 7 lines
Quoted 2 lines

If a driver use vmalloc() and vfree() frequently, we will lost much page table memory, maybe oom later.

If it's reused, then not really.

Did you notice an actual issue, or is this just theoretical concern.

Yes, we have this problem on our production line.
I find the page table memory takes 200-300M.

Thanks,
Xishi Qiu

Quoted 7 lines
Quoted 3 lines

Thanks,
Xishi Qiu

.

#4 lore raw
Quoted 6 lines · Xishi Qiu
Quoted 4 lines · Vlastimil Babka
Quoted 2 lines · Xishi Qiu

When calling vfree(), it calls unmap_vmap_area() to clear page table, but do not free the memory of page table, why? just for performance?

Quoted 8 lines
Quoted 3 lines

I guess it's expected that the free virtual range and associated page tables it might be reused later.

Hi Vlastimil,

If use vmalloc/vfree different size, then there will be some hols during VMALLOC_START to VMALLOC_END, and this holes takes page table memory, right?

Possibly. But to free a page table page, there has to be contiguous aligned 2MB hole.

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

If a driver use vmalloc() and vfree() frequently, we will lost much page table memory, maybe oom later.

If it's reused, then not really.

Did you notice an actual issue, or is this just theoretical concern.

Yes, we have this problem on our production line.
I find the page table memory takes 200-300M.

Well, can you verify that it's really due to vmalloc holes? And that the holes are there because of an unfortunate sequence of vmalloc/vfree, and not due to some bug in vmalloc failing to reuse freed areas properly? And do the holes contain enough 2MB aligned ranges to make it possible to free the page tables?

Vlastimil

Quoted 13 lines

Thanks,
Xishi Qiu

Quoted 7 lines
Quoted 3 lines

Thanks,
Xishi Qiu

.

#5 lore raw
In reply to Xishi Qiu
Quoted 4 lines · Xishi Qiu
Quoted 1 line

Did you notice an actual issue, or is this just theoretical concern.

Yes, we have this problem on our production line.
I find the page table memory takes 200-300M.

200MB? That's mapping 800GB of virtual address space. That must be quite the module you're loading there ...

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>