mm: Fix shmem THP counters on migration
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 mm: Fix shmem THP counters on migration
The per node numa_stat values for shmem don't change on page migration for THP:
grep shmem /sys/fs/cgroup/machine.slice/.../memory.numa_stat:
shmem N0=1092616192 N1=10485760
shmem_thp N0=1092616192 N1=10485760migratepages 9181 0 1:
shmem N0=0 N1=1103101952
shmem_thp N0=1092616192 N1=10485760Fix that by updating shmem_thp counters likewise to shmem counters on page migration.
--- mm/migrate.c | 5 +++++ 1 file changed, 5 insertions(+)
mm/migrate.c +5 -0
@@ -492,6 +492,11 @@ int folio_migrate_mapping(struct address_space *mapping,if (folio_test_swapbacked (folio) && !folio_test_swapcache (folio)) {__mod_lruvec_state (old_lruvec,NR_SHMEM , -nr);__mod_lruvec_state (new_lruvec,NR_SHMEM , nr); + +if (folio_test_transhuge (folio)) { +__mod_lruvec_state (old_lruvec,NR_SHMEM_THPS , -nr); +__mod_lruvec_state (new_lruvec,NR_SHMEM_THPS , nr); + } }#ifdef CONFIG_SWAP if (folio_test_swapcache (folio)) {
--
2.25.1
Quoted 13 lines · Jan Glauber
The per node
numa_statvalues for shmem don't change on page migration for THP:grep shmem /sys/fs/cgroup/machine.slice/.../memory.numa_stat: shmem N0=1092616192 N1=10485760 shmem_thp N0=1092616192 N1=10485760 migratepages 9181 0 1: shmem N0=0 N1=1103101952 shmem_thp N0=1092616192 N1=10485760
Quoted 5 lines
Fix that by updating
shmem_thpcounters likewise to shmem counters on page migration.Signed-off-by Jan Glauber <[email protected]>---
Please add your change history.
mm/migrate.c int folio_migrate_mapping(struct address_space *mapping, · line 496
Quoted 13 lines
mm/migrate.c | 5 +++++ 1 file changed, 5 insertions(+)mm/migrate.c +2
-0@@ -492,6 +492,11 @@ int folio_migrate_mapping(struct address_space *mapping,if (folio_test_swapbacked (folio) && !folio_test_swapcache (folio)) {__mod_lruvec_state (old_lruvec,NR_SHMEM , -nr);__mod_lruvec_state (new_lruvec,NR_SHMEM , nr); + +if (folio_test_transhuge (folio)) {
I am afraid this validation is fragile, IIUC the file backed folio can contain various numbers of pages in future.
So seems using folio_test_pmd_mappable() seems more suitable for THP.
Quoted 9 lines
mm/migrate.c +3
-1+__mod_lruvec_state (old_lruvec,NR_SHMEM_THPS , -nr); +__mod_lruvec_state (new_lruvec,NR_SHMEM_THPS , nr); + } }#ifdef CONFIG_SWAP if (folio_test_swapcache (folio)) { --2.25.1