Skip to contentSkip to conversation

flush_tlb_all in vmalloc_area_pages

PATCH Andrea Arcangeli 2 participants 6 messages Sep 7, 2001 – Sep 20, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

can somebody see a good reason for flushing the tlb in vmalloc? We must do that in vfree but doing it in vmalloc is just a waste of time, we are guaranteed that's an unmapped space before we start setting up the pagetables so such address space cannot be cached in any tlb in first place.

For the flush_cache_all for the virtually indexed caches should be the same issue in theory (at least the kmap logic only needs to flush the caches before the unmapping [not before the mapping] too)

Am I missing something, Dave?

mm/vmalloc.c renamed from mm/vmalloc.c.~1~ +0 -2
@@ -144,7 +144,6 @@
 	int ret;
 
 	dir = pgd_offset_k(address);
-	flush_cache_all();
 	spin_lock(&init_mm.page_table_lock);
 	do {
 		pmd_t *pmd;
@@ -164,7 +163,6 @@
 		ret = 0;
 	} while (address && (address < end));
 	spin_unlock(&init_mm.page_table_lock);
-	flush_tlb_all();
 	return ret;
 }
 

Andrea

#1 lore raw

From: Andrea Arcangeli <[email protected]>
Date: Fri, 7 Sep 2001 16:56:12 +0200

For the flush_cache_all for the virtually indexed caches should be the same issue in theory (at least the kmap logic only needs to flush the caches before the unmapping [not before the mapping] too)

Am I missing something, Dave?

Anything that creates or takes away vmalloc() mappings needs to flush the data cache if it is virtuall indexed.

I am always uncomfortable when I see people suggesting to remove flushes from kernel virtual mapping setup/teardown.

Later,
David S. Miller
[email protected]

#2 lore raw
In reply to Andrea Arcangeli
Quoted 11 lines · David S. Miller

From: Andrea Arcangeli <[email protected]>
Date: Fri, 7 Sep 2001 16:56:12 +0200

For the flush_cache_all for the virtually indexed caches should be the same issue in theory (at least the kmap logic only needs to flush the caches before the unmapping [not before the mapping] too)

Am I missing something, Dave?

Anything that creates or takes away vmalloc() mappings needs to flush the data cache if it is virtuall indexed.

The only question I'd like to get a answer is "what is actually the data that can be virtually indexed) in the vmalloc range at the time we run vmalloc?" Where does it cames from?

If there is no such data (as I think), we obviously don't need to flush the virtually indexed caches at vmalloc time (but just at vfree).

Furthmore I recall on sparc you cannot flush the cache if you don't have a mapping in place, and when you run vmalloc there should be no mapping in place for the region of cache that you're trying to flush (or we wouldn't trap the invalid faults there).

If anybody is using at boot time the vmalloc range for whatever purpuse it should be its own business to flush the cache before dropping the mappings from there.

Andrea

#3 lore raw

From: Andrea Arcangeli <[email protected]>
Date: Fri, 21 Sep 2001 00:25:47 +0200

The only question I'd like to get a answer is "what is actually the data that can be virtually indexed) in the vmalloc range at the time we run vmalloc?" Where does it cames from?

Quoted 1 line

From the the direct PAGE_OFFSET mappings.

Furthmore I recall on sparc you cannot flush the cache if you don't have a mapping in place,

This is only true of Hypersparc sparc32 chips for page based flushes, not whole flushes.

If anybody is using at boot time the vmalloc range for whatever purpuse it should be its own business to flush the cache before dropping the mappings from there.

That isn't the problem, it's dirty cache lines left over from the usual access addresses for physical memory (ie. via PAGE_OFFSET linear mappings).

Please, I would heavily suggest leaving this area until 2.5.x there are already a traumatic amount of changes going on in 2.4.x

Later,
David S. Miller
[email protected]

#5 lore raw
In reply to Andrea Arcangeli
Quoted 4 lines · Andrea Arcangeli
Quoted 1 line · David S. Miller

Please, I would heavily suggest leaving this area until 2.5.x there

ok

Linus please apply to next pre patch, I understood from David that for him the direct mapping can overlap the vmalloc virtual address space, it really doesn't make much sense to me but since this is a noop for me and I trust him, we can really delay this to 2.5:

mm/vmalloc.c renamed from mm/vmalloc.c.~1~ +1 -0
@@ -144,6 +144,7 @@
 	int ret;
 
 	dir = pgd_offset_k(address);
+	flush_cache_all();
 	spin_lock(&init_mm.page_table_lock);
 	do {
 		pmd_t *pmd;

And btw, now I suspect David can have also have an arguments for the tlb_flush removal (infact the problem is the same, if the address space is shared by direct mapping and vmalloc we'd also need to flush the tlb), but such one isn't really a noop for the other archs so I will be more concerned not to reintroduce it and to at least just put an #ifndef __i386__ around it (safe for both parts).

Andrea