[RFC v1 08/19] mm, vmscan: pass pgdat to wakeup_kswapd()

From: Pengfei Li
Date: Thu Nov 21 2019 - 10:20:58 EST


This is a preparation patch. Passing pgdat to wakeup_kswapd() and
avoiding indirect access to pgdat via zone->zone_pgdat.

Signed-off-by: Pengfei Li <fly@xxxxxxxxxxx>
---
include/linux/mmzone.h | 2 +-
mm/page_alloc.c | 4 ++--
mm/vmscan.c | 12 ++++--------
3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index dd493239b8b2..599b30620aa1 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -814,7 +814,7 @@ static inline bool pgdat_is_empty(pg_data_t *pgdat)
#include <linux/memory_hotplug.h>

void build_all_zonelists(pg_data_t *pgdat);
-void wakeup_kswapd(struct zone *zone, gfp_t gfp_mask, int order,
+void wakeup_kswapd(pg_data_t *pgdat, gfp_t gfp_mask, int order,
enum zone_type classzone_idx);
bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
int classzone_idx, unsigned int alloc_flags,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ec5f48b755ff..2dcf2a21c578 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3306,7 +3306,7 @@ struct page *rmqueue(struct zone *preferred_zone,
/* Separate test+clear to avoid unnecessary atomics */
if (test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags)) {
clear_bit(ZONE_BOOSTED_WATERMARK, &zone->flags);
- wakeup_kswapd(zone, 0, 0, zone_idx(zone));
+ wakeup_kswapd(zone->zone_pgdat, 0, 0, zone_idx(zone));
}

VM_BUG_ON_PAGE(page && bad_range(zone, page), page);
@@ -4173,7 +4173,7 @@ static void wake_all_kswapds(unsigned int order, gfp_t gfp_mask,
for_each_zone_nlist_nodemask(zone, &t, ac->nodelist, high_zoneidx,
ac->nodemask) {
if (last_pgdat != zone->zone_pgdat)
- wakeup_kswapd(zone, gfp_mask, order, high_zoneidx);
+ wakeup_kswapd(zone->zone_pgdat, gfp_mask, order, high_zoneidx);
last_pgdat = zone->zone_pgdat;
}
}
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 7554c8ba0841..b5256ef682c2 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3964,17 +3964,13 @@ static int kswapd(void *p)
* has failed or is not needed, still wake up kcompactd if only compaction is
* needed.
*/
-void wakeup_kswapd(struct zone *zone, gfp_t gfp_flags, int order,
+void wakeup_kswapd(pg_data_t *pgdat, gfp_t gfp_flags, int order,
enum zone_type classzone_idx)
{
- pg_data_t *pgdat;
-
- if (!managed_zone(zone))
- return;
+ int node = pgdat->node_id;

- if (!cpuset_zone_allowed(zone, gfp_flags))
+ if (!cpuset_node_allowed(node, gfp_flags))
return;
- pgdat = zone->zone_pgdat;

if (pgdat->kswapd_classzone_idx == MAX_NR_ZONES)
pgdat->kswapd_classzone_idx = classzone_idx;
@@ -4001,7 +3997,7 @@ void wakeup_kswapd(struct zone *zone, gfp_t gfp_flags, int order,
return;
}

- trace_mm_vmscan_wakeup_kswapd(pgdat->node_id, classzone_idx, order,
+ trace_mm_vmscan_wakeup_kswapd(node, classzone_idx, order,
gfp_flags);
wake_up_interruptible(&pgdat->kswapd_wait);
}
--
2.23.0