Module: xenomai-rpm
Branch: for-upstream
Commit: 6bb1b5b22670bd118eabd9240b782a249b3fd6ae
URL:    
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=6bb1b5b22670bd118eabd9240b782a249b3fd6ae

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon May 17 15:28:36 2010 +0200

powerpc: use hardened switch_mm() support when available

Newer I-pipe patches allow to call __switch_mm() from non-root
contexts (*). Use this feature to greatly simplify our context
switching code for those kernels.

Another upside is to keep the mm switching innards only known from the
linux core.

(*) __IPIPE_FEATURE_HARDENED_SWITCHMM.

---

 include/asm-powerpc/bits/pod.h |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/asm-powerpc/bits/pod.h b/include/asm-powerpc/bits/pod.h
index 0502212..6fe5e7b 100644
--- a/include/asm-powerpc/bits/pod.h
+++ b/include/asm-powerpc/bits/pod.h
@@ -119,7 +119,11 @@ static inline void xnarch_switch_to(xnarchtcb_t *out_tcb,
 
        next_mm = in_tcb->active_mm;
 
-       if (prev_mm != next_mm) {
+#ifdef __IPIPE_FEATURE_HARDENED_SWITCHMM
+       if (next_mm && likely(prev_mm != next_mm))
+               __switch_mm(prev_mm, next_mm, next);
+#else /* !__IPIPE_FEATURE_HARDENED_SWITCHMM */
+       if (likely(prev_mm != next_mm)) {
 #ifdef CONFIG_ALTIVEC
                asm volatile ("dssall;\n" :/*empty*/:);
 #endif
@@ -133,9 +137,8 @@ static inline void xnarch_switch_to(xnarchtcb_t *out_tcb,
                                switch_stab(next, next_mm);
                }
         }
-       rthal_thread_switch(out_tcb->tsp, in_tcb->tsp, next == NULL);
 #else /* PPC32 */
-               if (likely(next_mm != NULL)) {
+               if (likely(next_mm)) {
                        next->thread.pgdir = next_mm->pgd;
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
                        get_mmu_context(next_mm);
@@ -150,9 +153,14 @@ static inline void xnarch_switch_to(xnarchtcb_t *out_tcb,
                        current = prev; /* Make sure r2 is valid. */
                }
        }
-       rthal_thread_switch(out_tcb->tsp, in_tcb->tsp);
 #endif /* PPC32 */
+#endif /* !__IPIPE_FEATURE_HARDENED_SWITCHMM */
 
+#ifdef CONFIG_PPC64
+       rthal_thread_switch(out_tcb->tsp, in_tcb->tsp, next == NULL);
+#else
+       rthal_thread_switch(out_tcb->tsp, in_tcb->tsp);
+#endif
        barrier();
 }
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to