Skip to content

Commit 8e68d68

Browse files
tehcastertorvalds
authored andcommitted
mm: /proc/pid/smaps: factor out mem stats gathering
To prepare for handling /proc/pid/smaps_rollup differently from /proc/pid/smaps factor out vma mem stats gathering from show_smap() - it will be used by both. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Vlastimil Babka <[email protected]> Reviewed-by: Alexey Dobriyan <[email protected]> Cc: Daniel Colascione <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 871305b commit 8e68d68

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

fs/proc/task_mmu.c

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -702,38 +702,16 @@ static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask,
702702
}
703703
#endif /* HUGETLB_PAGE */
704704

705-
#define SEQ_PUT_DEC(str, val) \
706-
seq_put_decimal_ull_width(m, str, (val) >> 10, 8)
707-
static int show_smap(struct seq_file *m, void *v)
705+
static void smap_gather_stats(struct vm_area_struct *vma,
706+
struct mem_size_stats *mss)
708707
{
709-
struct proc_maps_private *priv = m->private;
710-
struct vm_area_struct *vma = v;
711-
struct mem_size_stats mss_stack;
712-
struct mem_size_stats *mss;
713708
struct mm_walk smaps_walk = {
714709
.pmd_entry = smaps_pte_range,
715710
#ifdef CONFIG_HUGETLB_PAGE
716711
.hugetlb_entry = smaps_hugetlb_range,
717712
#endif
718713
.mm = vma->vm_mm,
719714
};
720-
int ret = 0;
721-
bool rollup_mode;
722-
bool last_vma;
723-
724-
if (priv->rollup) {
725-
rollup_mode = true;
726-
mss = priv->rollup;
727-
if (mss->first) {
728-
mss->first_vma_start = vma->vm_start;
729-
mss->first = false;
730-
}
731-
last_vma = !m_next_vma(priv, vma);
732-
} else {
733-
rollup_mode = false;
734-
memset(&mss_stack, 0, sizeof(mss_stack));
735-
mss = &mss_stack;
736-
}
737715

738716
smaps_walk.private = mss;
739717

@@ -765,6 +743,35 @@ static int show_smap(struct seq_file *m, void *v)
765743
walk_page_vma(vma, &smaps_walk);
766744
if (vma->vm_flags & VM_LOCKED)
767745
mss->pss_locked += mss->pss;
746+
}
747+
748+
#define SEQ_PUT_DEC(str, val) \
749+
seq_put_decimal_ull_width(m, str, (val) >> 10, 8)
750+
static int show_smap(struct seq_file *m, void *v)
751+
{
752+
struct proc_maps_private *priv = m->private;
753+
struct vm_area_struct *vma = v;
754+
struct mem_size_stats mss_stack;
755+
struct mem_size_stats *mss;
756+
int ret = 0;
757+
bool rollup_mode;
758+
bool last_vma;
759+
760+
if (priv->rollup) {
761+
rollup_mode = true;
762+
mss = priv->rollup;
763+
if (mss->first) {
764+
mss->first_vma_start = vma->vm_start;
765+
mss->first = false;
766+
}
767+
last_vma = !m_next_vma(priv, vma);
768+
} else {
769+
rollup_mode = false;
770+
memset(&mss_stack, 0, sizeof(mss_stack));
771+
mss = &mss_stack;
772+
}
773+
774+
smap_gather_stats(vma, mss);
768775

769776
if (!rollup_mode) {
770777
show_map_vma(m, vma);

0 commit comments

Comments
 (0)