Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeremy Fitzhardinge
Date: Tuesday, November 30, 2010 - 10:45 am

On 11/30/2010 04:42 AM, Nick Piggin wrote:

Perhaps.  But perhaps there are cache benefits in clearing early because
the ptes are still in cache from when they were set?

I thought I'd avoided that.  Oh, right, in both vb_free(), and again -
eventually - in free_vmap_block->free_unmap_vmap_area_noflush.

Delta patch below.


I'd rather not unless there's a strong reason to do so.

It occurs to me that once you remove the lazily mapped ptes, then all
that code is doing is keeping track of ranges of addresses with dirty
tlb entries.  But on x86 at least, any kernel tlb flush is a global one,
so keeping track of fine-grain address information is overkill.  I
wonder if the overall code can be simplified as a result?

On a more concrete level, vmap_page_range_noflush() and
vunmap_page_range() could be implemented with apply_to_page_range()
which removes a chunk of boilerplate code (however, it would result in a
callback per pte rather than one per pte page - but I'll fix that now).


Yes, it seems to.

Thanks,
    J

Subject: [PATCH] vmalloc: avoid double-unmapping percpu blocks

The area has always been unmapped by the time free_vmap_block() is
called, so there's no need to unmap it again.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 9551316..ade3302 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -520,13 +520,12 @@ static void purge_vmap_area_lazy(void)
 }
 
 /*
- * Free and unmap a vmap area, caller ensuring flush_cache_vunmap had been
- * called for the correct range previously.
+ * Free a vmap area, caller ensuring that the area has been unmapped
+ * and flush_cache_vunmap had been called for the correct range
+ * previously.
  */
-static void free_unmap_vmap_area_noflush(struct vmap_area *va)
+static void free_vmap_area_noflush(struct vmap_area *va)
 {
-	unmap_vmap_area(va);
-
 	va->flags |= VM_LAZY_FREE;
 	atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr);
 	if (unlikely(atomic_read(&vmap_lazy_nr) > lazy_max_pages()))
@@ -534,6 +533,16 @@ static void free_unmap_vmap_area_noflush(struct vmap_area *va)
 }
 
 /*
+ * Free and unmap a vmap area, caller ensuring flush_cache_vunmap had been
+ * called for the correct range previously.
+ */
+static void free_unmap_vmap_area_noflush(struct vmap_area *va)
+{
+	unmap_vmap_area(va);
+	free_vmap_area_noflush(va);
+}
+
+/*
  * Free and unmap a vmap area
  */
 static void free_unmap_vmap_area(struct vmap_area *va)
@@ -709,7 +718,7 @@ static void free_vmap_block(struct vmap_block *vb)
 	spin_unlock(&vmap_block_tree_lock);
 	BUG_ON(tmp != vb);
 
-	free_unmap_vmap_area_noflush(vb->va);
+	free_vmap_area_noflush(vb->va);
 	call_rcu(&vb->rcu_head, rcu_free_vb);
 }
 


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Could we do immediate pte zaps in vunmap?, Jeremy Fitzhardinge, (Fri Nov 26, 1:10 am)
Re: Could we do immediate pte zaps in vunmap?, Nick Piggin, (Sat Nov 27, 3:36 am)
[PATCH RFC] vmalloc: eagerly clear ptes on vunmap, Jeremy Fitzhardinge, (Mon Nov 29, 1:32 pm)
Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap, Nick Piggin, (Tue Nov 30, 5:42 am)
Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap, Jeremy Fitzhardinge, (Tue Nov 30, 10:45 am)
Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap, Andrew Morton, (Tue Nov 30, 5:29 pm)
Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap, Jeremy Fitzhardinge, (Tue Nov 30, 8:09 pm)
Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap, Andrew Morton, (Tue Nov 30, 8:23 pm)
Re: [PATCH RFC] vmalloc: eagerly clear ptes on vunmap, Jeremy Fitzhardinge, (Wed Dec 1, 1:16 am)