mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
mm: smaps*: extend smap_gather_stats to support specified beginning
Extend smap_gather_stats to support indicated beginning address at which it should start gathering. To achieve the goal, we add a new parameter @start assigned by the caller and try to refactor it for simplicity. If @start is 0, it will use the range of @vma for gathering. Signed-off-by: Chinwen Chang <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Steven Price <[email protected]> Cc: Michel Lespinasse <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Daniel Jordan <[email protected]> Cc: Daniel Kiss <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Huang Ying <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Jimmy Assarsson <[email protected]> Cc: Laurent Dufour <[email protected]> Cc: "Matthew Wilcox (Oracle)" <[email protected]> Cc: Matthias Brugger <[email protected]> Cc: Song Liu <[email protected]> Cc: Vlastimil Babka <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
committed by
Linus Torvalds
parent
07e5bfe651
commit
03b4b11493
+22
-8
@@ -721,9 +721,21 @@ static const struct mm_walk_ops smaps_shmem_walk_ops = {
|
||||
.pte_hole = smaps_pte_hole,
|
||||
};
|
||||
|
||||
/*
|
||||
* Gather mem stats from @vma with the indicated beginning
|
||||
* address @start, and keep them in @mss.
|
||||
*
|
||||
* Use vm_start of @vma as the beginning address if @start is 0.
|
||||
*/
|
||||
static void smap_gather_stats(struct vm_area_struct *vma,
|
||||
struct mem_size_stats *mss)
|
||||
struct mem_size_stats *mss, unsigned long start)
|
||||
{
|
||||
const struct mm_walk_ops *ops = &smaps_walk_ops;
|
||||
|
||||
/* Invalid start */
|
||||
if (start >= vma->vm_end)
|
||||
return;
|
||||
|
||||
#ifdef CONFIG_SHMEM
|
||||
/* In case of smaps_rollup, reset the value from previous vma */
|
||||
mss->check_shmem_swap = false;
|
||||
@@ -740,18 +752,20 @@ static void smap_gather_stats(struct vm_area_struct *vma,
|
||||
*/
|
||||
unsigned long shmem_swapped = shmem_swap_usage(vma);
|
||||
|
||||
if (!shmem_swapped || (vma->vm_flags & VM_SHARED) ||
|
||||
!(vma->vm_flags & VM_WRITE)) {
|
||||
if (!start && (!shmem_swapped || (vma->vm_flags & VM_SHARED) ||
|
||||
!(vma->vm_flags & VM_WRITE))) {
|
||||
mss->swap += shmem_swapped;
|
||||
} else {
|
||||
mss->check_shmem_swap = true;
|
||||
walk_page_vma(vma, &smaps_shmem_walk_ops, mss);
|
||||
return;
|
||||
ops = &smaps_shmem_walk_ops;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* mmap_lock is held in m_start */
|
||||
walk_page_vma(vma, &smaps_walk_ops, mss);
|
||||
if (!start)
|
||||
walk_page_vma(vma, ops, mss);
|
||||
else
|
||||
walk_page_range(vma->vm_mm, start, vma->vm_end, ops, mss);
|
||||
}
|
||||
|
||||
#define SEQ_PUT_DEC(str, val) \
|
||||
@@ -803,7 +817,7 @@ static int show_smap(struct seq_file *m, void *v)
|
||||
|
||||
memset(&mss, 0, sizeof(mss));
|
||||
|
||||
smap_gather_stats(vma, &mss);
|
||||
smap_gather_stats(vma, &mss, 0);
|
||||
|
||||
show_map_vma(m, vma);
|
||||
|
||||
@@ -852,7 +866,7 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
|
||||
hold_task_mempolicy(priv);
|
||||
|
||||
for (vma = priv->mm->mmap; vma; vma = vma->vm_next) {
|
||||
smap_gather_stats(vma, &mss);
|
||||
smap_gather_stats(vma, &mss, 0);
|
||||
last_vma_end = vma->vm_end;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user