mmu_context.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  4. */
  5. #ifndef __UM_MMU_CONTEXT_H
  6. #define __UM_MMU_CONTEXT_H
  7. #include <linux/sched.h>
  8. #include <linux/mm_types.h>
  9. #include <linux/mmap_lock.h>
  10. #include <asm/mm_hooks.h>
  11. #include <asm/mmu.h>
  12. extern void force_flush_all(void);
  13. #define activate_mm activate_mm
  14. static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
  15. {
  16. /*
  17. * This is called by fs/exec.c and sys_unshare()
  18. * when the new ->mm is used for the first time.
  19. */
  20. __switch_mm(&new->context.id);
  21. }
  22. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  23. struct task_struct *tsk)
  24. {
  25. unsigned cpu = smp_processor_id();
  26. if(prev != next){
  27. cpumask_clear_cpu(cpu, mm_cpumask(prev));
  28. cpumask_set_cpu(cpu, mm_cpumask(next));
  29. if(next != &init_mm)
  30. __switch_mm(&next->context.id);
  31. }
  32. }
  33. #define init_new_context init_new_context
  34. extern int init_new_context(struct task_struct *task, struct mm_struct *mm);
  35. #define destroy_context destroy_context
  36. extern void destroy_context(struct mm_struct *mm);
  37. #include <asm-generic/mmu_context.h>
  38. #endif