The print_page_statst() function is modified so that it will count how
many pages are found with each of the kpageflag bit set. The collected
stats are then printed so that count for every non-zero kpageflag is
shown. Since there are so many kpageflag flags (22 at the moment),
zero number counts are alwaysy omitted.
Since root priviledges are required to read the /proc/kpageflag
interface, all of the kpageflag counts are zero if user does not have
root priviledges.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
struct maps *map;
int pids;
struct maps *map;
int pids;
long int pages_present;
long int pages_swapped;
long int pages_unique;
long int pages_present;
long int pages_swapped;
long int pages_unique;
+
+ /* kpageflag stats counters */
+ long int kpageflag[KPAGEFLAGS_NUM];
};
#define bintree_ops_to_af(bintree_ops) \
};
#define bintree_ops_to_af(bintree_ops) \
struct pageframe *pf = tree_to_pageframe(b);
struct analyze_frames *af = bintree_ops_to_af(ops);
struct maps_list *ml;
struct pageframe *pf = tree_to_pageframe(b);
struct analyze_frames *af = bintree_ops_to_af(ops);
struct maps_list *ml;
if (af->pid) {
/* Find pages which reference at least once a pid */
if (af->pid) {
/* Find pages which reference at least once a pid */
af->pages_swapped++;
if (pf->kpagecount == 1)
af->pages_unique++;
af->pages_swapped++;
if (pf->kpagecount == 1)
af->pages_unique++;
+
+ for (i = 0; i < KPAGEFLAGS_NUM; i++)
+ if (kpageflag_is_set(pf, i))
+ af->kpageflag[i]++;
{
struct analyze_frames af;
long count;
{
struct analyze_frames af;
long count;
memset(&af, 0, sizeof(af));
af.ops.callback = count_pages;
count = bintree_walk(&pf->tree, &af.ops);
memset(&af, 0, sizeof(af));
af.ops.callback = count_pages;
count = bintree_walk(&pf->tree, &af.ops);
+
+ for (i = 0; i < KPAGEFLAGS_NUM; i++) {
+ if (!af.kpageflag[i])
+ continue;
+
+ printf("%13s pages: %6ld, %5lld %s\n",
+ kpageflag_to_str(i),
+ af.kpageflag[i],
+ PAGE_TO_NICE(af.kpageflag[i]),
+ PAGE_TO_NICE_UNIT(af.kpageflag[i]));
+ }
+
printf(" present pages: %6ld, %5lld %sB\n"
" swapped pages: %6ld, %5lld %sB\n"
" unique pages: %6ld, %5lld %sB\n"
printf(" present pages: %6ld, %5lld %sB\n"
" swapped pages: %6ld, %5lld %sB\n"
" unique pages: %6ld, %5lld %sB\n"