On Fri 04-07-25 17:25:33, Uladzislau Rezki wrote:
> The vm_area_alloc_pages() function uses cond_resched() to yield the
> CPU during potentially long-running loops. However, yielding should
> only be done if the given GFP flags allow blocking.
>
> This patch avoids calling cond_resched() when the allocation context
> is non-blocking(GFP_ATOMIC, GFP_NOWAIT).
Do we even need those cond_resched calls? Both of them are called
shortly after memory allocator which already yields CPU when allowed.
>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
> mm/vmalloc.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 8c375b8e269d..25d09f753239 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -3624,7 +3624,9 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
> pages + nr_allocated);
>
> nr_allocated += nr;
> - cond_resched();
> +
> + if (gfpflags_allow_blocking(gfp))
> + cond_resched();
>
> /*
> * If zero or pages were obtained partly,
> @@ -3666,7 +3668,9 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
> for (i = 0; i < (1U << order); i++)
> pages[nr_allocated + i] = page + i;
>
> - cond_resched();
> + if (gfpflags_allow_blocking(gfp))
> + cond_resched();
> +
> nr_allocated += 1U << order;
> }
>
> --
> 2.39.5
--
Michal Hocko
SUSE Labs