Skip to contentSkip to conversation

mm/vmstat: Add events for HugeTLB migration

RFC In review Anshuman Khandual 4 participants 10 messages Sep 30, 2020 – Oct 6, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

RFC v2 1/1 mm/vmstat: Add events for HugeTLB migration

Add following new vmstat events which will track HugeTLB page migration.

1. HUGETLB_MIGRATION_SUCCESS
2. HUGETLB_MIGRATION_FAILURE

It follows the existing semantics to accommodate HugeTLB subpages in total page migration statistics. While here, this updates current trace event 'mm_migrate_pages' to accommodate now available HugeTLB based statistics.

Cc Daniel Jordan <[email protected]>
Cc Zi Yan <[email protected]>
Cc John Hubbard <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Andrew Morton <[email protected]>

---
Applies on linux-next and v5.9-rc7.

Changes in RFC V2:

- Added the missing hugetlb_retry in the loop per Oscar
- Changed HugeTLB and THP detection sequence per Mike
- Changed nr_subpages fetch from compound_nr() instead per Mike

Changes in RFC V1: (https://patchwork.kernel.org/patch/11799395/)

 include/linux/vm_event_item.h  |  2 ++
 include/trace/events/migrate.h | 13 ++++++---
 mm/migrate.c                   | 48 +++++++++++++++++++++++++++++-----
 mm/vmstat.c                    |  2 ++
 4 files changed, 56 insertions(+), 9 deletions(-)
include/linux/vm_event_item.h +2 -0
index 18e75974d4e3..d1ddad835c19 100644
@@ -60,6 +60,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		THP_MIGRATION_SUCCESS,
 		THP_MIGRATION_FAIL,
 		THP_MIGRATION_SPLIT,
+		HUGETLB_MIGRATION_SUCCESS,
+		HUGETLB_MIGRATION_FAIL,
 #endif
 #ifdef CONFIG_COMPACTION
 		COMPACTMIGRATE_SCANNED, COMPACTFREE_SCANNED,
include/trace/events/migrate.h +10 -3
index 4d434398d64d..f8ffb8aece48 100644
@@ -47,10 +47,11 @@ TRACE_EVENT(mm_migrate_pages,
 
 	TP_PROTO(unsigned long succeeded, unsigned long failed,
 		 unsigned long thp_succeeded, unsigned long thp_failed,
-		 unsigned long thp_split, enum migrate_mode mode, int reason),
+		 unsigned long thp_split, unsigned long hugetlb_succeeded,
+		 unsigned long hugetlb_failed, enum migrate_mode mode, int reason),
 
 	TP_ARGS(succeeded, failed, thp_succeeded, thp_failed,
-		thp_split, mode, reason),
+		thp_split, hugetlb_succeeded, hugetlb_failed, mode, reason),
 
 	TP_STRUCT__entry(
 		__field(	unsigned long,		succeeded)
@@ -58,6 +59,8 @@ TRACE_EVENT(mm_migrate_pages,
 		__field(	unsigned long,		thp_succeeded)
 		__field(	unsigned long,		thp_failed)
 		__field(	unsigned long,		thp_split)
+		__field(	unsigned long,		hugetlb_succeeded)
+		__field(	unsigned long,		hugetlb_failed)
 		__field(	enum migrate_mode,	mode)
 		__field(	int,			reason)
 	),
@@ -68,16 +71,20 @@ TRACE_EVENT(mm_migrate_pages,
 		__entry->thp_succeeded	= thp_succeeded;
 		__entry->thp_failed	= thp_failed;
 		__entry->thp_split	= thp_split;
+		__entry->hugetlb_succeeded	= hugetlb_succeeded;
+		__entry->hugetlb_failed		= hugetlb_failed;
 		__entry->mode		= mode;
 		__entry->reason		= reason;
 	),
 
-	TP_printk("nr_succeeded=%lu nr_failed=%lu nr_thp_succeeded=%lu nr_thp_failed=%lu nr_thp_split=%lu mode=%s reason=%s",
+	TP_printk("nr_succeeded=%lu nr_failed=%lu nr_thp_succeeded=%lu nr_thp_failed=%lu nr_thp_split=%lu nr_hugetlb_succeeded=%lu nr_hugetlb_failed=%lu mode=%s reason=%s",
 		__entry->succeeded,
 		__entry->failed,
 		__entry->thp_succeeded,
 		__entry->thp_failed,
 		__entry->thp_split,
+		__entry->hugetlb_succeeded,
+		__entry->hugetlb_failed,
 		__print_symbolic(__entry->mode, MIGRATE_MODE),
 		__print_symbolic(__entry->reason, MIGRATE_REASON))
 );
mm/migrate.c +42 -6

114 lines not on this page · raw message

mm/vmstat.c +2 -0
index 79e5cd0abd0e..12fd35ba135f 100644
@@ -1286,6 +1286,8 @@ const char * const vmstat_text[] = {
 	"thp_migration_success",
 	"thp_migration_fail",
 	"thp_migration_split",
+	"hugetlb_migration_success",
+	"hugetlb_migration_fail",
 #endif
 #ifdef CONFIG_COMPACTION
 	"compact_migrate_scanned",
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw

mm/migrate.c int migrate_pages(struct list_head *from, new_page_t get_new_page, · line 1456

Quoted 10 lines · Anshuman Khandual
mm/migrate.c +8 -2
-			is_thp = PageTransHuge(page) && !PageHuge(page);
-			nr_subpages = thp_nr_pages(page);
+			is_thp = false;
+			is_hugetlb = false;
+			if (PageTransHuge(page)) {
+				if (PageHuge(page))
+					is_hugetlb = true;
+				else
+					is_thp = true;
+			}

Since PageHuge only returns true for hugetlb pages, I think the following is more simple?

if (PageHuge(page))
is_hugetlb = true;
else if (PageTransHuge(page))
is_thp = true

Besides that, it looks good to me:

Signature · 2 lines
Oscar Salvador
SUSE L3
#2 lore raw
Quoted 15 lines · Oscar Salvador

mm/migrate.c int migrate_pages(struct list_head *from, new_page_t get_new_page, · line 1456

Quoted 10 lines · Anshuman Khandual
mm/migrate.c +8 -2
-			is_thp = PageTransHuge(page) && !PageHuge(page);
-			nr_subpages = thp_nr_pages(page);
+			is_thp = false;
+			is_hugetlb = false;
+			if (PageTransHuge(page)) {
+				if (PageHuge(page))
+					is_hugetlb = true;
+				else
+					is_thp = true;
+			}

Since PageHuge only returns true for hugetlb pages, I think the following is more simple?

Quoted 4 lines

if (PageHuge(page))
is_hugetlb = true;
else if (PageTransHuge(page))
is_thp = true

Right, it would be simple. But as Mike had mentioned before PageHuge() check is more expensive than PageTransHuge(). This proposal just tries not to call PageHuge() unless the page first clears PageTransHuge(), saving some potential CPU cycles on normal pages.

Quoted 6 lines

Besides that, it looks good to me:

#3 lore raw
Quoted 4 lines · Anshuman Khandual

Right, it would be simple. But as Mike had mentioned before PageHuge() check is more expensive than PageTransHuge(). This proposal just tries not to call PageHuge() unless the page first clears PageTransHuge(), saving some potential CPU cycles on normal pages.

Ah, I remember now.
I missed that, sorry.

Signature · 2 lines
Oscar Salvador
SUSE L3
Reviewed-by on v2 1/1
#4 lore raw
In reply to Anshuman Khandual
Quoted 9 lines · Anshuman Khandual

Add following new vmstat events which will track HugeTLB page migration.

1. HUGETLB_MIGRATION_SUCCESS
2. HUGETLB_MIGRATION_FAILURE

It follows the existing semantics to accommodate HugeTLB subpages in total page migration statistics. While here, this updates current trace event 'mm_migrate_pages' to accommodate now available HugeTLB based statistics.

Quoted 9 lines
Cc Daniel Jordan <[email protected]>
Cc Zi Yan <[email protected]>
Cc John Hubbard <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Andrew Morton <[email protected]>

Thanks,

Signature · 1 line
Mike Kravetz
reviewer
#5 lore raw
In reply to Anshuman Khandual
Quoted 8 lines · Anshuman Khandual

Add following new vmstat events which will track HugeTLB page migration.

1. HUGETLB_MIGRATION_SUCCESS
2. HUGETLB_MIGRATION_FAILURE

It follows the existing semantics to accommodate HugeTLB subpages in total page migration statistics. While here, this updates current trace event 'mm_migrate_pages' to accommodate now available HugeTLB based statistics.

What is the actual usecase? And how do you deal with the complexity introduced by many different hugetlb page sizes. Really, what is the point to having such a detailed view on hugetlb migration?

Quoted 231 lines
Cc Daniel Jordan <[email protected]>
Cc Zi Yan <[email protected]>
Cc John Hubbard <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Andrew Morton <[email protected]>

---
Applies on linux-next and v5.9-rc7.

Changes in RFC V2:

- Added the missing hugetlb_retry in the loop per Oscar
- Changed HugeTLB and THP detection sequence per Mike
- Changed nr_subpages fetch from compound_nr() instead per Mike

Changes in RFC V1: (https://patchwork.kernel.org/patch/11799395/)

 include/linux/vm_event_item.h  |  2 ++
 include/trace/events/migrate.h | 13 ++++++---
 mm/migrate.c                   | 48 +++++++++++++++++++++++++++++-----
 mm/vmstat.c                    |  2 ++
 4 files changed, 56 insertions(+), 9 deletions(-)
include/linux/vm_event_item.h +2 -0
index 18e75974d4e3..d1ddad835c19 100644
@@ -60,6 +60,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		THP_MIGRATION_SUCCESS,
 		THP_MIGRATION_FAIL,
 		THP_MIGRATION_SPLIT,
+		HUGETLB_MIGRATION_SUCCESS,
+		HUGETLB_MIGRATION_FAIL,
 #endif
 #ifdef CONFIG_COMPACTION
 		COMPACTMIGRATE_SCANNED, COMPACTFREE_SCANNED,
include/trace/events/migrate.h +10 -3
index 4d434398d64d..f8ffb8aece48 100644
@@ -47,10 +47,11 @@ TRACE_EVENT(mm_migrate_pages,
 
 	TP_PROTO(unsigned long succeeded, unsigned long failed,
 		 unsigned long thp_succeeded, unsigned long thp_failed,
-		 unsigned long thp_split, enum migrate_mode mode, int reason),
+		 unsigned long thp_split, unsigned long hugetlb_succeeded,
+		 unsigned long hugetlb_failed, enum migrate_mode mode, int reason),
 
 	TP_ARGS(succeeded, failed, thp_succeeded, thp_failed,
-		thp_split, mode, reason),
+		thp_split, hugetlb_succeeded, hugetlb_failed, mode, reason),
 
 	TP_STRUCT__entry(
 		__field(	unsigned long,		succeeded)
@@ -58,6 +59,8 @@ TRACE_EVENT(mm_migrate_pages,
 		__field(	unsigned long,		thp_succeeded)
 		__field(	unsigned long,		thp_failed)
 		__field(	unsigned long,		thp_split)
+		__field(	unsigned long,		hugetlb_succeeded)
+		__field(	unsigned long,		hugetlb_failed)
 		__field(	enum migrate_mode,	mode)
 		__field(	int,			reason)
 	),
@@ -68,16 +71,20 @@ TRACE_EVENT(mm_migrate_pages,
 		__entry->thp_succeeded	= thp_succeeded;
 		__entry->thp_failed	= thp_failed;
 		__entry->thp_split	= thp_split;
+		__entry->hugetlb_succeeded	= hugetlb_succeeded;
+		__entry->hugetlb_failed		= hugetlb_failed;
 		__entry->mode		= mode;
 		__entry->reason		= reason;
 	),
 
-	TP_printk("nr_succeeded=%lu nr_failed=%lu nr_thp_succeeded=%lu nr_thp_failed=%lu nr_thp_split=%lu mode=%s reason=%s",
+	TP_printk("nr_succeeded=%lu nr_failed=%lu nr_thp_succeeded=%lu nr_thp_failed=%lu nr_thp_split=%lu nr_hugetlb_succeeded=%lu nr_hugetlb_failed=%lu mode=%s reason=%s",
 		__entry->succeeded,
 		__entry->failed,
 		__entry->thp_succeeded,
 		__entry->thp_failed,
 		__entry->thp_split,
+		__entry->hugetlb_succeeded,
+		__entry->hugetlb_failed,
 		__print_symbolic(__entry->mode, MIGRATE_MODE),
 		__print_symbolic(__entry->reason, MIGRATE_REASON))
 );
mm/migrate.c +42 -6
index 5ca5842df5db..0aac9d39778c 100644
@@ -1415,13 +1415,17 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 {
 	int retry = 1;
 	int thp_retry = 1;
+	int hugetlb_retry = 1;
 	int nr_failed = 0;
 	int nr_succeeded = 0;
 	int nr_thp_succeeded = 0;
 	int nr_thp_failed = 0;
 	int nr_thp_split = 0;
+	int nr_hugetlb_succeeded = 0;
+	int nr_hugetlb_failed = 0;
 	int pass = 0;
 	bool is_thp = false;
+	bool is_hugetlb = false;
 	struct page *page;
 	struct page *page2;
 	int swapwrite = current->flags & PF_SWAPWRITE;
@@ -1430,9 +1434,10 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 	if (!swapwrite)
 		current->flags |= PF_SWAPWRITE;
 
-	for (pass = 0; pass < 10 && (retry || thp_retry); pass++) {
+	for (pass = 0; pass < 10 && (retry || thp_retry || hugetlb_retry); pass++) {
 		retry = 0;
 		thp_retry = 0;
+		hugetlb_retry = 0;
 
 		list_for_each_entry_safe(page, page2, from, lru) {
 retry:
@@ -1441,11 +1446,19 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 			 * Capture required information that might get lost
 			 * during migration.
 			 */
-			is_thp = PageTransHuge(page) && !PageHuge(page);
-			nr_subpages = thp_nr_pages(page);
+			is_thp = false;
+			is_hugetlb = false;
+			if (PageTransHuge(page)) {
+				if (PageHuge(page))
+					is_hugetlb = true;
+				else
+					is_thp = true;
+			}
+			nr_subpages = compound_nr(page);
+
 			cond_resched();
 
-			if (PageHuge(page))
+			if (is_hugetlb)
 				rc = unmap_and_move_huge_page(get_new_page,
 						put_new_page, private, page,
 						pass > 2, mode, reason);
@@ -1481,6 +1494,11 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 					nr_failed += nr_subpages;
 					goto out;
 				}
+				if (is_hugetlb) {
+					nr_hugetlb_failed++;
+					nr_failed += nr_subpages;
+					goto out;
+				}
 				nr_failed++;
 				goto out;
 			case -EAGAIN:
@@ -1488,6 +1506,10 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 					thp_retry++;
 					break;
 				}
+				if (is_hugetlb) {
+					hugetlb_retry++;
+					break;
+				}
 				retry++;
 				break;
 			case MIGRATEPAGE_SUCCESS:
@@ -1496,6 +1518,11 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 					nr_succeeded += nr_subpages;
 					break;
 				}
+				if (is_hugetlb) {
+					nr_hugetlb_succeeded++;
+					nr_succeeded += nr_subpages;
+					break;
+				}
 				nr_succeeded++;
 				break;
 			default:
@@ -1510,13 +1537,19 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 					nr_failed += nr_subpages;
 					break;
 				}
+				if (is_hugetlb) {
+					nr_hugetlb_failed++;
+					nr_failed += nr_subpages;
+					break;
+				}
 				nr_failed++;
 				break;
 			}
 		}
 	}
-	nr_failed += retry + thp_retry;
+	nr_failed += retry + thp_retry + hugetlb_retry;
 	nr_thp_failed += thp_retry;
+	nr_hugetlb_failed += hugetlb_retry;
 	rc = nr_failed;
 out:
 	count_vm_events(PGMIGRATE_SUCCESS, nr_succeeded);
@@ -1524,8 +1557,11 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
 	count_vm_events(THP_MIGRATION_SUCCESS, nr_thp_succeeded);
 	count_vm_events(THP_MIGRATION_FAIL, nr_thp_failed);
 	count_vm_events(THP_MIGRATION_SPLIT, nr_thp_split);
+	count_vm_events(HUGETLB_MIGRATION_SUCCESS, nr_hugetlb_succeeded);
+	count_vm_events(HUGETLB_MIGRATION_FAIL, nr_hugetlb_failed);
 	trace_mm_migrate_pages(nr_succeeded, nr_failed, nr_thp_succeeded,
-			       nr_thp_failed, nr_thp_split, mode, reason);
+			       nr_thp_failed, nr_thp_split, nr_hugetlb_succeeded,
+			       nr_hugetlb_failed, mode, reason);
 
 	if (!swapwrite)
 		current->flags &= ~PF_SWAPWRITE;
mm/vmstat.c +2 -0
index 79e5cd0abd0e..12fd35ba135f 100644
@@ -1286,6 +1286,8 @@ const char * const vmstat_text[] = {
 	"thp_migration_success",
 	"thp_migration_fail",
 	"thp_migration_split",
+	"hugetlb_migration_success",
+	"hugetlb_migration_fail",
 #endif
 #ifdef CONFIG_COMPACTION
 	"compact_migrate_scanned",
Signature · 1 line
2.20.1
Signature · 2 lines
Michal Hocko
SUSE Labs
#6 lore raw
Quoted 6 lines · Michal Hocko
Quoted 5 lines · Anshuman Khandual

Add following new vmstat events which will track HugeTLB page migration.

1. HUGETLB_MIGRATION_SUCCESS
2. HUGETLB_MIGRATION_FAILURE

Quoted 7 lines
Quoted 3 lines

It follows the existing semantics to accommodate HugeTLB subpages in total page migration statistics. While here, this updates current trace event 'mm_migrate_pages' to accommodate now available HugeTLB based statistics.

What is the actual usecase? And how do you deal with the complexity introduced by many different hugetlb page sizes. Really, what is the point to having such a detailed view on hugetlb migration?

It helps differentiate various page migration events i.e normal, THP and HugeTLB and gives us more reliable and accurate measurement. Current stats as per PGMIGRATE_SUCCESS and PGMIGRATE_FAIL are misleading, as they contain both normal and HugeTLB pages as single entities, which is not accurate.

After this change, PGMIGRATE_SUCCESS and PGMIGRATE_FAIL will contain page migration statistics in terms of normal pages irrespective of whether any previous migrations until that point involved normal pages, THP or HugeTLB (any size) pages. At the least, this fixes existing misleading stats with PGMIGRATE_SUCCESS and PGMIGRATE_FAIL.

Besides, it helps us understand HugeTLB migrations in more detail. Even though HugeTLB can be of various sizes on a given platform, these new stats HUGETLB_MIGRATION_SUCCESS and HUGETLB_MIGRATION_FAILURE give enough overall insight into HugeTLB migration events.

Though these new stats accumulate HugeTLB migration success and failure irrespective of their size, it will still be helpful as HugeTLB is user driven, who should be able to decipher these accumulated stats. But this is a limitation, as it might be difficult to determine available HugeTLB sizes at compile time.

reviewer
#7 lore raw
Quoted 17 lines · Anshuman Khandual
Quoted 6 lines · Michal Hocko
Quoted 5 lines · Anshuman Khandual

Add following new vmstat events which will track HugeTLB page migration.

1. HUGETLB_MIGRATION_SUCCESS
2. HUGETLB_MIGRATION_FAILURE

Quoted 7 lines
Quoted 3 lines

It follows the existing semantics to accommodate HugeTLB subpages in total page migration statistics. While here, this updates current trace event 'mm_migrate_pages' to accommodate now available HugeTLB based statistics.

What is the actual usecase? And how do you deal with the complexity introduced by many different hugetlb page sizes. Really, what is the point to having such a detailed view on hugetlb migration?

Quoted 4 lines

It helps differentiate various page migration events i.e normal, THP and HugeTLB and gives us more reliable and accurate measurement. Current stats as per PGMIGRATE_SUCCESS and PGMIGRATE_FAIL are misleading, as they contain both normal and HugeTLB pages as single entities, which is not accurate.

Yes this is true. But why does it really matter? Do you have a specific example?

Quoted 10 lines

After this change, PGMIGRATE_SUCCESS and PGMIGRATE_FAIL will contain page migration statistics in terms of normal pages irrespective of whether any previous migrations until that point involved normal pages, THP or HugeTLB (any size) pages. At the least, this fixes existing misleading stats with PGMIGRATE_SUCCESS and PGMIGRATE_FAIL.

Besides, it helps us understand HugeTLB migrations in more detail. Even though HugeTLB can be of various sizes on a given platform, these new stats HUGETLB_MIGRATION_SUCCESS and HUGETLB_MIGRATION_FAILURE give enough overall insight into HugeTLB migration events.

While true this all is way too vague to add yet another imprecise counter.

Signature · 2 lines
Michal Hocko
SUSE Labs
#8 lore raw
Quoted 18 lines · Michal Hocko
Quoted 17 lines · Anshuman Khandual
Quoted 13 lines · Michal Hocko
Quoted 8 lines · Anshuman Khandual

Add following new vmstat events which will track HugeTLB page migration.

1. HUGETLB_MIGRATION_SUCCESS
2. HUGETLB_MIGRATION_FAILURE

It follows the existing semantics to accommodate HugeTLB subpages in total page migration statistics. While here, this updates current trace event 'mm_migrate_pages' to accommodate now available HugeTLB based statistics.

What is the actual usecase? And how do you deal with the complexity introduced by many different hugetlb page sizes. Really, what is the point to having such a detailed view on hugetlb migration?

Quoted 7 lines
Quoted 4 lines

It helps differentiate various page migration events i.e normal, THP and HugeTLB and gives us more reliable and accurate measurement. Current stats as per PGMIGRATE_SUCCESS and PGMIGRATE_FAIL are misleading, as they contain both normal and HugeTLB pages as single entities, which is not accurate.

Yes this is true. But why does it really matter? Do you have a specific example?

An example which demonstrates that mixing and misrepresentation in these stats create some problem ? Well, we could just create one scenario via an application with different VMA types and triggering some migrations. But the fact remains, that these stats are inaccurate and misleading which is very clear and apparent.

Quoted 7 lines
Quoted 7 lines

After this change, PGMIGRATE_SUCCESS and PGMIGRATE_FAIL will contain page migration statistics in terms of normal pages irrespective of whether any previous migrations until that point involved normal pages, THP or HugeTLB (any size) pages. At the least, this fixes existing misleading stats with PGMIGRATE_SUCCESS and PGMIGRATE_FAIL.

Quoted 7 lines
Quoted 4 lines

Besides, it helps us understand HugeTLB migrations in more detail. Even though HugeTLB can be of various sizes on a given platform, these new stats HUGETLB_MIGRATION_SUCCESS and HUGETLB_MIGRATION_FAILURE give enough overall insight into HugeTLB migration events.

While true this all is way too vague to add yet another imprecise counter.

Given that user knows about all HugeTLB mappings it has got, these counters are not really vague and could easily be related back. Moreover this change completes the migration stats restructuring which was started with adding THP counters. Otherwise it remains incomplete.

reviewer
#9 lore raw
Quoted 26 lines · Anshuman Khandual
Quoted 23 lines · Michal Hocko
Quoted 21 lines · Anshuman Khandual
Quoted 6 lines · Michal Hocko
Quoted 5 lines · Anshuman Khandual

Add following new vmstat events which will track HugeTLB page migration.

1. HUGETLB_MIGRATION_SUCCESS
2. HUGETLB_MIGRATION_FAILURE

Quoted 7 lines
Quoted 3 lines

It follows the existing semantics to accommodate HugeTLB subpages in total page migration statistics. While here, this updates current trace event 'mm_migrate_pages' to accommodate now available HugeTLB based statistics.

What is the actual usecase? And how do you deal with the complexity introduced by many different hugetlb page sizes. Really, what is the point to having such a detailed view on hugetlb migration?

It helps differentiate various page migration events i.e normal, THP and HugeTLB and gives us more reliable and accurate measurement. Current stats as per PGMIGRATE_SUCCESS and PGMIGRATE_FAIL are misleading, as they contain both normal and HugeTLB pages as single entities, which is not accurate.

Quoted 8 lines
Quoted 2 lines

Yes this is true. But why does it really matter? Do you have a specific example?

An example which demonstrates that mixing and misrepresentation in these stats create some problem ? Well, we could just create one scenario via an application with different VMA types and triggering some migrations. But the fact remains, that these stats are inaccurate and misleading which is very clear and apparent.

This doesn't sound like a proper justification to me.

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

After this change, PGMIGRATE_SUCCESS and PGMIGRATE_FAIL will contain page migration statistics in terms of normal pages irrespective of whether any previous migrations until that point involved normal pages, THP or HugeTLB (any size) pages. At the least, this fixes existing misleading stats with PGMIGRATE_SUCCESS and PGMIGRATE_FAIL.

Besides, it helps us understand HugeTLB migrations in more detail. Even though HugeTLB can be of various sizes on a given platform, these new stats HUGETLB_MIGRATION_SUCCESS and HUGETLB_MIGRATION_FAILURE give enough overall insight into HugeTLB migration events.

Quoted 5 lines
Quoted 2 lines

While true this all is way too vague to add yet another imprecise counter.

Given that user knows about all HugeTLB mappings it has got, these counters are not really vague and could easily be related back.

How can you tell a difference between different hugetlb sizes?

Quoted 3 lines

Moreover this change
completes the migration stats restructuring which was started with adding THP counters. Otherwise it remains incomplete.

Our counters will be always incomplete. Please do realize they are mere aid rather than a comprihensive toolset to identify the system behavior to the very detail. We have way too many counters and this particular ones are not adding much IMHO. At least not from your description which sounds to me like "Yeah, why not do that although there is no strong reason, well except that THP already has it so let's do it for hugetlb as well". I really do not want to deal with yet another report in few years that somebody wants to distinguish hugetlb migration of different sizes.

Really, is there any _real_ practical use for these other than "nice, let's just have it"?

Signature · 2 lines
Michal Hocko
SUSE Labs