mm/vmalloc: avoid iterating over per CPU vmap blocks twice
authorThomas Gleixner <tglx@linutronix.de>
Thu, 25 May 2023 12:57:04 +0000 (14:57 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 9 Jun 2023 23:25:40 +0000 (16:25 -0700)
commitca5e46c3400badc418a8fbcaeba711ad60ff4e1b
tree7de31529fbc5f27f7a0a7a0b1a32f121be753e8b
parentfc1e0d980037e065441cd1d9a1a5e9c9117e4ba2
mm/vmalloc: avoid iterating over per CPU vmap blocks twice

_vunmap_aliases() walks the per CPU xarrays to find partially unmapped
blocks and then walks the per cpu free lists to purge fragmented blocks.

Arguably that's waste of CPU cycles and cache lines as the full xarray
walk already touches every block.

Avoid this double iteration:

  - Split out the code to purge one block and the code to free the local
    purge list into helper functions.

  - Try to purge the fragmented blocks in the xarray walk before looking at
    their dirty space.

Link: https://lkml.kernel.org/r/20230525124504.633469722@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Baoquan He <bhe@redhat.com>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmalloc.c