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]

Re: [SCRIPT] NUMA page fault accounting.


Stone, Joshua I wrote:

Jose R. Santos wrote:
        page_faults [pid(), $write_access ? 1 : 0] ++
        node_faults [pid(), addr_to_node($address)] ++

You could improve scalability of this script by using statistics to maintain your count, e.g.:

        page_faults [pid(), $write_access ? 1 : 0] <<< 1
        node_faults [pid(), addr_to_node($address)] <<< 1

And then access the values with @count(page_faults[...]).

Other than that, this looks good.  It might be nice to start publishing
case studies on the website, so if you have a real problem that you
solved with this, please share!


Josh


Here the updated script based on your suggestions. Unfortunately, the machine that I uses is an old pre-production box that gives me a lot of variability between runs even when Im not running the SystemTap script so I cant verify if the changes are faster running the stream benchmark.

Thanks

-JRS

#! /usr/local/bin/stap -g

global execnames, page_faults, node_faults

function addr_to_node:long(addr:long)
%{
int nid;
int pfn = __pa(THIS->addr) >> PAGE_SHIFT;
for_each_online_node(nid)
if ( node_start_pfn(nid) <= pfn &&
pfn < (node_start_pfn(nid) +
NODE_DATA(nid)->node_spanned_pages) )
{
THIS->__retvalue = nid; break;
}


%}

probe kernel.function("__handle_mm_fault") {
       execnames[pid()] = execname()
       page_faults [pid(), $write_access ? 1 : 0] <<< 1
       node_faults [pid(), addr_to_node($address)] <<< 1

}

function print_pf () {
print (" Execname\t PID\tRead Faults\tWrite Faults\n")
print ("====================\t========\t===========\t============\n")
foreach (pid in execnames) {
printf ("%20s\t%8d\t%11d\t%12d\t", execnames[pid], pid,
@count(page_faults[pid,0]), @count(page_faults[pid,1]))


               foreach ([pid2,node+] in node_faults) {
                       if (pid2 == pid)
                               printf ("Node[%d]=%d\t", node,
                                       @count(node_faults[pid2, node]))
               }
               print ("\n")

       }
}

probe begin {
 print ("Starting pagefault counters \n")
}

probe end {
 print ("Printing counters: \n")
 print_pf ()
 print ("Done\n")
}


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