public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Erich Focht <efocht@ess.nec.de>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] switch_mm race condition with Ingo's scheduler
Date: Wed, 10 Jul 2002 17:27:20 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590701905759@msgid-missing> (raw)

[-- Attachment #1: Type: text/plain, Size: 175 bytes --]

Hi David,

the attached patch fixes the switch_mm -> wrap_mmu_context deadlock which
can occur in 2.5.18+ia64. We discussed this in January/February...

Regards,
Erich

[-- Attachment #2: wrap_mmu_ia64.patch --]
[-- Type: text/x-diff, Size: 2457 bytes --]

diff -urNp linux-2.5.18-ia64/arch/ia64/mm/tlb.c linux-2.5.18-ia64-wrap/arch/ia64/mm/tlb.c
--- linux-2.5.18-ia64/arch/ia64/mm/tlb.c	Sat May 25 03:55:29 2002
+++ linux-2.5.18-ia64-wrap/arch/ia64/mm/tlb.c	Wed Jul 10 17:08:46 2002
@@ -77,7 +77,11 @@ wrap_mmu_context (struct mm_struct *mm)
 			ia64_ctx.limit = tsk_context;
 	}
 	read_unlock(&tasklist_lock);
-	flush_tlb_all();
+	//flush_tlb_all(); /* potential race condition with O(1) scheduler [EF] */
+	for (i=0; i<smp_num_cpus; i++)
+		cpu_data(i)->tlb_flush = 1;
+	__flush_tlb_all();
+	local_cpu_data->tlb_flush = 0;
 }
 
 void
diff -urNp linux-2.5.18-ia64/include/asm-ia64/mmu_context.h linux-2.5.18-ia64-wrap/include/asm-ia64/mmu_context.h
--- linux-2.5.18-ia64/include/asm-ia64/mmu_context.h	Sat May 25 03:55:19 2002
+++ linux-2.5.18-ia64-wrap/include/asm-ia64/mmu_context.h	Wed Jul 10 17:03:03 2002
@@ -44,6 +44,23 @@ enter_lazy_tlb (struct mm_struct *mm, st
 {
 }
 
+/* 
+ * When the context counter wraps around all TLBs need to be flushed because
+ * an old context number might have been reused. This is signalled by a bit
+ * set in ia64_ctx.flush, which is checked in the routine below. Called by
+ * activate_mm().                                        <efocht@ess.nec.de>
+ */
+static inline void
+delayed_tlb_flush (void)
+{
+	extern void __flush_tlb_all (void);
+
+	if (unlikely(local_cpu_data->tlb_flush)) {
+		__flush_tlb_all();
+		local_cpu_data->tlb_flush = 0;
+	}
+}
+
 static inline void
 get_new_mmu_context (struct mm_struct *mm)
 {
@@ -54,7 +71,6 @@ get_new_mmu_context (struct mm_struct *m
 		mm->context = ia64_ctx.next++;
 	}
 	spin_unlock(&ia64_ctx.lock);
-
 }
 
 static inline void
@@ -113,6 +129,7 @@ activate_mm (struct mm_struct *prev, str
 	 * We may get interrupts here, but that's OK because interrupt
 	 * handlers cannot touch user-space.
 	 */
+	delayed_tlb_flush();
 	ia64_set_kr(IA64_KR_PT_BASE, __pa(next->pgd));
 	get_mmu_context(next);
 	reload_context(next);
diff -urNp linux-2.5.18-ia64/include/asm-ia64/processor.h linux-2.5.18-ia64-wrap/include/asm-ia64/processor.h
--- linux-2.5.18-ia64/include/asm-ia64/processor.h	Thu Jul  4 12:23:26 2002
+++ linux-2.5.18-ia64-wrap/include/asm-ia64/processor.h	Wed Jul 10 17:05:20 2002
@@ -151,6 +151,7 @@ extern struct cpuinfo_ia64 {
 	/* CPUID-derived information: */
 	__u64 ppn;
 	__u64 features;
+	__u8 tlb_flush;		/* flush TLB before next context switch if non-zero */
 	__u8 number;
 	__u8 revision;
 	__u8 model;

             reply	other threads:[~2002-07-10 17:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-10 17:27 Erich Focht [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-01-30 16:58 [Linux-ia64] switch_mm race condition with Ingo's scheduler Erich Focht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-105590701905759@msgid-missing \
    --to=efocht@ess.nec.de \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox