2000-11-22 12:00:53

by Tigran Aivazian

[permalink] [raw]
Subject: vfree() question.

Hi,

In vfree() shouldn't we be dropping vmlist_lock spinlock as soon as we
unlinked the item from the vmlist? I.e. before we free the actual pages
and the vm_struct itself. Or, perhaps it should be done _after_
vmfree_area_pages() but definitely before kfree(tmp) since tmp is no
longer visible outside the function. (My only doubt whether
vmfree_area_pages() should be inside the lock is because those pages may
otherwise be reused for the next vmalloc request).

(actually I put that spinlock in vfree and get_vm_area so at the time it
seemed "obviously correct" but now I am having thoughts that it can still
be optimized more).

Regards,
Tigran

PS. To be specific, here is the patch I had in mind:

--- linux/mm/vmalloc.c Mon Nov 20 11:56:14 2000
+++ work/mm/vmalloc.c Wed Nov 22 11:25:29 2000
@@ -214,9 +214,9 @@
for (p = &vmlist ; (tmp = *p) ; p = &tmp->next) {
if (tmp->addr == addr) {
*p = tmp->next;
+ write_unlock(&vmlist_lock);
vmfree_area_pages(VMALLOC_VMADDR(tmp->addr), tmp->size);
kfree(tmp);
- write_unlock(&vmlist_lock);
return;
}
}