mmu_context.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #define activate_mm activate_mm
  13. static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
  14. {
  15. /*
  16. * This is called by fs/exec.c and sys_unshare()
  17. * when the new ->mm is used for the first time.
  18. */
  19. __switch_mm(&new->context.id);
  20. }
  21. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  22. struct task_struct *tsk)
  23. {
  24. unsigned cpu = smp_processor_id();
  25. if(prev != next){
  26. cpumask_clear_cpu(cpu, mm_cpumask(prev));
  27. cpumask_set_cpu(cpu, mm_cpumask(next));
  28. if(next != &init_mm)
  29. __switch_mm(&next->context.id);
  30. }
  31. }
  32. #define init_new_context init_new_context
  33. extern int init_new_context(struct task_struct *task, struct mm_struct *mm);
  34. #define destroy_context destroy_context
  35. extern void destroy_context(struct mm_struct *mm);
  36. #include <asm-generic/mmu_context.h>
  37. #endif