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>] [day] [month] [year] [list]
Message-Id: <20221101023219.752365-1-yajun.deng@linux.dev>
Date:   Tue,  1 Nov 2022 10:32:19 +0800
From:   Yajun Deng <yajun.deng@...ux.dev>
To:     akpm@...ux-foundation.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Yajun Deng <yajun.deng@...ux.dev>
Subject: [PATCH] mm: simplify page_zone() and get_deferred_split_queue() with page_pgdat()

page_zone() is too long, we can shorten it by page_pgdat().

There is no need define pgdat variable if memcg isn't NULL, so use
page_pgdat() to simplify get_deferred_split_queue().

Signed-off-by: Yajun Deng <yajun.deng@...ux.dev>
---
 include/linux/mm.h | 8 ++++----
 mm/huge_memory.c   | 7 ++-----
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 978c17df053e..25ff9a14a777 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1448,14 +1448,14 @@ static inline void page_kasan_tag_reset(struct page *page) { }
 
 #endif /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */
 
-static inline struct zone *page_zone(const struct page *page)
+static inline pg_data_t *page_pgdat(const struct page *page)
 {
-	return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)];
+	return NODE_DATA(page_to_nid(page));
 }
 
-static inline pg_data_t *page_pgdat(const struct page *page)
+static inline struct zone *page_zone(const struct page *page)
 {
-	return NODE_DATA(page_to_nid(page));
+	return &page_pgdat(page)->node_zones[page_zonenum(page)];
 }
 
 static inline struct zone *folio_zone(const struct folio *folio)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 1ed245f6d1a7..a524db74e9e6 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -562,19 +562,16 @@ pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma)
 static inline struct deferred_split *get_deferred_split_queue(struct page *page)
 {
 	struct mem_cgroup *memcg = page_memcg(compound_head(page));
-	struct pglist_data *pgdat = NODE_DATA(page_to_nid(page));
 
 	if (memcg)
 		return &memcg->deferred_split_queue;
 	else
-		return &pgdat->deferred_split_queue;
+		return &page_pgdat(page)->deferred_split_queue;
 }
 #else
 static inline struct deferred_split *get_deferred_split_queue(struct page *page)
 {
-	struct pglist_data *pgdat = NODE_DATA(page_to_nid(page));
-
-	return &pgdat->deferred_split_queue;
+	return &page_pgdat(page)->deferred_split_queue;
 }
 #endif
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ