From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D0904DA537 for ; Thu, 2 Jul 2026 09:50:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782985812; cv=none; b=WRWa2GluYMKSfV3IymQ7NqkZmF5fpDNUuf+1CJJxq1qK/eTaKl8AoVAef2S6BmkMGTtQIzplpT+XoyrXQIyr7ixmsqLnXQMs/VvJeUflGrDjVUr1tEJOrmOKcmwwRAELEVFwHp8q0wnUuEl5h+FcqkLB6Qko7AChXGd36DTQLOE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782985812; c=relaxed/simple; bh=29DjDNblqVpTGDCQuZAaQoS1GbOAOm7XzMBS6FpDHNc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YeW9nk6KjKoXvtgzVOEP1XtyYLlYYq1i/u7cv+bMzDvxHtEHMb3tOgx5BsGifWxYyOYgOgd0OfZjE3+zCpScrCD2atBnSZY1DXH7mCDNlG5+SPKD2eeP+aQz/iPfewOXywDdfWYbKLiWSgE7hg+hQadKeijueTCbkLIteiDBxPA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=txahEXpi; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="txahEXpi" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-475e540a0ffso1036481f8f.3 for ; Thu, 02 Jul 2026 02:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782985809; x=1783590609; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jQXytmyYmI8a16dW0v09XUUNQjHph6nhuleCzdBkd7M=; b=txahEXpiomwWAWTT97Cos8ALpd+pXzxdh/SQmsy4gX3q+PqNs6ymnAbWJ0yyFmuW2U zrE9mMb5Ovn8tAuSWm4eW7VYL+wEUsXbPaGhwLYzKHg4YUDjB4Ug1UFd7iZvA9/nCLRP pzwt+nKqHNtWbhqSQsUx9U3ZMuBdU3ggpW/Juc6q6moCi/FEzxYHgHNy1g/uMVCiZLkh ftqJpcE7ZhjsaK2YRsKKt6jZ7DyxY8ZSmXcEYpORMj1eqH0PbtHRD8aqmE/oPXyvNIR/ yIj6q29QrX7Ua24AAhx8F/uEpqf8YHAX85MQEiXILF3sOIxLuir7KYC/efpQngZbEdb8 qb5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782985809; x=1783590609; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jQXytmyYmI8a16dW0v09XUUNQjHph6nhuleCzdBkd7M=; b=ki3gJOtGzgyTF2MiWv4ELgT3eyDAoGTnSGig7dAxP7Ch+LS3DS7p3adBLyXEL6cBSu JiiLiy9f70qqtwupHc9Xwk7OU1YVP3F6dZIQW9nprqnHUSCR9sptBOMTbBUlDmixSzIn zX1TK55hURzqdNraKoKRPlW0M4SVIQqawWYA8yuyf64fYB5xCTBOf42aflQbM6HLIaDm f/sSPfrijtpwEbA1Ntbnh33/ISxFKlC2ge0Gswl3VOi5pxRjbo2GP6gRgUQ+9mFXce8q ICoSAEYMiovGrRx1fHWbx211TwVoQuDIZclV5S5TzB9duj6xSdsqhzIumTK7vC1RgjJN 8P3A== X-Forwarded-Encrypted: i=1; AHgh+RrUcBI3RZ6hzweJienyCdCSv/UPDYyjTtzjQ39JnLadlqwu61OK5HEHT+71HQLs726zJxR8tC+D6ZUbYgs=@vger.kernel.org X-Gm-Message-State: AOJu0Yyc7ckWuGL4U5rlG7GnMcXAkvzLFoAsSTeKlMl1BIl9wjp9oy6B I0LbkMif+DCwrOvnypG5djLltaVGGNDOlH2dqNEP1ILI6xF1jU3q8HZwOqHfLOlXvresHY15Ac5 S6qOMgm6PmZpchA== X-Received: from wrsx9.prod.google.com ([2002:adf:ffc9:0:b0:462:fc9c:4a7a]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:adf:fc08:0:b0:473:e22:e819 with SMTP id ffacd0b85a97d-4775a0fe0dcmr6360703f8f.29.1782985808510; Thu, 02 Jul 2026 02:50:08 -0700 (PDT) Date: Thu, 02 Jul 2026 09:49:48 +0000 In-Reply-To: <20260702-alloc-trylock-v4-0-0af8ff387e80@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260702-alloc-trylock-v4-0-0af8ff387e80@google.com> X-Mailer: b4 0.15.2 Message-ID: <20260702-alloc-trylock-v4-17-0af8ff387e80@google.com> Subject: [PATCH v4 17/18] mm/page_alloc: drop alloc_flags arg from alloc_flags_cma() From: Brendan Jackman To: Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Johannes Weiner , Zi Yan , Muchun Song , Oscar Salvador , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Mike Rapoport , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Ying Huang , Alistair Popple , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: "Harry Yoo (Oracle)" , Gregory Price , Johannes Weiner , Alexei Starovoitov , Matthew Wilcox , Hao Ge , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, derkling@google.com, reijiw@google.com, Brendan Jackman , Yosry Ahmed Content-Type: text/plain; charset="utf-8" To align the style with other alloc_flags_*() functions, drop this additive argument and just have the callers do that themselves. Note you can't always freely or alloc_flags like these callers do (because of the WMARK bits that encode an enum) but this is fine for ALLOC_CMA, just like it's fine for e.g. ALLOC_NON_BLOCK returned by alloc_flags_nonblocking() and or'd by its caller. Suggested-by: Vlastimil Babka (SUSE) Link: https://lore.kernel.org/all/5dcdd1ef-21ad-4ed0-9e8a-0e5cf96b4392@kernel.org/ Signed-off-by: Brendan Jackman --- mm/page_alloc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cfaf16244f56d..c3b246e67ed14 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3775,14 +3775,13 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) } /* Must be called after current_gfp_context() which can change gfp_mask */ -static inline unsigned int alloc_flags_cma(gfp_t gfp_mask, - unsigned int alloc_flags) +static inline unsigned int alloc_flags_cma(gfp_t gfp_mask) { #ifdef CONFIG_CMA if (gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE) - alloc_flags |= ALLOC_CMA; + return ALLOC_CMA; #endif - return alloc_flags; + return ALLOC_DEFAULT; } /* @@ -4526,7 +4525,7 @@ alloc_flags_slowpath(gfp_t gfp_mask, unsigned int order) } else if (unlikely(rt_or_dl_task(current)) && in_task()) alloc_flags |= ALLOC_MIN_RESERVE; - alloc_flags = alloc_flags_cma(gfp_mask, alloc_flags); + alloc_flags |= alloc_flags_cma(gfp_mask); if (defrag_mode) alloc_flags |= ALLOC_NOFRAGMENT; @@ -4837,7 +4836,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, reserve_flags = __gfp_pfmemalloc_flags(gfp_mask); if (reserve_flags) - alloc_flags = alloc_flags_cma(gfp_mask, reserve_flags) | + alloc_flags = alloc_flags_cma(gfp_mask) | reserve_flags | ac->alloc_flags | (alloc_flags & ALLOC_KSWAPD); /* @@ -5070,7 +5069,7 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order, should_fail_alloc_page(gfp_mask, order)) return false; - *alloc_flags = alloc_flags_cma(gfp_mask, *alloc_flags); + *alloc_flags |= alloc_flags_cma(gfp_mask); /* Dirty zone balancing only done in the fast path */ ac->spread_dirty_pages = (gfp_mask & __GFP_WRITE); -- 2.54.0