Skip to contentSkip to conversation

i386 Ldt context inline

PATCH In review Zachary Amsden 3 participants 3 messages Nov 8, 2005 – Nov 10, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 21/21 i386 Ldt context inline

I was also able to get the LDT switching functionality out of the critical path in switch_mm, which reduces the number of function calls, potential TLB misses and code size.

include/asm-i386/desc.h +3 -0
Index: linux-2.6.14-zach-work/include/asm-i386/desc.h
===================================================================
@@ -271,6 +271,9 @@ static inline void restore_bios_segments
 	put_cpu();
 }
 
+extern void destroy_ldt(mm_context_t *pc);
+extern int copy_ldt(mm_context_t *new, mm_context_t *old);
+
 #endif /* !__ASSEMBLY__ */
 
 #endif
include/asm-i386/mmu_context.h +21 -2
Index: linux-2.6.14-zach-work/include/asm-i386/mmu_context.h
===================================================================
@@ -10,9 +10,28 @@
 /*
  * Used for LDT copy/destruction.
  */
-int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
-void destroy_context(struct mm_struct *mm);
+static inline int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
+{
+	struct mm_struct * old_mm;
+	int retval = 0;
+
+	memset(&mm->context, 0, sizeof(mm->context));
+	init_MUTEX(&mm->context.sem);
+	old_mm = current->mm;
+	if (old_mm && unlikely(old_mm->context.ldt)) {
+		retval = copy_ldt(&mm->context, &old_mm->context);
+	}
+	return retval;
+}
 
+/*
+ * No need to lock the MM as we are the last user
+ */
+static inline void destroy_context(struct mm_struct *mm)
+{
+	if (unlikely(mm->context.ldt))
+		destroy_ldt(&mm->context);
+}
 
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
arch/i386/kernel/ldt.c +0 -23
Index: linux-2.6.14-zach-work/arch/i386/kernel/ldt.c
===================================================================
@@ -103,29 +103,6 @@ void destroy_ldt(mm_context_t *pc)
 	pc->ldt = NULL;
 }
 
-int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
-{
-	struct mm_struct * old_mm;
-	int retval = 0;
-
-	memset(&mm->context, 0, sizeof(mm->context));
-	init_MUTEX(&mm->context.sem);
-	old_mm = current->mm;
-	if (old_mm && unlikely(old_mm->context.ldt)) {
-		retval = copy_ldt(&mm->context, &old_mm->context);
-	}
-	return retval;
-}
-
-/*
- * No need to lock the MM as we are the last user
- */
-void destroy_context(struct mm_struct *mm)
-{
-	if (unlikely(mm->context.ldt))
-		destroy_ldt(&mm->context);
-}
-
 static int read_ldt(void __user * ptr, unsigned long bytecount)
 {
 	int err;
#1 lore raw

include/asm-i386/mmu_context.h line 23

Quoted 3 lines · Zachary Amsden
include/asm-i386/mmu_context.h +3 -0
+	if (old_mm && unlikely(old_mm->context.ldt)) {
+		retval = copy_ldt(&mm->context, &old_mm->context);
+	}

style police: remove the { }. You only moved the function, but still :-)

Ingo

#2 lore raw
In reply to Zachary Amsden
Quoted 3 lines · Zachary Amsden

I was also able to get the LDT switching functionality out of the critical path in switch_mm, which reduces the number of function calls, potential TLB misses and code size.

Hmm - i don't think your description matches the patch. Or where is the critical path here?

-Andi