Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp79912rdb; Thu, 25 Jan 2024 08:46:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOYcHgmrcecu4yrE/yt8qZrUbWcKCYq5Mv76HFb46bcBIGwa/3w4JNXeU8GdpLv96TtYyv X-Received: by 2002:a05:6870:6985:b0:210:b468:6a5d with SMTP id my5-20020a056870698500b00210b4686a5dmr1252526oab.16.1706201183300; Thu, 25 Jan 2024 08:46:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706201183; cv=pass; d=google.com; s=arc-20160816; b=dzHhz72z1NzQlSvkyuEWxP3e9ed0IKm1GCirn8tBO0p+H/IvOqBMPFferHScyV6C85 IpVTlF8GhrKUPAOcqChL5s4bbLvDZjxNKlF9MmpaWEY3QVHyZGvePe3yvj/yNFgEDwCh QpdCqVa1X5MXoHXsDU7ndQN8ITBM23MDLv7ddW4jFj/Y+m5tyRJrDWF1GYLNzC3zYBZ9 1WhllgXsA67Z1q0junpuHCmsbtKJJZvqw66A/Hun52r/klIeNJCrY2h8krJJg7bH+oVp /fIMxwvVe22D5qxvI4Yd2A8z+ovww5uQc9VIUT0W+WKF1t6y5hnfMZ0cTS7NxmKA/DrH XgnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=/m4vNs7M03/9f2nYaUHeWkQCui+Og+uQ/XcHmyqte6Y=; fh=ON0oQ90Z4xnjbNCGsyMgiRbLR29nyOKvbeaw6TmRihk=; b=Qwx77GQIrMrg2xYhpSeVy/FTP+Bj/i5Jo3okgGYTDSQAXcalREGALHSgfJ4gG/N9pc SO2Df1+X6y1YkUEyqRaR0a5+eDGEImcgxzkHtZPUVSfU1YiqKSEDoCrGPn9Glf/9nOnH /ICqdLdZHJ+7oXGfgou72mrANozcvgGu8iqLc2UruhRSrUnHgaaddRK+QofebPjeP8CO lDPmp9dQLDPJL+f87YEhE8nvb21WnoqswC2BcQ7jhTkY+PwEZOYvYoFNxnioINX9BVBx n+BAg3LuUbKV8+d3VPc7D5nSYkJMc1FE7uQdS3skgFeBm+38R9Ku9QAopj1mymIL9CAU iHvg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38916-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38916-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h2-20020ac87d42000000b0042a6d08cf32si1307995qtb.53.2024.01.25.08.46.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 08:46:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38916-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-38916-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38916-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A449D1C2129D for ; Thu, 25 Jan 2024 16:45:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D9FD135A48; Thu, 25 Jan 2024 16:43:08 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8F09135417; Thu, 25 Jan 2024 16:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706200988; cv=none; b=JMJhvT2tIgGWwlWAThl1vEQBsxW8KM0/Yi5ckUndUVUT3Hk+SAYSlaKJeXhyK5W4eSv5nMRs3KK0SwC3rCYcrGInPu7EK1nVEzxgGVTPOglnEgsZmXpi/fna0Bg1G3PMTnF9T46rU2okS80KPgqrgxWHEquoIYsHT5OYLgqitZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706200988; c=relaxed/simple; bh=D/hqHT7m4p56hZz+nSWR5TR3chuuOg75oPh3Ho54hkM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ojUKs5CYWwz9/XBg1BJFcCy9s8AHsbFEGN0Brfp9KXYReC9uDeSMhlFHzQelc1JAfi5DkxAiF2fI8vSy9vlLDth2yZTvsevS3h5ql0HXl0bK8RKR8HvkHuNx4yLBN+VmRm8N5E3vsfBsb0YCpI+xSsmjMqtEveBkaJzEyfECP0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 D2B4A1477; Thu, 25 Jan 2024 08:43:48 -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 E1DA43F5A1; Thu, 25 Jan 2024 08:42:58 -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 v3 03/35] mm: page_alloc: Add an arch hook to filter MIGRATE_CMA allocations Date: Thu, 25 Jan 2024 16:42:24 +0000 Message-Id: <20240125164256.4147-4-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240125164256.4147-1-alexandru.elisei@arm.com> References: <20240125164256.4147-1-alexandru.elisei@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, and tag storage pages cannot be tagged. The filter will be used to deny using MIGRATE_CMA for __GFP_TAGGED allocations. 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 6d98d5fdd697..c5ddec6b5305 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -905,6 +905,13 @@ static inline void arch_do_swap_page(struct mm_struct *mm, 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 27282a1c82fe..a96d47a6393e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3157,7 +3157,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.43.0