[PATCH 10/10] mm/vmscan: use unsigned int for "kswapd_order" in struct pglist_data

From: Pengfei Li
Date: Thu Jul 25 2019 - 14:44:57 EST


Because "kswapd_order" will never be negative, so just make it
unsigned int. And modify wakeup_kswapd(), kswapd_try_to_sleep()
and trace_mm_vmscan_kswapd_wake() accordingly.

Besides, make "order" unsigned int in two related trace functions.

Signed-off-by: Pengfei Li <lpf.vector@xxxxxxxxx>
---
include/linux/mmzone.h | 4 ++--
include/trace/events/compaction.h | 10 +++++-----
include/trace/events/vmscan.h | 4 ++--
mm/vmscan.c | 6 +++---
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 60bebdf47661..1196ed0cee67 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -717,7 +717,7 @@ typedef struct pglist_data {
wait_queue_head_t pfmemalloc_wait;
struct task_struct *kswapd; /* Protected by
mem_hotplug_begin/end() */
- int kswapd_order;
+ unsigned int kswapd_order;
enum zone_type kswapd_classzone_idx;

int kswapd_failures; /* Number of 'reclaimed == 0' runs */
@@ -802,7 +802,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(struct zone *zone, gfp_t gfp_mask, unsigned 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/include/trace/events/compaction.h b/include/trace/events/compaction.h
index f83ba40f9614..34a9fac3b4d6 100644
--- a/include/trace/events/compaction.h
+++ b/include/trace/events/compaction.h
@@ -314,13 +314,13 @@ TRACE_EVENT(mm_compaction_kcompactd_sleep,

DECLARE_EVENT_CLASS(kcompactd_wake_template,

- TP_PROTO(int nid, int order, enum zone_type classzone_idx),
+ TP_PROTO(int nid, unsigned int order, enum zone_type classzone_idx),

TP_ARGS(nid, order, classzone_idx),

TP_STRUCT__entry(
__field(int, nid)
- __field(int, order)
+ __field(unsigned int, order)
__field(enum zone_type, classzone_idx)
),

@@ -330,7 +330,7 @@ DECLARE_EVENT_CLASS(kcompactd_wake_template,
__entry->classzone_idx = classzone_idx;
),

- TP_printk("nid=%d order=%d classzone_idx=%-8s",
+ TP_printk("nid=%d order=%u classzone_idx=%-8s",
__entry->nid,
__entry->order,
__print_symbolic(__entry->classzone_idx, ZONE_TYPE))
@@ -338,14 +338,14 @@ DECLARE_EVENT_CLASS(kcompactd_wake_template,

DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,

- TP_PROTO(int nid, int order, enum zone_type classzone_idx),
+ TP_PROTO(int nid, unsigned int order, enum zone_type classzone_idx),

TP_ARGS(nid, order, classzone_idx)
);

DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,

- TP_PROTO(int nid, int order, enum zone_type classzone_idx),
+ TP_PROTO(int nid, unsigned int order, enum zone_type classzone_idx),

TP_ARGS(nid, order, classzone_idx)
);
diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index c37e2280e6dd..13c214f3750b 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -74,7 +74,7 @@ TRACE_EVENT(mm_vmscan_kswapd_wake,

TRACE_EVENT(mm_vmscan_wakeup_kswapd,

- TP_PROTO(int nid, int zid, int order, gfp_t gfp_flags),
+ TP_PROTO(int nid, int zid, unsigned int order, gfp_t gfp_flags),

TP_ARGS(nid, zid, order, gfp_flags),

@@ -92,7 +92,7 @@ TRACE_EVENT(mm_vmscan_wakeup_kswapd,
__entry->gfp_flags = gfp_flags;
),

- TP_printk("nid=%d order=%d gfp_flags=%s",
+ TP_printk("nid=%d order=%u gfp_flags=%s",
__entry->nid,
__entry->order,
show_gfp_flags(__entry->gfp_flags))
diff --git a/mm/vmscan.c b/mm/vmscan.c
index f4fd02ae233e..9d98a2e5f736 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3781,8 +3781,8 @@ static enum zone_type kswapd_classzone_idx(pg_data_t *pgdat,
return pgdat->kswapd_classzone_idx;
}

-static void kswapd_try_to_sleep(pg_data_t *pgdat, int alloc_order, int reclaim_order,
- unsigned int classzone_idx)
+static void kswapd_try_to_sleep(pg_data_t *pgdat, unsigned int alloc_order,
+ unsigned int reclaim_order, unsigned int classzone_idx)
{
long remaining = 0;
DEFINE_WAIT(wait);
@@ -3956,7 +3956,7 @@ 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(struct zone *zone, gfp_t gfp_flags, unsigned int order,
enum zone_type classzone_idx)
{
pg_data_t *pgdat;
--
2.21.0