The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/tools/trace/pirate.lua

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #!/usr/local/bin/recon
    2 
    3 local ktrace = require 'ktrace'
    4 
    5 if arg[1] == '-h' then
    6   io.stderr:write[[
    7 usage: pirate [<trace-file-path>]
    8 
    9 pirate monitors for jetsam, on the high seas!
   10 ]]
   11   os.exit(0)
   12 end
   13 
   14 local sess = ktrace.Session.new(arg[1])
   15 
   16 sess:add_callback_pair('MEMSTAT_jetsam', function (start, finish)
   17   local pid = finish[2]
   18   local reclaimed_kb = finish[4] / 1024
   19   local duration_ns = sess:ns_from_abs(finish.abstime - start.abstime)
   20   print(('%12f: %32s: duration = %gus, reclaimed = %gKB'):format(
   21       sess:relns_from_abs(start.abstime) / 1e9, sess:procname_for_pid(pid),
   22       duration_ns / 1000, reclaimed_kb))
   23 end)
   24 
   25 local ok, err = sess:start()
   26 if not ok then
   27   io.stderr:write('pirate: failed to start tracing: ', err, '\n')
   28   os.exit(1)
   29 end

Cache object: 24ef0ad8178764f917a2698a0867af44


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.