summaryrefslogtreecommitdiffstats
path: root/mm/percpu.c
diff options
context:
space:
mode:
authorDennis Zhou <dennisz@fb.com>2017-06-19 19:28:31 -0400
committerTejun Heo <tj@kernel.org>2017-06-20 15:31:38 -0400
commit30a5b5367ef9d5c9055414e12ec2f02d9de2e70f (patch)
tree900c04966e2adae51b7f833dbedcd8cbe0f828bb /mm/percpu.c
parent8fa3ed8014ac792a4c76d585b5c0f68bd202ff6b (diff)
percpu: expose statistics about percpu memory via debugfs
There is limited visibility into the use of percpu memory leaving us unable to reason about correctness of parameters and overall use of percpu memory. These counters and statistics aim to help understand basic statistics about percpu memory such as number of allocations over the lifetime, allocation sizes, and fragmentation. New Config: PERCPU_STATS Signed-off-by: Dennis Zhou <dennisz@fb.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'mm/percpu.c')
-rw-r--r--mm/percpu.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mm/percpu.c b/mm/percpu.c
index 75ac982c19df..44a1cadf74a7 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -657,6 +657,7 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int freeme,
657 int *p; 657 int *p;
658 658
659 lockdep_assert_held(&pcpu_lock); 659 lockdep_assert_held(&pcpu_lock);
660 pcpu_stats_area_dealloc(chunk);
660 661
661 freeme |= 1; /* we are searching for <given offset, in use> pair */ 662 freeme |= 1; /* we are searching for <given offset, in use> pair */
662 663
@@ -721,6 +722,7 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void)
721 chunk->map[0] = 0; 722 chunk->map[0] = 0;
722 chunk->map[1] = pcpu_unit_size | 1; 723 chunk->map[1] = pcpu_unit_size | 1;
723 chunk->map_used = 1; 724 chunk->map_used = 1;
725 chunk->has_reserved = false;
724 726
725 INIT_LIST_HEAD(&chunk->list); 727 INIT_LIST_HEAD(&chunk->list);
726 INIT_LIST_HEAD(&chunk->map_extend_list); 728 INIT_LIST_HEAD(&chunk->map_extend_list);
@@ -970,6 +972,7 @@ restart:
970 goto restart; 972 goto restart;
971 973
972area_found: 974area_found:
975 pcpu_stats_area_alloc(chunk, size);
973 spin_unlock_irqrestore(&pcpu_lock, flags); 976 spin_unlock_irqrestore(&pcpu_lock, flags);
974 977
975 /* populate if not all pages are already there */ 978 /* populate if not all pages are already there */
@@ -1642,6 +1645,8 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
1642 pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) + 1645 pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) +
1643 BITS_TO_LONGS(pcpu_unit_pages) * sizeof(unsigned long); 1646 BITS_TO_LONGS(pcpu_unit_pages) * sizeof(unsigned long);
1644 1647
1648 pcpu_stats_save_ai(ai);
1649
1645 /* 1650 /*
1646 * Allocate chunk slots. The additional last slot is for 1651 * Allocate chunk slots. The additional last slot is for
1647 * empty chunks. 1652 * empty chunks.
@@ -1685,6 +1690,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
1685 if (schunk->free_size) 1690 if (schunk->free_size)
1686 schunk->map[++schunk->map_used] = ai->static_size + schunk->free_size; 1691 schunk->map[++schunk->map_used] = ai->static_size + schunk->free_size;
1687 schunk->map[schunk->map_used] |= 1; 1692 schunk->map[schunk->map_used] |= 1;
1693 schunk->has_reserved = true;
1688 1694
1689 /* init dynamic chunk if necessary */ 1695 /* init dynamic chunk if necessary */
1690 if (dyn_size) { 1696 if (dyn_size) {
@@ -1703,6 +1709,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
1703 dchunk->map[1] = pcpu_reserved_chunk_limit; 1709 dchunk->map[1] = pcpu_reserved_chunk_limit;
1704 dchunk->map[2] = (pcpu_reserved_chunk_limit + dchunk->free_size) | 1; 1710 dchunk->map[2] = (pcpu_reserved_chunk_limit + dchunk->free_size) | 1;
1705 dchunk->map_used = 2; 1711 dchunk->map_used = 2;
1712 dchunk->has_reserved = true;
1706 } 1713 }
1707 1714
1708 /* link the first chunk in */ 1715 /* link the first chunk in */
@@ -1711,6 +1718,8 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
1711 pcpu_count_occupied_pages(pcpu_first_chunk, 1); 1718 pcpu_count_occupied_pages(pcpu_first_chunk, 1);
1712 pcpu_chunk_relocate(pcpu_first_chunk, -1); 1719 pcpu_chunk_relocate(pcpu_first_chunk, -1);
1713 1720
1721 pcpu_stats_chunk_alloc();
1722
1714 /* we're done */ 1723 /* we're done */
1715 pcpu_base_addr = base_addr; 1724 pcpu_base_addr = base_addr;
1716 return 0; 1725 return 0;