Skip to content

Commit 63d9866

Browse files
Ryan Robertsakpm00
authored andcommitted
mm: shmem: rename mTHP shmem counters
The legacy PMD-sized THP counters at /proc/vmstat include thp_file_alloc, thp_file_fallback and thp_file_fallback_charge, which rather confusingly refer to shmem THP and do not include any other types of file pages. This is inconsistent since in most other places in the kernel, THP counters are explicitly separated for anon, shmem and file flavours. However, we are stuck with it since it constitutes a user ABI. Recently, commit 66f4458 ("mm: shmem: add mTHP counters for anonymous shmem") added equivalent mTHP stats for shmem, keeping the same "file_" prefix in the names. But in future, we may want to add extra stats to cover actual file pages, at which point, it would all become very confusing. So let's take the opportunity to rename these new counters "shmem_" before the change makes it upstream and the ABI becomes immutable. While we are at it, let's improve the documentation for the legacy counters to make it clear that they count shmem pages only. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ryan Roberts <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Reviewed-by: Lance Yang <[email protected]> Reviewed-by: Zi Yan <[email protected]> Reviewed-by: Barry Song <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Daniel Gomez <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2ef52d5 commit 63d9866

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

Documentation/admin-guide/mm/transhuge.rst

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -412,20 +412,23 @@ thp_collapse_alloc_failed
412412
the allocation.
413413

414414
thp_file_alloc
415-
is incremented every time a file huge page is successfully
416-
allocated.
415+
is incremented every time a shmem huge page is successfully
416+
allocated (Note that despite being named after "file", the counter
417+
measures only shmem).
417418

418419
thp_file_fallback
419-
is incremented if a file huge page is attempted to be allocated
420-
but fails and instead falls back to using small pages.
420+
is incremented if a shmem huge page is attempted to be allocated
421+
but fails and instead falls back to using small pages. (Note that
422+
despite being named after "file", the counter measures only shmem).
421423

422424
thp_file_fallback_charge
423-
is incremented if a file huge page cannot be charged and instead
425+
is incremented if a shmem huge page cannot be charged and instead
424426
falls back to using small pages even though the allocation was
425-
successful.
427+
successful. (Note that despite being named after "file", the
428+
counter measures only shmem).
426429

427430
thp_file_mapped
428-
is incremented every time a file huge page is mapped into
431+
is incremented every time a file or shmem huge page is mapped into
429432
user address space.
430433

431434
thp_split_page
@@ -496,16 +499,16 @@ swpout_fallback
496499
Usually because failed to allocate some continuous swap space
497500
for the huge page.
498501

499-
file_alloc
500-
is incremented every time a file huge page is successfully
502+
shmem_alloc
503+
is incremented every time a shmem huge page is successfully
501504
allocated.
502505

503-
file_fallback
504-
is incremented if a file huge page is attempted to be allocated
506+
shmem_fallback
507+
is incremented if a shmem huge page is attempted to be allocated
505508
but fails and instead falls back to using small pages.
506509

507-
file_fallback_charge
508-
is incremented if a file huge page cannot be charged and instead
510+
shmem_fallback_charge
511+
is incremented if a shmem huge page cannot be charged and instead
509512
falls back to using small pages even though the allocation was
510513
successful.
511514

include/linux/huge_mm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ enum mthp_stat_item {
269269
MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE,
270270
MTHP_STAT_SWPOUT,
271271
MTHP_STAT_SWPOUT_FALLBACK,
272-
MTHP_STAT_FILE_ALLOC,
273-
MTHP_STAT_FILE_FALLBACK,
274-
MTHP_STAT_FILE_FALLBACK_CHARGE,
272+
MTHP_STAT_SHMEM_ALLOC,
273+
MTHP_STAT_SHMEM_FALLBACK,
274+
MTHP_STAT_SHMEM_FALLBACK_CHARGE,
275275
MTHP_STAT_SPLIT,
276276
MTHP_STAT_SPLIT_FAILED,
277277
MTHP_STAT_SPLIT_DEFERRED,

mm/huge_memory.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,9 @@ DEFINE_MTHP_STAT_ATTR(anon_fault_fallback, MTHP_STAT_ANON_FAULT_FALLBACK);
568568
DEFINE_MTHP_STAT_ATTR(anon_fault_fallback_charge, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE);
569569
DEFINE_MTHP_STAT_ATTR(swpout, MTHP_STAT_SWPOUT);
570570
DEFINE_MTHP_STAT_ATTR(swpout_fallback, MTHP_STAT_SWPOUT_FALLBACK);
571-
DEFINE_MTHP_STAT_ATTR(file_alloc, MTHP_STAT_FILE_ALLOC);
572-
DEFINE_MTHP_STAT_ATTR(file_fallback, MTHP_STAT_FILE_FALLBACK);
573-
DEFINE_MTHP_STAT_ATTR(file_fallback_charge, MTHP_STAT_FILE_FALLBACK_CHARGE);
571+
DEFINE_MTHP_STAT_ATTR(shmem_alloc, MTHP_STAT_SHMEM_ALLOC);
572+
DEFINE_MTHP_STAT_ATTR(shmem_fallback, MTHP_STAT_SHMEM_FALLBACK);
573+
DEFINE_MTHP_STAT_ATTR(shmem_fallback_charge, MTHP_STAT_SHMEM_FALLBACK_CHARGE);
574574
DEFINE_MTHP_STAT_ATTR(split, MTHP_STAT_SPLIT);
575575
DEFINE_MTHP_STAT_ATTR(split_failed, MTHP_STAT_SPLIT_FAILED);
576576
DEFINE_MTHP_STAT_ATTR(split_deferred, MTHP_STAT_SPLIT_DEFERRED);
@@ -581,9 +581,9 @@ static struct attribute *stats_attrs[] = {
581581
&anon_fault_fallback_charge_attr.attr,
582582
&swpout_attr.attr,
583583
&swpout_fallback_attr.attr,
584-
&file_alloc_attr.attr,
585-
&file_fallback_attr.attr,
586-
&file_fallback_charge_attr.attr,
584+
&shmem_alloc_attr.attr,
585+
&shmem_fallback_attr.attr,
586+
&shmem_fallback_charge_attr.attr,
587587
&split_attr.attr,
588588
&split_failed_attr.attr,
589589
&split_deferred_attr.attr,

mm/shmem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ static struct folio *shmem_alloc_and_add_folio(struct vm_fault *vmf,
17771777
if (pages == HPAGE_PMD_NR)
17781778
count_vm_event(THP_FILE_FALLBACK);
17791779
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
1780-
count_mthp_stat(order, MTHP_STAT_FILE_FALLBACK);
1780+
count_mthp_stat(order, MTHP_STAT_SHMEM_FALLBACK);
17811781
#endif
17821782
order = next_order(&suitable_orders, order);
17831783
}
@@ -1804,8 +1804,8 @@ static struct folio *shmem_alloc_and_add_folio(struct vm_fault *vmf,
18041804
count_vm_event(THP_FILE_FALLBACK_CHARGE);
18051805
}
18061806
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
1807-
count_mthp_stat(folio_order(folio), MTHP_STAT_FILE_FALLBACK);
1808-
count_mthp_stat(folio_order(folio), MTHP_STAT_FILE_FALLBACK_CHARGE);
1807+
count_mthp_stat(folio_order(folio), MTHP_STAT_SHMEM_FALLBACK);
1808+
count_mthp_stat(folio_order(folio), MTHP_STAT_SHMEM_FALLBACK_CHARGE);
18091809
#endif
18101810
}
18111811
goto unlock;
@@ -2181,7 +2181,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index,
21812181
if (folio_test_pmd_mappable(folio))
21822182
count_vm_event(THP_FILE_ALLOC);
21832183
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
2184-
count_mthp_stat(folio_order(folio), MTHP_STAT_FILE_ALLOC);
2184+
count_mthp_stat(folio_order(folio), MTHP_STAT_SHMEM_ALLOC);
21852185
#endif
21862186
goto alloced;
21872187
}

0 commit comments

Comments
 (0)