From: Max Kellermann <max.kellermann@ionos.com>
To: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Cc: willy@infradead.org, sfr@canb.auug.org, david@redhat.com.au,
Max Kellermann <max.kellermann@ionos.com>
Subject: [PATCH v5 09/15] linux/mm.h: move devmap-related declarations to mm/devmap_managed.h
Date: Tue, 30 Apr 2024 17:29:25 +0200 [thread overview]
Message-ID: <20240430152931.1137975-10-max.kellermann@ionos.com> (raw)
In-Reply-To: <20240430152931.1137975-1-max.kellermann@ionos.com>
Prepare to reduce dependencies on linux/mm.h.
put_devmap_managed_page() is called by put_page(). Moving it to a
separate header allows us to move put_page() to a separate lean header
as well.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
include/linux/mm.h | 20 +------------------
include/linux/mm/devmap_managed.h | 32 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 19 deletions(-)
create mode 100644 include/linux/mm/devmap_managed.h
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5b3d56454344..9539ba12b99d 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2,6 +2,7 @@
#ifndef _LINUX_MM_H
#define _LINUX_MM_H
+#include <linux/mm/devmap_managed.h>
#include <linux/mm/folio_next.h>
#include <linux/mm/folio_size.h>
#include <linux/mm/page_address.h>
@@ -1364,25 +1365,6 @@ vm_fault_t finish_fault(struct vm_fault *vmf);
* back into memory.
*/
-#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX)
-DECLARE_STATIC_KEY_FALSE(devmap_managed_key);
-
-bool __put_devmap_managed_folio_refs(struct folio *folio, int refs);
-static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs)
-{
- if (!static_branch_unlikely(&devmap_managed_key))
- return false;
- if (!folio_is_zone_device(folio))
- return false;
- return __put_devmap_managed_folio_refs(folio, refs);
-}
-#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */
-static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs)
-{
- return false;
-}
-#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */
-
/* 127: arbitrary random number, small enough to assemble well */
#define folio_ref_zero_or_close_to_overflow(folio) \
((unsigned int) folio_ref_count(folio) + 127u <= 127u)
diff --git a/include/linux/mm/devmap_managed.h b/include/linux/mm/devmap_managed.h
new file mode 100644
index 000000000000..50357b304d68
--- /dev/null
+++ b/include/linux/mm/devmap_managed.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_MM_DEVMAP_MANAGED_H
+#define _LINUX_MM_DEVMAP_MANAGED_H
+
+#include <linux/types.h> // for bool
+
+struct page;
+
+#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX)
+
+#include <linux/jump_label.h> // for DECLARE_STATIC_KEY_FALSE(), static_branch_unlikely()
+#include <linux/mmzone.h> // folio_is_zone_device()
+
+DECLARE_STATIC_KEY_FALSE(devmap_managed_key);
+
+bool __put_devmap_managed_folio_refs(struct folio *folio, int refs);
+static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs)
+{
+ if (!static_branch_unlikely(&devmap_managed_key))
+ return false;
+ if (!folio_is_zone_device(folio))
+ return false;
+ return __put_devmap_managed_folio_refs(folio, refs);
+}
+#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */
+static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs)
+{
+ return false;
+}
+#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */
+
+#endif /* _LINUX_MM_DEVMAP_MANAGED_H */
--
2.39.2
next prev parent reply other threads:[~2024-04-30 15:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 15:29 [PATCH v5 00/15] Fast kernel headers: split linux/mm.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 01/15] drivers: add missing includes on linux/mm.h (and others) Max Kellermann
2024-04-30 15:29 ` [PATCH v5 02/15] include/drm/drm_gem.h: add poll_table_struct forward declaration Max Kellermann
2024-04-30 15:29 ` [PATCH v5 03/15] include/scsi/scsicam.h: forward-declare struct block_device Max Kellermann
2024-04-30 15:29 ` [PATCH v5 04/15] linux/mm.h: move page_kasan_tag() to mm/page_kasan_tag.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 05/15] linux/mm.h: move section functions to mm/page_section.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 06/15] linux/mm.h: move page_address() and others to mm/page_address.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 07/15] linux/mm.h: move folio_size(), ... to mm/folio_size.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 08/15] linux/mm.h: move folio_next() to mm/folio_next.h Max Kellermann
2024-04-30 15:29 ` Max Kellermann [this message]
2024-04-30 15:29 ` [PATCH v5 10/15] linux/mm.h: move usage count functions to mm/folio_usage.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 11/15] linux/mm.h: move page_zone_id() and more to mm/folio_zone.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 12/15] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 13/15] linux/mm.h: move is_vmalloc_addr() to mm/vmalloc_addr.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 14/15] linux/mm.h: move high_memory to mm/high_memory.h Max Kellermann
2024-04-30 15:29 ` [PATCH v5 15/15] include: reduce dependencies on linux/mm.h Max Kellermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240430152931.1137975-10-max.kellermann@ionos.com \
--to=max.kellermann@ionos.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sfr@canb.auug.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox