Excessive TLB flush ranges
Russell King (Oracle)
linux at armlinux.org.uk
Tue May 16 01:45:08 PDT 2023
On Tue, May 16, 2023 at 04:07:17PM +0800, Baoquan He wrote:
> On 05/16/23 at 08:40am, Thomas Gleixner wrote:
> > On Tue, May 16 2023 at 10:26, Baoquan He wrote:
> > > On 05/15/23 at 08:17pm, Uladzislau Rezki wrote:
> > >> For systems which lack a full TLB flush and to flush a long range is
> > >> a problem(it takes time), probably we can flush VA one by one. Because
> > >> currently we calculate a flush range [min:max] and that range includes
> > >> the space that might not be mapped at all. Like below:
> > >
> > > It's fine if we only calculate a flush range of [min:max] with VA. In
> > > vm_reset_perms(), it calculates the flush range with the impacted direct
> > > mapping range, then merge it with VA's range. That looks really strange
> > > and surprising. If the vm->pages[] are got from a lower part of physical
> > > memory, the final merged flush will span tremendous range. Wondering why
> > > we need merge the direct map range with VA range, then do flush. Not
> > > sure if I misunderstand it.
> >
> > So what happens on this BPF teardown is:
> >
> > The vfree(8k) ends up flushing 3 entries. The actual vmalloc part (2) and
> > one extra which is in the direct map. I haven't verified that yet, but I
> > assume it's the alias of one of the vmalloc'ed pages.
>
> It looks like the reason. As Uladzislau pointed out, ARCH-es may
> have full TLB flush, so won't get trouble from the merged flush
> in the calculated [min:max] way, e.g arm64 and x86's flush_tlb_kernel_range().
> However, arm32 seems lacking the ability of full TLB flash. If agreed, I
> can make a draft patch to do the flush for direct map and VA seperately,
> see if it works.
The question IMHO is not so much whether there's a full-TLB flush
available, but whether it is appropriate to use it. If we're only
wanting to flush a small number of TLB entries but over a sparse
range (which seems to be Thomas' situation), does it make any sense
to flush all TLB entries? I don't think it does, but it depends
how often this occurs. If we're doing it on a regular basis because
of some workload, then that workload suffers. If it's a rare event
then maybe that's okay to do.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
More information about the linux-arm-kernel
mailing list