The patch titled

     uml: fixes performance regression in activate_mm and thus exec()

has been added to the -mm tree.  Its filename is

     uml-fixes-performance-regression-in-activate_mm-and-thus-exec.patch

Patches currently in -mm which might be from [EMAIL PROTECTED] are

comment-typo-fix.patch
x86_64-remove-duplicated-sys_time64.patch
uml-rename-kconfig-files-to-be-like-the-other-arches.patch
ptrace-i386-fix-syscall-audit-interaction-with-singlestep.patch
uml-support-ptrace-adds-the-host-sysemu-support-for-uml-and-general-usage.patch
uml-support-reorganize-ptrace_sysemu-support.patch
uml-support-add-ptrace_sysemu_singlestep-option-to-i386.patch
sysemu-fix-sysaudit--singlestep-interaction.patch
uml-support-sysemu-slight-cleanup-and-speedup.patch
uml-workaround-gdb-problems-on-debugging.patch
uml-fix-sigwinch-handler-race-while-waiting-for-signals.patch
uml-fixes-performance-regression-in-activate_mm-and-thus-exec.patch



From: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>

Normally, activate_mm() is called from exec(), and thus it used to be a
no-op because we use a completely new "MM context" on the host (for
instance, a new process), and so we didn't need to flush any "TLB entries"
(which for us are the set of memory mappings for the host process from the
virtual "RAM" file).

Kernel threads, instead, are usually handled in a different way.  So, when
for AIO we call use_mm(), things used to break and so Benjamin implemented
activate_mm().  However, that is only needed for AIO, and could slow down
exec() inside UML, so be smart: detect being called for AIO (via
PF_BORROWED_MM) and do the full flush only in that situation.

Comment also the caller so that people won't go breaking UML without
noticing.  I also rely on the caller's locks for testing current->flags.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
CC: Benjamin LaHaise <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 fs/aio.c                     |    4 ++++
 include/asm-um/mmu_context.h |   10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff -puN 
fs/aio.c~uml-fixes-performance-regression-in-activate_mm-and-thus-exec fs/aio.c
--- 25/fs/aio.c~uml-fixes-performance-regression-in-activate_mm-and-thus-exec   
Wed Aug 17 14:45:40 2005
+++ 25-akpm/fs/aio.c    Wed Aug 17 14:46:06 2005
@@ -567,6 +567,10 @@ static void use_mm(struct mm_struct *mm)
        atomic_inc(&mm->mm_count);
        tsk->mm = mm;
        tsk->active_mm = mm;
+       /*
+        * Note that on UML this *requires* PF_BORROWED_MM to be set, otherwise
+        * it won't work. Update it accordingly if you change it here
+        */
        activate_mm(active_mm, mm);
        task_unlock(tsk);
 
diff -puN 
include/asm-um/mmu_context.h~uml-fixes-performance-regression-in-activate_mm-and-thus-exec
 include/asm-um/mmu_context.h
--- 
25/include/asm-um/mmu_context.h~uml-fixes-performance-regression-in-activate_mm-and-thus-exec
       Wed Aug 17 14:45:40 2005
+++ 25-akpm/include/asm-um/mmu_context.h        Wed Aug 17 14:46:16 2005
@@ -20,7 +20,15 @@ extern void force_flush_all(void);
 
 static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
 {
-       if (old != new)
+       /*
+        * This is called by fs/exec.c and fs/aio.c. In the first case, for an
+        * exec, we don't need to do anything as we're called from userspace
+        * and thus going to use a new host PID. In the second, we're called
+        * from a kernel thread, and thus need to go doing the mmap's on the
+        * host. Since they're very expensive, we want to avoid that as far as
+        * possible.
+        */
+       if (old != new && (current->flags & PF_BORROWED_MM))
                force_flush_all();
 }
 
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to