Re: [PATCH v2 01/13] mm/page_alloc: rename ALLOC_TRYLOCK -> ALLOC_NOLOCK

From: Suren Baghdasaryan

Date: Wed Jun 24 2026 - 10:44:07 EST


On Mon, Jun 22, 2026 at 3:01 AM Brendan Jackman <jackmanb@xxxxxxxxxx> wrote:
>
> It's confusing that the function is called "nolock" but the flag is
> called "trylock", align them.
>
> The function's terminology is more visible and has more mindshare so use that.
>
> Suggested-by: "Vlastimil Babka (SUSE)" <vbabka@xxxxxxxxxx>
> Link: https://lore.kernel.org/linux-mm/2399b3ad-4eac-4a14-94c3-27e9f07972a1@xxxxxxxxxx/
> Signed-off-by: Brendan Jackman <jackmanb@xxxxxxxxxx>

That comment for ALLOC_NOLOCK about only using spin_trylock in the
allocation path could be rewritten to say that no locking or spinning
is allowed but it's a minor detail.

Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>

> ---
> mm/internal.h | 2 +-
> mm/page_alloc.c | 10 +++++-----
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/mm/internal.h b/mm/internal.h
> index 181e79f1d6a20..1483a4fcdfce1 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -1475,7 +1475,7 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone,
> #define ALLOC_NOFRAGMENT 0x0
> #endif
> #define ALLOC_HIGHATOMIC 0x200 /* Allows access to MIGRATE_HIGHATOMIC */
> -#define ALLOC_TRYLOCK 0x400 /* Only use spin_trylock in allocation path */
> +#define ALLOC_NOLOCK 0x400 /* Only use spin_trylock in allocation path */
> #define ALLOC_KSWAPD 0x800 /* allow waking of kswapd, __GFP_KSWAPD_RECLAIM set */
>
> /* Flags that allow allocations below the min watermark. */
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 0111cdbdb5321..6c4eb6908bd95 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2528,7 +2528,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
> unsigned long flags;
> int i;
>
> - if (unlikely(alloc_flags & ALLOC_TRYLOCK)) {
> + if (unlikely(alloc_flags & ALLOC_NOLOCK)) {
> if (!spin_trylock_irqsave(&zone->lock, flags))
> return 0;
> } else {
> @@ -3216,7 +3216,7 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone,
>
> do {
> page = NULL;
> - if (unlikely(alloc_flags & ALLOC_TRYLOCK)) {
> + if (unlikely(alloc_flags & ALLOC_NOLOCK)) {
> if (!spin_trylock_irqsave(&zone->lock, flags))
> return NULL;
> } else {
> @@ -5042,7 +5042,7 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order,
> * Don't invoke should_fail logic, since it may call
> * get_random_u32() and printk() which need to spin_lock.
> */
> - if (!(*alloc_flags & ALLOC_TRYLOCK) &&
> + if (!(*alloc_flags & ALLOC_NOLOCK) &&
> should_fail_alloc_page(gfp_mask, order))
> return false;
>
> @@ -7786,7 +7786,7 @@ static bool cond_accept_memory(struct zone *zone, unsigned int order,
> return false;
>
> /* Bailout, since try_to_accept_memory_one() needs to take a lock */
> - if (alloc_flags & ALLOC_TRYLOCK)
> + if (alloc_flags & ALLOC_NOLOCK)
> return false;
>
> wmark = promo_wmark_pages(zone);
> @@ -7878,7 +7878,7 @@ struct page *alloc_frozen_pages_nolock_noprof(gfp_t gfp_flags, int nid, unsigned
> */
> gfp_t alloc_gfp = __GFP_NOWARN | __GFP_ZERO | __GFP_NOMEMALLOC | __GFP_COMP
> | gfp_flags;
> - unsigned int alloc_flags = ALLOC_TRYLOCK;
> + unsigned int alloc_flags = ALLOC_NOLOCK;
> struct alloc_context ac = { };
> struct page *page;
>
>
> --
> 2.54.0
>