lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230529144022.42927-1-wangkefeng.wang@huawei.com>
Date:   Mon, 29 May 2023 22:40:22 +0800
From:   Kefeng Wang <wangkefeng.wang@...wei.com>
To:     Andrew Morton <akpm@...ux-foundation.org>, <linux-mm@...ck.org>,
        <linux-kernel@...r.kernel.org>
CC:     Kefeng Wang <wangkefeng.wang@...wei.com>,
        Baoquan He <bhe@...hat.com>
Subject: [PATCH -next] mm: page_alloc: simplify has_managed_dma()

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@...hat.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ