[ltt-dev] [PATCH] Add tracepoints to track pagecache transition

Atsushi Tsuji a-tsuji at bk.jp.nec.com
Sun Feb 8 21:54:38 EST 2009


Frank Ch. Eigler wrote:
> Atsushi Tsuji <a-tsuji at bk.jp.nec.com> writes:
> 
>> I thought it would be useful to trace pagecache behavior for problem
>> analysis (performance bottlenecks, behavior differences between stable
>> time and trouble time).
> 
> Interesting!  I hope it inspires more thinking about more places and
> ways for graphical data visualization to apply.
> 
>> By using those tracepoints, we can describe and visualize pagecache
>> transition (file-by-file basis) in kernel and pagecache consumes
>> most of the memory in running system and pagecache hit rate and
>> writeback behavior will influence system load and performance.
> 
> To what extent does your script work if it uses kprobes-based
> kernel.function() probes?  (It can use "!" type probe point
> decorations to automatically adapt to the preferred presence of the
> tracepoints/markers.)

Hi Frank,

Thank you for your response.
Yes, my script works using probe points in tapset (kprobes-based probes).
I attached this script below.

Thanks,
-Atsushi

----
Usage:
  ./pagecache_stat.stp

Output:
  This script outputs pagecache size(file-by-file basis) every 5 seconds like below.
 
  timestamp dev:inode pagecache size (KB), dev:inode pagecache size (KB),...

  (example)
  Thu Feb  5 05:21:29 2009 800003:4482806 112348
  Thu Feb  5 05:21:34 2009 800003:4482806 211968, 800003:4482817 96708,
  Thu Feb  5 05:21:39 2009 800003:4482806 294488, 800003:4482817 178604,
  Thu Feb  5 05:21:44 2009 800003:4482806 400560, 800003:4482817 288832,
                                .
                                .
                                .

#!/usr/bin/env stap

global cache

probe timer.ms(5000)
{
	printf("%s ",ctime(gettimeofday_s()));
	foreach([dev, ino] in cache){
		printf("%x:%d %d, ",dev ,ino , cache[dev, ino] * 4); /* page size is 4KB */
	}
	printf("\n");
}

probe vfs.add_to_page_cache.return
{
	/* $return == 0 if the page is really added to pagecache */
	if($return == 0){
		ino = $mapping->host->i_ino;
		dev = $mapping->host->i_sb->s_dev;
		cache[dev, ino]++;
	}
}

probe vfs.remove_from_page_cache
{
	cache[dev, ino]--;
}





More information about the lttng-dev mailing list