From patchwork Tue Jun 4 09:08:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13684917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40E0CC25B78 for ; Tue, 4 Jun 2024 09:09:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E177F6B0099; Tue, 4 Jun 2024 05:09:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9D556B009A; Tue, 4 Jun 2024 05:09:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C18306B009C; Tue, 4 Jun 2024 05:09:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A1FF36B0099 for ; Tue, 4 Jun 2024 05:09:16 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 16AA3C0AA1 for ; Tue, 4 Jun 2024 09:09:16 +0000 (UTC) X-FDA: 82192632312.09.8CF7CC5 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf12.hostedemail.com (Postfix) with ESMTP id 3AFBF40016 for ; Tue, 4 Jun 2024 09:09:14 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=MD+MFvyt; dmarc=pass (policy=quarantine) header.from=ionos.com; spf=pass (imf12.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717492154; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5ugwYiQRh7gsSZKM5f9fZEfiERzaZSJH9xrcJo+enM8=; b=hyAxIzcUH1yvTb79DBxcQvlQGImRqnIdLyHviggA1iV0sepegHCr/V6S7hQKm4ovyAaLJn 59gXHziMs+Vhn+1bB86eWetm3Nlr2iQaY41lXF78pRsYmucBkcD9hx1Z0oI6bdh7jl24lk jZK4OSu+k7BwnkwxENbu57y7FqYdEj0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=MD+MFvyt; dmarc=pass (policy=quarantine) header.from=ionos.com; spf=pass (imf12.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717492154; a=rsa-sha256; cv=none; b=Pox+LDbb0yfGICCpLRMndaCOhVlv01fhL37cdT0QN3p58sICeiU+OLppAkyvp+lh8iMIVQ Q2zpTR39YHmy7iyUmMiORUzxpCIctW4oDvh/64+nMqrzjTxCL78Z3U+NRPVyTW4S3YBxn+ ZC56THPvw//dYdW1QvR+U0ziMsFTZWo= Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a68e7538cfaso285630166b.0 for ; Tue, 04 Jun 2024 02:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492153; x=1718096953; darn=kvack.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=5ugwYiQRh7gsSZKM5f9fZEfiERzaZSJH9xrcJo+enM8=; b=MD+MFvytsnec1UGl/eVx9PbNw+MfufmEllJ8xHUjHZHrAGH6vpoE5SQKkJTXLIJgCT AJXWWvtVS9W9uKXP7pSniZZcizoIuqXPW/EW4b0TdMXpN7uHaRlggiCE2Ubnl8Av7wW9 jGB/m10J9MmnB+JvyDygsdsacpF9mgP8BEhru1kRVw5a49P2a8Wbq7xEne1EdBaUyOzC GN19f5ewxjPc8L4CyQsT4w6FpOUPTcRdV4SM0AvL1VsDAHnzWK8I4dBELkMQgvYCbEPx 5ZRy1NTHVcvRmlnj6Zm6FD0NfamKhnfWuOpY7eMelNCGKGAnQJ7FY8FRksL2Dc5al+2w aVow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492153; x=1718096953; 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=5ugwYiQRh7gsSZKM5f9fZEfiERzaZSJH9xrcJo+enM8=; b=Bnzy5tdAUBbWvx2S7a8VZ7/6r1GgGRcqLhOG5BUIYR8RoTvZ9gfvU9X4555Q14/S0v io2ZtVH1F3Y55hs7hdOl8E2Rz6W9XY4pfoquvJ6uD8SHllavkrSfSn8EHTBpPvGh82sA ednLsxaJ+lyWhKE9eXJlAdKyD0kpylgKGZCo/G65/1ruzHnrMDstS7A6GMf0B9UvPIeU jRm3uf4oPnpklxf7ai6hPTTGujkC3tbeAFMfhcsz04n3DDRtKxgYCeLvzaz9a/gZ0Dy/ X3bGBjQGgBV5kluxW3JES0QKbtmKBri/yYtJUDtLu+6dcbsWUcalUV1N8OsN2hEdngb+ ZAbg== X-Forwarded-Encrypted: i=1; AJvYcCWyejtriqO3hwTmb/LqFiJlvRE6dvBblIgr+i+/+X5Q/ffoj2sc7V2cQWIhjJ/hBL4sqAMIHkzN1EkWIWY8z/Li48E= X-Gm-Message-State: AOJu0YxFRa2YlFQllHS5iqkv8WCMC0bOKJTeFH7DUL8CPJELYFwWpXZ7 nq02TZlWk4SZbKgFqfWTgD4W1ANqGh0J0CMX0qwV+fkkmopVbbf5q8kbn2G3z1k4BLNtYFS/DQ/ ayz4= X-Google-Smtp-Source: AGHT+IHuYP1ufnXMMmWaJJ03GHA9WgouemhQpCjHhbIXLQh1XyAq6YAVOglv63VcXHv+oaxWEjtZQA== X-Received: by 2002:a17:907:9725:b0:a68:fafc:659 with SMTP id a640c23a62f3a-a68fafc0807mr430280566b.29.1717492152699; Tue, 04 Jun 2024 02:09:12 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:11 -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, david@redhat.com, Max Kellermann Subject: [PATCH v6 05/15] linux/mm.h: move section functions to mm/page_section.h Date: Tue, 4 Jun 2024 11:08:35 +0200 Message-Id: <20240604090845.2182265-6-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3AFBF40016 X-Stat-Signature: b7n4gtfihc4jimgwmnzu9apsnbi8unpa X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1717492154-233213 X-HE-Meta: U2FsdGVkX19/MZd1DVsUQ0lk8Qfo1h17gcOp+oI9gxKPjifsoPsVpg/kK2AYtxCTqa/9utrMSW3TiPQo9/p2S5Rv8vPlMm7H0fXUj2exQRiDrSA7oPsGY9V4Pv8jaqci/64NO+3UvAij7Os2B1oUbXnMTOckIz/+MXc0zL8vlzbdrU2yGHzx2sCWxWs9r5qS/YdyZ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uiHo6L25r3Al2wGk60ZQoDyaMjmvyOT6HoCBZmDIvqO3AIxphAqUZxmcdUHP8Cx+P+b+UH/x+I5VWByox2AkTMCcH3YTtgg0/V7HF1cGc272zTPLQ8DLg6SIaNS8vrdlYSyrjtxCbGoDFZYbLzU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 3ff239992d4c..c9a3f1c0ae07 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3,6 +3,7 @@ #define _LINUX_MM_H #include +#include #include #include #include @@ -1631,10 +1632,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 @@ -1832,19 +1829,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 */