On Mon, 14 Apr 2025 22:54:41 +0200
Borislav Petkov <[email protected]> wrote:

> On Mon, Apr 14, 2025 at 03:35:41PM -0500, Junxuan Liao wrote:
> > Rename page_fault_{user,kernel} to page_fault_{user,kernel}_enter, and
> > add the exit counterparts. This might be useful for measuring page fault  
>                                 ^^^^^^^^^^^^^^^^
> 
> Well, come back when it really becomes useful.

It's useful for me ;-)

 # cd /sys/kernel/tracing
 # echo 's:user_faults u64 delta;' >> dynamic_events
 # echo 'hist:keys=common_pid:ts0=common_timestamp.usecs' >> 
events/exceptions/page_fault_user_enter/trigger
 # echo 
'hist:keys=common_pid:delta=common_timestamp.usecs-$ts0:onmatch(exceptions.page_fault_user_enter).trace(user_faults,$delta)'
 >> events/exceptions/page_fault_user_exit/trigger

 # cd /work/git/trace-cmd.git
 # echo 'hist:keys=delta.log2:sort=delta if COMM == "cc1"' > 
/sys/kernel/tracing/events/synthetic/user_faults/trigger
 # make
[..]

 # cat /sys/kernel/tracing/events/synthetic/user_faults/hist
# event histogram
#
# trigger info: hist:keys=delta.log2:vals=hitcount:sort=delta.log2:size=2048 if 
COMM == "cc1" [active]
#

{ delta: ~ 2^0  } hitcount:          1
{ delta: ~ 2^1  } hitcount:        334
{ delta: ~ 2^2  } hitcount:       4090
{ delta: ~ 2^3  } hitcount:      86037
{ delta: ~ 2^4  } hitcount:     108790
{ delta: ~ 2^5  } hitcount:      27387
{ delta: ~ 2^6  } hitcount:       6015
{ delta: ~ 2^7  } hitcount:        481
{ delta: ~ 2^8  } hitcount:        134
{ delta: ~ 2^9  } hitcount:         74
{ delta: ~ 2^10 } hitcount:         54
{ delta: ~ 2^11 } hitcount:          6

Totals:
    Hits: 233403
    Entries: 12
    Dropped: 0


The above shows a histogram in microseconds where the buckets increase in a
power of two. The biggest bucket is between 2^4 (16) and 2^5 (32) microseconds
with 108790 hits.

The longest bucket of 2^11 (2ms) to 2^12 (4ms) had 6 hits.

And when sframes is supported, it will be able to show the user space stack
trace of where the longest page faults occur.

-- Steve

Reply via email to