Re: measuring the number of times each page is read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > I am trying to instrument linux-2.2.19 kernel to measure the number of
> > times each page is read. That is, for each page that is read by each
> > process from disk, there should be a counter. Once the measurement started,
> > the number of times a page is read from disk by a process should be counted;
> > if page is written out to swap space and brought back in, this should be
> > included in the count.
> 
> All swap and mmapped pages are already associated with disk
> locations in the kernel, via the address_space structure.
> However, when a page is evicted from RAM, naturally its
> "identity" is destroyed. You would need to keep a list or
> array of mappings between file offsets (or swap id) and
> read count. Attaching such to the address_space struct is
> probably the sensible thing to do. You could then manage
> the read count in the swap.c code when a page is read in
> from disk. Though disk readahead might cause you some
> problems - do you count all reads, or only those initiated
> to service page faults?

I want to count all reads, such as reading inodes.
In this case, I may have to look into "ll_rw_block()", since this routine
is used for all disk I/O activities, including those not involving swapping.
But, at that level, I only know the block no. How can I still associate
to a block reads to a virtual address?

And, can a block read be interpreated as a page read?(because, as far as
I saw for ext2 fs, one block is usually 4k)

> Much simpler to do the accounting in the kernel and provide a
> /proc interface to get the data, I think.

Good idea. I may go and try.

> > That's why I am here to ask you to give me some
> > suggestions. The aim is just to measure the number of each page is read when
> > runing a process.
> > 
> > Btw, is it feasible to use or introduce some additional bits in process
> > page-table to accomplish this?
> 
> I think that would be enormously more trouble than it's worth, and
> not possible anyway on many platforms. Also, remember that only a

Why is it so troublesome by modifying page-table?

> small percentage of page faults require disk reads; the
> majority are serviced from the page cache (under normal conditions).
> So tracking the number of per-process faults would not tell you
> much about disk activity.

But, when the memory size is small, it must increase the disk activity
for a single process tremendously.

Thanks for you suggestions!

-- 
Cheers!

Zou Min 
zoum@comp.nus.edu.sg
-----------------------------------------------------------------------------
To attract a vegetarian, make a noise like a wounded vegetable.
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux