linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mm: page_alloc: simplify has_managed_dma()
@ 2023-05-29 14:40 Kefeng Wang
  2023-05-29 14:26 ` Matthew Wilcox
  0 siblings, 1 reply; 5+ messages in thread
From: Kefeng Wang @ 2023-05-29 14:40 UTC (permalink / raw)
  To: Andrew Morton, linux-mm, linux-kernel; +Cc: Kefeng Wang, Baoquan He

The ZONE_DMA should only exists on Node 0, only check NODE_DATA(0)
is enough, so simplify has_managed_dma() and make it inline.

Cc: Baoquan He <bhe@redhat.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 include/linux/mmzone.h | 21 +++++++++++----------
 mm/page_alloc.c        | 15 ---------------
 2 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 5a7ada0413da..48e9fd8eccb4 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1503,16 +1503,6 @@ static inline int is_highmem(struct zone *zone)
 	return is_highmem_idx(zone_idx(zone));
 }
 
-#ifdef CONFIG_ZONE_DMA
-bool has_managed_dma(void);
-#else
-static inline bool has_managed_dma(void)
-{
-	return false;
-}
-#endif
-
-
 #ifndef CONFIG_NUMA
 
 extern struct pglist_data contig_page_data;
@@ -1527,6 +1517,17 @@ static inline struct pglist_data *NODE_DATA(int nid)
 
 #endif /* !CONFIG_NUMA */
 
+static inline bool has_managed_dma(void)
+{
+#ifdef CONFIG_ZONE_DMA
+	struct zone *zone = NODE_DATA(0)->node_zones + ZONE_DMA;
+
+	if (managed_zone(zone))
+		return true;
+#endif
+	return false;
+}
+
 extern struct pglist_data *first_online_pgdat(void);
 extern struct pglist_data *next_online_pgdat(struct pglist_data *pgdat);
 extern struct zone *next_zone(struct zone *zone);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e671c747892f..e847b39939b8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6613,18 +6613,3 @@ bool put_page_back_buddy(struct page *page)
 	return ret;
 }
 #endif
-
-#ifdef CONFIG_ZONE_DMA
-bool has_managed_dma(void)
-{
-	struct pglist_data *pgdat;
-
-	for_each_online_pgdat(pgdat) {
-		struct zone *zone = &pgdat->node_zones[ZONE_DMA];
-
-		if (managed_zone(zone))
-			return true;
-	}
-	return false;
-}
-#endif /* CONFIG_ZONE_DMA */
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-30  6:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-29 14:40 [PATCH -next] mm: page_alloc: simplify has_managed_dma() Kefeng Wang
2023-05-29 14:26 ` Matthew Wilcox
2023-05-30  2:10   ` Kefeng Wang
2023-05-30  4:18     ` Baoquan He
2023-05-30  6:40       ` Kefeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).