Skip to contentSkip to conversation

[[email protected]: Re: TLB flushing in 2.4.14]

[email protected]: Re: TLB flushing in 2.4.14 Benjamin LaHaise 1 participant 1 message Dec 7, 2001

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

Hey folks,

I'm just going through my backlog, and this patch looks reasonable to me. Linus, could you drop this into 2.5?

-ben

----- Forwarded message from Jack Steiner <[email protected]> -----

From: Jack Steiner <[email protected]>
Subject: Re: TLB flushing in 2.4.14
To: [email protected] (Benjamin LaHaise)
Date: Wed, 28 Nov 2001 14:01:14 -0600 (CST)
In-Reply-To: <[email protected]> from "Benjamin LaHaise" at Nov 27, 2001 01:25:19 PM
X-Mailer: ELM [version 2.5 PL2]

Quoted 9 lines · Jack Steiner
Quoted 3 lines

Do you see any problems with this patch??

(I also sent a copy of this to Andrea Arcangeli)

Yes. Your system will now happily corrupt memory if you run ps or top at the right time. I'd suggested adding an mm->dead flag and using that instead, but Linus is the keeper of the vm code, so run it by him.

You are right, of course. I should have studied the code better.

Here is a much cleaner fix (ignore the previous patch completely). This keeps all the changes in just one spot - no changes to fs/exec.c.

Do you see any problems here...

include/asm-generic/tlb.h +5 -2
@@ -43,7 +43,7 @@
 
 	tlb->mm = mm;
 	/* Use fast mode if there is only one user of this mm (this process) */
-	tlb->nr = (atomic_read(&(mm)->mm_users) == 1) ? ~0UL : 0UL;
+	tlb->nr = (atomic_read(&(mm)->mm_users) <= 1) ? ~0UL : 0UL;
 	return tlb;
 }
 
@@ -70,6 +70,8 @@
 /* tlb_finish_mmu
  *	Called at the end of the shootdown operation to free up any resources
  *	that were required.  The page talbe lock is still held at this point.
+ *	Note that no TLB flushes are needed if there are no users of the mm
+ *	context.
  */
 static inline void tlb_finish_mmu(struct free_pte_ctx *ctx, unsigned long start, unsigned long end)
 {
@@ -77,7 +79,8 @@
 
 	/* Handle the fast case first. */
 	if (ctx->nr == ~0UL) {
-		flush_tlb_range(ctx->mm, start, end);
+		if (ctx->mm->mmap)
+			flush_tlb_range(ctx->mm, start, end);
 		return;
 	}
 	nr = ctx->nr;
Signature · 12 lines
Thanks

Jack Steiner    (651-683-5302)   (vnet 233-5302)      [email protected]

----- End forwarded message -----

-- 
Fish.
--
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/