Re: /proc/*/statm, exactly what does "shared" mean?

From: Hugh Dickins
Date: Wed Feb 16 2005 - 07:03:23 EST


On Wed, 16 Feb 2005, Mauricio Lin wrote:
> Well, for each vma it is checked how many pages are mapped to rss. So
> I have to check per page if it is allocated in physical memory. I know
> that this is a heavy function, but do you have any suggestion to
> improve this? What do you mean "needs refactoring into pgd_range,
> pud_range, pmd_range, pte_range levels like 2.4's statm"? Could you
> give more details, please?

Just look at, say, linux-2.4.29/fs/proc/array.c proc_pid_statm:
which calls statm_pgd_range which calls statm_pmd_range which
calls statm_pte_range which scans along the array of ptes doing
the pte examination you're doing. There are plenty of examples
in 2.6.11-rc mm/memory.c of how to do it with pud level too.

Whereas your way starts at the top and descends the tree each time
for every leaf, repeatedly mapping and unmapping the page table if
that pagetable is in highmem. You took follow_page as your starting
point, which is good for a single pte, but inefficient for many.

Your function(s) will still be heavyweight, but somewhat faster.

Hugh
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/