Re: [PATCH 8/9] mm/madvise: batch tlb flushes for [process_]madvise(MADV_{DONTNEED[_LOCKED],FREE})
From: SeongJae Park
Date: Tue Apr 01 2025 - 17:17:16 EST
On Mon, 10 Mar 2025 10:23:17 -0700 SeongJae Park <sj@xxxxxxxxxx> wrote:
> MADV_DONTNEED[_LOCKED] and MADV_FREE internal logics for
> [process_]madvise() can be invoked with batched tlb flushes. Update
> vector_madvise() and do_madvise(), which are called for the two system
> calls respectively, to use those in the efficient way. Initialize an
> mmu_gather object before starting the internal works, and flush the
> gathered tlb entries at once after all the internal works are done.
>
> Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
> ---
> mm/madvise.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 47 insertions(+), 4 deletions(-)
>
> diff --git a/mm/madvise.c b/mm/madvise.c
> index d7ea71c6422c..d5f4ce3041a4 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
[...]
> @@ -1639,6 +1642,32 @@ static void madvise_unlock(struct mm_struct *mm, int behavior)
> mmap_read_unlock(mm);
> }
>
> +static bool madvise_batch_tlb_flush(int behavior)
> +{
> + switch (behavior) {
> + case MADV_DONTNEED:
> + case MADV_DONTNEED_LOCKED:
> + return true;
> + default:
> + return false;
> + }
> +}
The above function should return true for MADV_FREE, too. I will make so in the
next spin.
Thanks,
SJ
[...]