Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'next/tlb-opt' into for-next

+23 -2
+23 -2
arch/riscv/mm/tlbflush.c
··· 2 2 3 3 #include <linux/mm.h> 4 4 #include <linux/smp.h> 5 + #include <linux/sched.h> 5 6 #include <asm/sbi.h> 6 7 7 8 void flush_tlb_all(void) ··· 10 9 sbi_remote_sfence_vma(NULL, 0, -1); 11 10 } 12 11 12 + /* 13 + * This function must not be called with cmask being null. 14 + * Kernel may panic if cmask is NULL. 15 + */ 13 16 static void __sbi_tlb_flush_range(struct cpumask *cmask, unsigned long start, 14 17 unsigned long size) 15 18 { 16 19 struct cpumask hmask; 20 + unsigned int cpuid; 17 21 18 - riscv_cpuid_to_hartid_mask(cmask, &hmask); 19 - sbi_remote_sfence_vma(hmask.bits, start, size); 22 + if (cpumask_empty(cmask)) 23 + return; 24 + 25 + cpuid = get_cpu(); 26 + 27 + if (cpumask_any_but(cmask, cpuid) >= nr_cpu_ids) { 28 + /* local cpu is the only cpu present in cpumask */ 29 + if (size <= PAGE_SIZE) 30 + local_flush_tlb_page(start); 31 + else 32 + local_flush_tlb_all(); 33 + } else { 34 + riscv_cpuid_to_hartid_mask(cmask, &hmask); 35 + sbi_remote_sfence_vma(cpumask_bits(&hmask), start, size); 36 + } 37 + 38 + put_cpu(); 20 39 } 21 40 22 41 void flush_tlb_mm(struct mm_struct *mm)