Re: [PATCH] RISC-V: Issue a local tlb flush if possible.

From: Andreas Schwab
Date: Sat Aug 10 2019 - 02:37:41 EST


On Aug 09 2019, Atish Patra <atish.patra@xxxxxxx> wrote:

> @@ -46,14 +47,38 @@ static inline void remote_sfence_vma(struct cpumask *cmask, unsigned long start,
> unsigned long size)
> {
> struct cpumask hmask;
> + struct cpumask tmask;
> + int cpuid = smp_processor_id();
>
> cpumask_clear(&hmask);
> - riscv_cpuid_to_hartid_mask(cmask, &hmask);
> - sbi_remote_sfence_vma(hmask.bits, start, size);
> + cpumask_clear(&tmask);
> +
> + if (cmask)
> + cpumask_copy(&tmask, cmask);
> + else
> + cpumask_copy(&tmask, cpu_online_mask);
> +
> + if (cpumask_test_cpu(cpuid, &tmask)) {
> + /* Save trap cost by issuing a local tlb flush here */
> + if ((start == 0 && size == -1) || (size > PAGE_SIZE))
> + local_flush_tlb_all();
> + else if (size == PAGE_SIZE)
> + local_flush_tlb_page(start);
> + cpumask_clear_cpu(cpuid, &tmask);
> + } else if (cpumask_empty(&tmask)) {
> + /* cpumask is empty. So just do a local flush */
> + local_flush_tlb_all();
> + return;
> + }
> +
> + if (!cpumask_empty(&tmask)) {
> + riscv_cpuid_to_hartid_mask(&tmask, &hmask);
> + sbi_remote_sfence_vma(hmask.bits, start, size);
> + }
> }

I think it's becoming too big to be inline.

Andreas.

--
Andreas Schwab, schwab@xxxxxxxxxxxxxx
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."