From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>, Baoquan He <bhe@redhat.com>
Subject: [PATCH -next] mm: page_alloc: simplify has_managed_dma()
Date: Mon, 29 May 2023 22:40:22 +0800 [thread overview]
Message-ID: <20230529144022.42927-1-wangkefeng.wang@huawei.com> (raw)
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
next reply other threads:[~2023-05-29 14:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 14:40 Kefeng Wang [this message]
2023-05-29 14:26 ` [PATCH -next] mm: page_alloc: simplify has_managed_dma() Matthew Wilcox
2023-05-30 2:10 ` Kefeng Wang
2023-05-30 4:18 ` Baoquan He
2023-05-30 6:40 ` Kefeng Wang
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=20230529144022.42927-1-wangkefeng.wang@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).