Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1756396rdb; Sun, 19 Nov 2023 08:59:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWs+OCyKlYjd2L3voYROj4m569lohf1Jcz8ZWOsqtHgxOX2AfRp+0RtCr2PNYs7HGKIKt3 X-Received: by 2002:aca:1113:0:b0:3b2:e5c6:23bc with SMTP id 19-20020aca1113000000b003b2e5c623bcmr6500422oir.52.1700413142837; Sun, 19 Nov 2023 08:59:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700413142; cv=none; d=google.com; s=arc-20160816; b=tETqz+/ly8gSXXt22alP2qTMQtovyBVpwpEHvpC/htEp7ONRTm4vOdWcQPTseJs+Iv tqpE0KZYdEyIqWAtR1zHdT7+JhJwKm+XHbV2M+au9o/dw72z90UucTQXmClOjATnkoDM 1rwTm3jrMbztHAE5bo9mesCHXinnciwKUFq6zkV/xrQ+IW46uJ6JE5f3WcVdK7cejyYd 3kWCdMCFDXa8NLci+guwEdAM/xnKTvmUVS6OMILmZnOxIjn/ldZb9BR013+L5U9+e1S/ Nvc9GDTiT/6LVsIjO3gfZgDU+IEmmw/WH0RxxLMeskhGZZzA4z5VGr9d/dkt4Dt6PI70 obFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=aFWXRa+GGPHMJHwCYR9WoxZ1jpNHVuHswRct9fy1eG0=; fh=ON0oQ90Z4xnjbNCGsyMgiRbLR29nyOKvbeaw6TmRihk=; b=zz8VmTOmBwjcgrJBYre7ncM07ogVz8PDh5OiDx3OZS5zloTTsYTA0xzix22CbUXuCN Y5zwgxE98cr8k7zWj8gH7+f+3w2Jj8uTd4UIpUOuUHILhzs9LiEhUaHUERg1/QMjiv2e Xg5I5OMmyeDy0shAuHRujMi730buhSHW0V0z9+QqmjD5bEnsZL/VrI+rtYf+s9OO3t+f 0QtOH9ijHY3R4uKuUxxT7KUYiCV+/6fIJGutW0RkaDG+bGjVJGW/0jxkCpeZLI6/gTIC lTXEOhhb9xvToe1tjosXEtjmEb9f8ICRDxu2ui/Rzy39K5sEVVS2omd3Nlfqkf5RKMV9 aO4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id m15-20020a656a0f000000b005bd39fc1ebesi6952088pgu.223.2023.11.19.08.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 08:59:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 392C18057E5D; Sun, 19 Nov 2023 08:58:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231551AbjKSQ6a (ORCPT + 99 others); Sun, 19 Nov 2023 11:58:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231519AbjKSQ60 (ORCPT ); Sun, 19 Nov 2023 11:58:26 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A604511D; Sun, 19 Nov 2023 08:58:16 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 967AFDA7; Sun, 19 Nov 2023 08:59:02 -0800 (PST) Received: from e121798.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6F4F03F6C4; Sun, 19 Nov 2023 08:58:11 -0800 (PST) From: Alexandru Elisei To: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com Cc: pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, david@redhat.com, eugenis@google.com, kcc@google.com, hyesoo.yu@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH RFC v2 07/27] mm: page_alloc: Add an arch hook to filter MIGRATE_CMA allocations Date: Sun, 19 Nov 2023 16:57:01 +0000 Message-Id: <20231119165721.9849-8-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231119165721.9849-1-alexandru.elisei@arm.com> References: <20231119165721.9849-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 19 Nov 2023 08:58:54 -0800 (PST) As an architecture might have specific requirements around the allocation of CMA pages, add an arch hook that can disable allocations from MIGRATE_CMA, if the allocation was otherwise allowed. This will be used by arm64, which will put tag storage pages on the MIGRATE_CMA list, pages which have specific limitations. Signed-off-by: Alexandru Elisei --- include/linux/pgtable.h | 7 +++++++ mm/page_alloc.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 3f34f00ced62..b7a9ab818f6d 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -884,6 +884,13 @@ static inline int arch_prep_new_page(struct page *page, int order, gfp_t gfp) static inline void arch_free_pages_prepare(struct page *page, int order) { } #endif +#ifndef __HAVE_ARCH_ALLOC_CMA +static inline bool arch_alloc_cma(gfp_t gfp) +{ + return true; +} +#endif + #ifndef __HAVE_ARCH_UNMAP_ONE /* * Some architectures support metadata associated with a page. When a diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 86e4b1dac538..0f508070c404 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3167,7 +3167,8 @@ static inline unsigned int gfp_to_alloc_flags_cma(gfp_t gfp_mask, unsigned int alloc_flags) { #ifdef CONFIG_CMA - if (gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE) + if (gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE && + arch_alloc_cma(gfp_mask)) alloc_flags |= ALLOC_CMA; #endif return alloc_flags; -- 2.42.1