Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp942496lql; Tue, 12 Mar 2024 02:44:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVqQg1nWU27Lw4RD4qQN3DseAgZjJxKx9VG8PTenyxvS2MW+lfLZbBozwFcau/1aN0+ALMZ0r5zD7KL9hiC0urIaMVx/OurMjbTZxWHnQ== X-Google-Smtp-Source: AGHT+IFBJclWmRXOMI0aUZMIVRmN5jXwyu5IYrhYfKw8s8ftWKD2IghgUzew1PGctYCHrHa7q0Is X-Received: by 2002:a17:906:3da9:b0:a45:b84f:7ad9 with SMTP id y9-20020a1709063da900b00a45b84f7ad9mr5622883ejh.9.1710236642934; Tue, 12 Mar 2024 02:44:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710236642; cv=pass; d=google.com; s=arc-20160816; b=p6MoZzPdAkXI9+KtQyamSD3m31+vtecqmC0GZxX/dnaeuODhcW4iVTZ+Fg8j06vD62 YfO9s5t6hp+t3ZPjI/uuJY42y5hpzgvEaAYUy/OmgxNbZPKKfO4wqXhHdE4zrlEj8amx c2gc+GpTQTNrKMMat1GR5P45iUri06nYu/Jwsj5vO7RtovrUJDiWc8BkYB0DxaXZSBGS pMK8yn0bCwILV8Yoo+LH5JhKEKelkmaK3Sx5MGGtil1yPYY0uk+iXg5FJfXH2CCnf2y3 7wQdLELGo0uVq/dB4Y5cBkP8n6HCF6klW90qdONSDplIt9wJQWQA3LRQ1JQrVrdSmz6u kjFg== 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:dkim-signature; bh=9wE2HsEwQuIKqCaqriShH9hKkj+cYk+gvkRx/+6+3to=; fh=62VBnY6W0jiFrZTR0Qo9l6LOOiQxadkx7JMCuLxBNWQ=; b=wdlUf7VUzvv8nZHG1oZA+AgFLed6pCG8UjJsLao0mMy9rseC7w9dEGPyBeiBrBs1wN usnfwuOS1nbx/vocxikrY5Ve3LYV+LaoZfbYzky50lRrM9KZbUEN1ywo18c9HC84VWyJ WkjeLmYBSe/J+swGty0Ssyy9ZX/zsxMDf8II6NSkfRW1WA8kXOWrrfSn3vOh27l9Wf8z HR5NQdbIXXo0IbArnu9En3pMbU/EenTvgGnl7VJhYhcdWnKuFcOpmDQqihHHCPj1G//p FHiV9kkYVNygqr+N1mIIyphBWR3UivIwUUtKDa0irfZxoVW+fXwgi61sNlfX18L2FevU 6tww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=B1cO7JY9; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-100045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ec10-20020a170906b6ca00b00a463eed3673si626523ejb.956.2024.03.12.02.44.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 02:44:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=B1cO7JY9; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-100045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 802A11F21310 for ; Tue, 12 Mar 2024 09:44:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B63CD7A720; Tue, 12 Mar 2024 09:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="B1cO7JY9" Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 A958679DDA for ; Tue, 12 Mar 2024 09:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710236517; cv=none; b=AaYL5oZAqw1r6gDytfeVcrghCYLseQayl1Wef1Uubegx2THNv008/wOXXJhI1nYBYQqiIyovng5FEl19CcUkvGbPnXoFSNTF7Wb83+NnXCEONlv+kuaC8c+wvRVi64hAgxv2pY/4fpwxQD/rglbBglwBhVan5OCGZkilCNjeD+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710236517; c=relaxed/simple; bh=WbgrH40EXEUiQSR1Yyn9b7sUNNxFQNIbVUvs4s+s9y8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ItoCniBtK+rG2oDfh6YsGORHKwWfJuKfw0cTqfl9h9Np/sgP1HBnaRmdxMwLo8Rfq9o2QE7snNE0le1I7t2NpoJq0YgotjuwgPi+UjRGuTTHE7XCUdiWikK87Qu6r/Xxt3I+MpxHDbBp9RYUIoiiYZmZFNCEIg6rj2YY+61lTZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=B1cO7JY9; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a45aa7cb2b3so481484066b.3 for ; Tue, 12 Mar 2024 02:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1710236514; x=1710841314; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9wE2HsEwQuIKqCaqriShH9hKkj+cYk+gvkRx/+6+3to=; b=B1cO7JY9JQ8K9AIWlyjExpZOe/wCCZIgXmKBbN290Vm6LYM+fbc4sJL5kObj5F5/1d GuC1cQv5haK82MA+6pwjuHEq3flEHFPTbKiQjgCsuiqbXJfJRiKm8r6hr6yRZpeEBf9H XwJA1y1pA7P/Mn/mGsrvQ9t/stI1zsMs20gJn6EQw591klPhZIP7B/R9zw5MYeaH0txf tfLQfeKY04xl0nPzJ4wKHModuuJQGU9FyqZvITkZ3ZttQ+c0Q/R3NAPyJtMfd12od/5k fVk8iSqIVyJVmPffpJDVRA7wMKhShYaPIovWuBgLSIVZZcBz/jn4yQVky+XqCJr58PPF o0xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710236514; x=1710841314; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9wE2HsEwQuIKqCaqriShH9hKkj+cYk+gvkRx/+6+3to=; b=cedoWGsXKhF6au7q+JEjMREC59KqxL72ITjCiB+C3o9jsMzbN1uCnRX2M98LlE8TlW SZak+c0qLh72Aidjg2hc7Ai/M3Z1cQ26U7wRlbzw2hCsada/AYL1FHaGdHkuaxfE9kR3 UddjbnU6KVFKBzoQZss9Wv65plTqZ5XJeo79M/DlpYcnUOfbmccqRKr3KOyFLqXpuOiC 8XCPVR2NgyRF5KICmba23n+TEexRipBeaH0gRkcsOacHDKiSc14ObdOhSrXgarGkwwX3 OwcXJgy85Lwie19yWgy5l45E8OdZgvjFxYV/o9UtrUTU1qSxQGhwvYaCEyLLZNAYJSHY iqHg== X-Forwarded-Encrypted: i=1; AJvYcCWjDLudPd4ZjXcJ+2QZOX1OZBQNIHeeCcu12lt78LhSvLilXzV7nLP9l4nYmwty4rAXOEfp5VOi7hMEDPEKFQYkQJX6ZBT1X/+yQvjN X-Gm-Message-State: AOJu0YwRFtUYCGu36LBDAYXWsZafslBPfa6pJWH+mEGV2z9zfVMsQtzh KY0nVAd0+o1JxZkWDCISdWBwnm2eDytzHvfM3GIDxgwwo2SF9XWGmylbkWdI/dxfvM1uvKSX96Q 7 X-Received: by 2002:a17:906:3a9a:b0:a46:2751:1358 with SMTP id y26-20020a1709063a9a00b00a4627511358mr2898595ejd.62.1710236514117; Tue, 12 Mar 2024 02:41:54 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f010900023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f01:900:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id jw22-20020a170906e95600b00a4623030893sm2091961ejb.126.2024.03.12.02.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 02:41:52 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, Max Kellermann Subject: [PATCH v4 05/15] linux/mm.h: move section functions to mm/page_section.h Date: Tue, 12 Mar 2024 10:41:23 +0100 Message-Id: <20240312094133.2084996-6-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312094133.2084996-1-max.kellermann@ionos.com> References: <20240312094133.2084996-1-max.kellermann@ionos.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 Prepare to reduce dependencies on linux/mm.h. page_to_section() is used by __page_to_pfn() (but asm-generic/memory_model.h does not include linux/mm.h). Thus, in order to be able to use anything that calls page_to_pfn(), linux/mm.h needs to be included. This would prevent us from moving page_address() to a separate header, because it calls lowmem_page_address() which in turn calls page_to_virt() and then page_to_pfn(). To prepare for this move, we move page_to_section() out of linux/mm.h into a separate lean header. Signed-off-by: Max Kellermann --- include/linux/mm.h | 18 +----------------- include/linux/mm/page_section.h | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 include/linux/mm/page_section.h diff --git a/include/linux/mm.h b/include/linux/mm.h index e140ee45f49c..79c1f924d4b5 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3,6 +3,7 @@ #define _LINUX_MM_H #include +#include #include #include #include @@ -1637,10 +1638,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_t flags) } #endif -#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) -#define SECTION_IN_PAGE_FLAGS -#endif - /* * The identification function is mainly used by the buddy allocator for * determining if two pages could be buddies. We are not really identifying @@ -1838,19 +1835,6 @@ static inline pg_data_t *folio_pgdat(const struct folio *folio) return page_pgdat(&folio->page); } -#ifdef SECTION_IN_PAGE_FLAGS -static inline void set_page_section(struct page *page, unsigned long section) -{ - page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT); - page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT; -} - -static inline unsigned long page_to_section(const struct page *page) -{ - return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; -} -#endif - /** * folio_pfn - Return the Page Frame Number of a folio. * @folio: The folio. diff --git a/include/linux/mm/page_section.h b/include/linux/mm/page_section.h new file mode 100644 index 000000000000..e4558c2691b8 --- /dev/null +++ b/include/linux/mm/page_section.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_SECTION_H +#define _LINUX_MM_PAGE_SECTION_H + +#include // for struct page +#include // for SECTIONS_* + +#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) +#define SECTION_IN_PAGE_FLAGS + +static inline void set_page_section(struct page *page, unsigned long section) +{ + page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT); + page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT; +} + +static inline unsigned long page_to_section(const struct page *page) +{ + return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; +} +#endif + +#endif /* _LINUX_MM_PAGE_SECTION_H */ -- 2.39.2