This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Distribution of time spent in major page faults script


Hi all,

I was stuck in the jury duty Tuesday. While I was waiting to be called to sit on a jury I wrote the attached script. It generates the average time spent in a major page fault, the total time spent in the major page faults, the number of major page faults, and a distribution of the page faults. This script needs to use the systemtap snapshot because it uses the vm.pagefault.return.

What would like to do is extend this script to map the page faults back to the files that are causing the page faults.

For something like the startup of openoffice get something like the following:

# systemtap_write/install/bin/stap major_faults.stp -c ooffice
pid = 5676, execname = thunderbird-bin
avg 17903 = sum 537099 / count 30
 value |-------------------------------------------------- count
  1024 |                                                    0
  2048 |                                                    0
  4096 |@@                                                  2
  8192 |@@@@@@@@@@@@@@                                     14
 16384 |@@@@@@@@@@                                         10
 32768 |@@@@                                                4
 65536 |                                                    0
131072 |                                                    0

pid = 20714, execname = soffice.bin
avg 11464 = sum 6007554 / count 524
 value |-------------------------------------------------- count
     4 |                                                     0
     8 |                                                     0
    16 |                                                     1
    32 |                                                     0
    64 |                                                     1
   128 |@@                                                  14
   256 |@@@                                                 18
   512 |@@@@@@@                                             38
  1024 |@@@@@@@@@@                                          52
  2048 |@@@@                                                21
  4096 |@@@@@@@@@@@@@@                                      74
  8192 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@           201
 16384 |@@@@@@@@@@@@@@@@                                    83
 32768 |@@@                                                 17
 65536 |                                                     4
131072 |                                                     0
262144 |                                                     0

pid = 20732, execname = xkbcomp
avg 15499 = sum 92995 / count 6
 value |-------------------------------------------------- count
    64 |                                                   0
   128 |                                                   0
   256 |@                                                  1
   512 |@                                                  1
  1024 |                                                   0
  2048 |                                                   0
  4096 |                                                   0
  8192 |@                                                  1
 16384 |@@                                                 2
 32768 |@                                                  1
 65536 |                                                   0
131072 |                                                   0

pid = 20712, execname = javaldx
avg 7981 = sum 215504 / count 27
 value |-------------------------------------------------- count
    64 |                                                   0
   128 |                                                   0
   256 |@@@                                                3
   512 |@@                                                 2
  1024 |@@@                                                3
  2048 |@@@                                                3
  4096 |@@@@@@                                             6
  8192 |@@@@@@@                                            7
 16384 |@@                                                 2
 32768 |@                                                  1
 65536 |                                                   0
131072 |                                                   0

global vm_entry_times
global process_faults
global process_names
global VM_FAULT_MAJOR=3

probe vm.pagefault
{
	t=gettimeofday_us(); p = pid();
	vm_entry_times[p]=t;
}

probe vm.pagefault.return
{
	t=gettimeofday_us(); p = pid();
	if  (vm_entry_times[p]) {
		if (fault_type == VM_FAULT_MAJOR){
			process_faults[p] <<< t - vm_entry_times[p];
			process_names[p] = execname();
		}
		delete vm_entry_times[p];
	}
}

probe end
{
	foreach (p in process_faults){
		printf ("pid = %d, execname = %s\n", p, process_names[p]);
        	printf ("avg %d = sum %d / count %d\n",
                        @avg(process_faults[p]), @sum(process_faults[p]),
			@count(process_faults[p]));
		print(@hist_log(process_faults[p]))
	}
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]