perf tools: Don't clone maps from parent when synthesizing forks
[linux/fpc-iii.git] / arch / nds32 / include / asm / mmu_context.h
blobfd7d13cefccc115529e1a19fa10bb5ad54eb7666
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
4 #ifndef __ASM_NDS32_MMU_CONTEXT_H
5 #define __ASM_NDS32_MMU_CONTEXT_H
7 #include <linux/spinlock.h>
8 #include <asm/tlbflush.h>
9 #include <asm/proc-fns.h>
10 #include <asm-generic/mm_hooks.h>
12 static inline int
13 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
15 mm->context.id = 0;
16 return 0;
19 #define destroy_context(mm) do { } while(0)
21 #define CID_BITS 9
22 extern spinlock_t cid_lock;
23 extern unsigned int cpu_last_cid;
25 static inline void __new_context(struct mm_struct *mm)
27 unsigned int cid;
28 unsigned long flags;
30 spin_lock_irqsave(&cid_lock, flags);
31 cid = cpu_last_cid;
32 cpu_last_cid += 1 << TLB_MISC_offCID;
33 if (cpu_last_cid == 0)
34 cpu_last_cid = 1 << TLB_MISC_offCID << CID_BITS;
36 if ((cid & TLB_MISC_mskCID) == 0)
37 flush_tlb_all();
38 spin_unlock_irqrestore(&cid_lock, flags);
40 mm->context.id = cid;
43 static inline void check_context(struct mm_struct *mm)
45 if (unlikely
46 ((mm->context.id ^ cpu_last_cid) >> TLB_MISC_offCID >> CID_BITS))
47 __new_context(mm);
50 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
54 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
55 struct task_struct *tsk)
57 unsigned int cpu = smp_processor_id();
59 if (!cpumask_test_and_set_cpu(cpu, mm_cpumask(next)) || prev != next) {
60 check_context(next);
61 cpu_switch_mm(next);
65 #define deactivate_mm(tsk,mm) do { } while (0)
66 #define activate_mm(prev,next) switch_mm(prev, next, NULL)
68 #endif