workload-tracing.rst 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. .. SPDX-License-Identifier: (GPL-2.0+ OR CC-BY-4.0)
  2. ======================================================
  3. Discovering Linux kernel subsystems used by a workload
  4. ======================================================
  5. :Authors: - Shuah Khan <skhan@linuxfoundation.org>
  6. - Shefali Sharma <sshefali021@gmail.com>
  7. :maintained-by: Shuah Khan <skhan@linuxfoundation.org>
  8. Key Points
  9. ==========
  10. * Understanding system resources necessary to build and run a workload
  11. is important.
  12. * Linux tracing and strace can be used to discover the system resources
  13. in use by a workload. The completeness of the system usage information
  14. depends on the completeness of coverage of a workload.
  15. * Performance and security of the operating system can be analyzed with
  16. the help of tools such as:
  17. `perf <https://man7.org/linux/man-pages/man1/perf.1.html>`_,
  18. `stress-ng <https://www.mankier.com/1/stress-ng>`_,
  19. `paxtest <https://github.com/opntr/paxtest-freebsd>`_.
  20. * Once we discover and understand the workload needs, we can focus on them
  21. to avoid regressions and use it to evaluate safety considerations.
  22. Methodology
  23. ===========
  24. `strace <https://man7.org/linux/man-pages/man1/strace.1.html>`_ is a
  25. diagnostic, instructional, and debugging tool and can be used to discover
  26. the system resources in use by a workload. Once we discover and understand
  27. the workload needs, we can focus on them to avoid regressions and use it
  28. to evaluate safety considerations. We use strace tool to trace workloads.
  29. This method of tracing using strace tells us the system calls invoked by
  30. the workload and doesn't include all the system calls that can be invoked
  31. by it. In addition, this tracing method tells us just the code paths within
  32. these system calls that are invoked. As an example, if a workload opens a
  33. file and reads from it successfully, then the success path is the one that
  34. is traced. Any error paths in that system call will not be traced. If there
  35. is a workload that provides full coverage of a workload then the method
  36. outlined here will trace and find all possible code paths. The completeness
  37. of the system usage information depends on the completeness of coverage of a
  38. workload.
  39. The goal is tracing a workload on a system running a default kernel without
  40. requiring custom kernel installs.
  41. How do we gather fine-grained system information?
  42. =================================================
  43. strace tool can be used to trace system calls made by a process and signals
  44. it receives. System calls are the fundamental interface between an
  45. application and the operating system kernel. They enable a program to
  46. request services from the kernel. For instance, the open() system call in
  47. Linux is used to provide access to a file in the file system. strace enables
  48. us to track all the system calls made by an application. It lists all the
  49. system calls made by a process and their resulting output.
  50. You can generate profiling data combining strace and perf record tools to
  51. record the events and information associated with a process. This provides
  52. insight into the process. "perf annotate" tool generates the statistics of
  53. each instruction of the program. This document goes over the details of how
  54. to gather fine-grained information on a workload's usage of system resources.
  55. We used strace to trace the perf, stress-ng, paxtest workloads to illustrate
  56. our methodology to discover resources used by a workload. This process can
  57. be applied to trace other workloads.
  58. Getting the system ready for tracing
  59. ====================================
  60. Before we can get started we will show you how to get your system ready.
  61. We assume that you have a Linux distribution running on a physical system
  62. or a virtual machine. Most distributions will include strace command. Let’s
  63. install other tools that aren’t usually included to build Linux kernel.
  64. Please note that the following works on Debian based distributions. You
  65. might have to find equivalent packages on other Linux distributions.
  66. Install tools to build Linux kernel and tools in kernel repository.
  67. scripts/ver_linux is a good way to check if your system already has
  68. the necessary tools::
  69. sudo apt-get build-essentials flex bison yacc
  70. sudo apt install libelf-dev systemtap-sdt-dev libaudit-dev libslang2-dev libperl-dev libdw-dev
  71. cscope is a good tool to browse kernel sources. Let's install it now::
  72. sudo apt-get install cscope
  73. Install stress-ng and paxtest::
  74. apt-get install stress-ng
  75. apt-get install paxtest
  76. Workload overview
  77. =================
  78. As mentioned earlier, we used strace to trace perf bench, stress-ng and
  79. paxtest workloads to show how to analyze a workload and identify Linux
  80. subsystems used by these workloads. Let's start with an overview of these
  81. three workloads to get a better understanding of what they do and how to
  82. use them.
  83. perf bench (all) workload
  84. -------------------------
  85. The perf bench command contains multiple multi-threaded microkernel
  86. benchmarks for executing different subsystems in the Linux kernel and
  87. system calls. This allows us to easily measure the impact of changes,
  88. which can help mitigate performance regressions. It also acts as a common
  89. benchmarking framework, enabling developers to easily create test cases,
  90. integrate transparently, and use performance-rich tooling subsystems.
  91. Stress-ng netdev stressor workload
  92. ----------------------------------
  93. stress-ng is used for performing stress testing on the kernel. It allows
  94. you to exercise various physical subsystems of the computer, as well as
  95. interfaces of the OS kernel, using "stressor-s". They are available for
  96. CPU, CPU cache, devices, I/O, interrupts, file system, memory, network,
  97. operating system, pipelines, schedulers, and virtual machines. Please refer
  98. to the `stress-ng man-page <https://www.mankier.com/1/stress-ng>`_ to
  99. find the description of all the available stressor-s. The netdev stressor
  100. starts specified number (N) of workers that exercise various netdevice
  101. ioctl commands across all the available network devices.
  102. paxtest kiddie workload
  103. -----------------------
  104. paxtest is a program that tests buffer overflows in the kernel. It tests
  105. kernel enforcements over memory usage. Generally, execution in some memory
  106. segments makes buffer overflows possible. It runs a set of programs that
  107. attempt to subvert memory usage. It is used as a regression test suite for
  108. PaX, but might be useful to test other memory protection patches for the
  109. kernel. We used paxtest kiddie mode which looks for simple vulnerabilities.
  110. What is strace and how do we use it?
  111. ====================================
  112. As mentioned earlier, strace which is a useful diagnostic, instructional,
  113. and debugging tool and can be used to discover the system resources in use
  114. by a workload. It can be used:
  115. * To see how a process interacts with the kernel.
  116. * To see why a process is failing or hanging.
  117. * For reverse engineering a process.
  118. * To find the files on which a program depends.
  119. * For analyzing the performance of an application.
  120. * For troubleshooting various problems related to the operating system.
  121. In addition, strace can generate run-time statistics on times, calls, and
  122. errors for each system call and report a summary when program exits,
  123. suppressing the regular output. This attempts to show system time (CPU time
  124. spent running in the kernel) independent of wall clock time. We plan to use
  125. these features to get information on workload system usage.
  126. strace command supports basic, verbose, and stats modes. strace command when
  127. run in verbose mode gives more detailed information about the system calls
  128. invoked by a process.
  129. Running strace -c generates a report of the percentage of time spent in each
  130. system call, the total time in seconds, the microseconds per call, the total
  131. number of calls, the count of each system call that has failed with an error
  132. and the type of system call made.
  133. * Usage: strace <command we want to trace>
  134. * Verbose mode usage: strace -v <command>
  135. * Gather statistics: strace -c <command>
  136. We used the “-c” option to gather fine-grained run-time statistics in use
  137. by three workloads we have chose for this analysis.
  138. * perf
  139. * stress-ng
  140. * paxtest
  141. What is cscope and how do we use it?
  142. ====================================
  143. Now let’s look at `cscope <https://cscope.sourceforge.net/>`_, a command
  144. line tool for browsing C, C++ or Java code-bases. We can use it to find
  145. all the references to a symbol, global definitions, functions called by a
  146. function, functions calling a function, text strings, regular expression
  147. patterns, files including a file.
  148. We can use cscope to find which system call belongs to which subsystem.
  149. This way we can find the kernel subsystems used by a process when it is
  150. executed.
  151. Let’s checkout the latest Linux repository and build cscope database::
  152. git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux
  153. cd linux
  154. cscope -R -p10 # builds cscope.out database before starting browse session
  155. cscope -d -p10 # starts browse session on cscope.out database
  156. Note: Run "cscope -R -p10" to build the database and c"scope -d -p10" to
  157. enter into the browsing session. cscope by default cscope.out database.
  158. To get out of this mode press ctrl+d. -p option is used to specify the
  159. number of file path components to display. -p10 is optimal for browsing
  160. kernel sources.
  161. What is perf and how do we use it?
  162. ==================================
  163. Perf is an analysis tool based on Linux 2.6+ systems, which abstracts the
  164. CPU hardware difference in performance measurement in Linux, and provides
  165. a simple command line interface. Perf is based on the perf_events interface
  166. exported by the kernel. It is very useful for profiling the system and
  167. finding performance bottlenecks in an application.
  168. If you haven't already checked out the Linux mainline repository, you can do
  169. so and then build kernel and perf tool::
  170. git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux
  171. cd linux
  172. make -j3 all
  173. cd tools/perf
  174. make
  175. Note: The perf command can be built without building the kernel in the
  176. repository and can be run on older kernels. However matching the kernel
  177. and perf revisions gives more accurate information on the subsystem usage.
  178. We used "perf stat" and "perf bench" options. For a detailed information on
  179. the perf tool, run "perf -h".
  180. perf stat
  181. ---------
  182. The perf stat command generates a report of various hardware and software
  183. events. It does so with the help of hardware counter registers found in
  184. modern CPUs that keep the count of these activities. "perf stat cal" shows
  185. stats for cal command.
  186. Perf bench
  187. ----------
  188. The perf bench command contains multiple multi-threaded microkernel
  189. benchmarks for executing different subsystems in the Linux kernel and
  190. system calls. This allows us to easily measure the impact of changes,
  191. which can help mitigate performance regressions. It also acts as a common
  192. benchmarking framework, enabling developers to easily create test cases,
  193. integrate transparently, and use performance-rich tooling.
  194. "perf bench all" command runs the following benchmarks:
  195. * sched/messaging
  196. * sched/pipe
  197. * syscall/basic
  198. * mem/memcpy
  199. * mem/memset
  200. What is stress-ng and how do we use it?
  201. =======================================
  202. As mentioned earlier, stress-ng is used for performing stress testing on
  203. the kernel. It allows you to exercise various physical subsystems of the
  204. computer, as well as interfaces of the OS kernel, using stressor-s. They
  205. are available for CPU, CPU cache, devices, I/O, interrupts, file system,
  206. memory, network, operating system, pipelines, schedulers, and virtual
  207. machines.
  208. The netdev stressor starts N workers that exercise various netdevice ioctl
  209. commands across all the available network devices. The following ioctls are
  210. exercised:
  211. * SIOCGIFCONF, SIOCGIFINDEX, SIOCGIFNAME, SIOCGIFFLAGS
  212. * SIOCGIFADDR, SIOCGIFNETMASK, SIOCGIFMETRIC, SIOCGIFMTU
  213. * SIOCGIFHWADDR, SIOCGIFMAP, SIOCGIFTXQLEN
  214. The following command runs the stressor::
  215. stress-ng --netdev 1 -t 60 --metrics command.
  216. We can use the perf record command to record the events and information
  217. associated with a process. This command records the profiling data in the
  218. perf.data file in the same directory.
  219. Using the following commands you can record the events associated with the
  220. netdev stressor, view the generated report perf.data and annotate the to
  221. view the statistics of each instruction of the program::
  222. perf record stress-ng --netdev 1 -t 60 --metrics command.
  223. perf report
  224. perf annotate
  225. What is paxtest and how do we use it?
  226. =====================================
  227. paxtest is a program that tests buffer overflows in the kernel. It tests
  228. kernel enforcements over memory usage. Generally, execution in some memory
  229. segments makes buffer overflows possible. It runs a set of programs that
  230. attempt to subvert memory usage. It is used as a regression test suite for
  231. PaX, and will be useful to test other memory protection patches for the
  232. kernel.
  233. paxtest provides kiddie and blackhat modes. The paxtest kiddie mode runs
  234. in normal mode, whereas the blackhat mode tries to get around the protection
  235. of the kernel testing for vulnerabilities. We focus on the kiddie mode here
  236. and combine "paxtest kiddie" run with "perf record" to collect CPU stack
  237. traces for the paxtest kiddie run to see which function is calling other
  238. functions in the performance profile. Then the "dwarf" (DWARF's Call Frame
  239. Information) mode can be used to unwind the stack.
  240. The following command can be used to view resulting report in call-graph
  241. format::
  242. perf record --call-graph dwarf paxtest kiddie
  243. perf report --stdio
  244. Tracing workloads
  245. =================
  246. Now that we understand the workloads, let's start tracing them.
  247. Tracing perf bench all workload
  248. -------------------------------
  249. Run the following command to trace perf bench all workload::
  250. strace -c perf bench all
  251. **System Calls made by the workload**
  252. The below table shows the system calls invoked by the workload, number of
  253. times each system call is invoked, and the corresponding Linux subsystem.
  254. +-------------------+-----------+-----------------+-------------------------+
  255. | System Call | # calls | Linux Subsystem | System Call (API) |
  256. +===================+===========+=================+=========================+
  257. | getppid | 10000001 | Process Mgmt | sys_getpid() |
  258. +-------------------+-----------+-----------------+-------------------------+
  259. | clone | 1077 | Process Mgmt. | sys_clone() |
  260. +-------------------+-----------+-----------------+-------------------------+
  261. | prctl | 23 | Process Mgmt. | sys_prctl() |
  262. +-------------------+-----------+-----------------+-------------------------+
  263. | prlimit64 | 7 | Process Mgmt. | sys_prlimit64() |
  264. +-------------------+-----------+-----------------+-------------------------+
  265. | getpid | 10 | Process Mgmt. | sys_getpid() |
  266. +-------------------+-----------+-----------------+-------------------------+
  267. | uname | 3 | Process Mgmt. | sys_uname() |
  268. +-------------------+-----------+-----------------+-------------------------+
  269. | sysinfo | 1 | Process Mgmt. | sys_sysinfo() |
  270. +-------------------+-----------+-----------------+-------------------------+
  271. | getuid | 1 | Process Mgmt. | sys_getuid() |
  272. +-------------------+-----------+-----------------+-------------------------+
  273. | getgid | 1 | Process Mgmt. | sys_getgid() |
  274. +-------------------+-----------+-----------------+-------------------------+
  275. | geteuid | 1 | Process Mgmt. | sys_geteuid() |
  276. +-------------------+-----------+-----------------+-------------------------+
  277. | getegid | 1 | Process Mgmt. | sys_getegid |
  278. +-------------------+-----------+-----------------+-------------------------+
  279. | close | 49951 | Filesystem | sys_close() |
  280. +-------------------+-----------+-----------------+-------------------------+
  281. | pipe | 604 | Filesystem | sys_pipe() |
  282. +-------------------+-----------+-----------------+-------------------------+
  283. | openat | 48560 | Filesystem | sys_opennat() |
  284. +-------------------+-----------+-----------------+-------------------------+
  285. | fstat | 8338 | Filesystem | sys_fstat() |
  286. +-------------------+-----------+-----------------+-------------------------+
  287. | stat | 1573 | Filesystem | sys_stat() |
  288. +-------------------+-----------+-----------------+-------------------------+
  289. | pread64 | 9646 | Filesystem | sys_pread64() |
  290. +-------------------+-----------+-----------------+-------------------------+
  291. | getdents64 | 1873 | Filesystem | sys_getdents64() |
  292. +-------------------+-----------+-----------------+-------------------------+
  293. | access | 3 | Filesystem | sys_access() |
  294. +-------------------+-----------+-----------------+-------------------------+
  295. | lstat | 1880 | Filesystem | sys_lstat() |
  296. +-------------------+-----------+-----------------+-------------------------+
  297. | lseek | 6 | Filesystem | sys_lseek() |
  298. +-------------------+-----------+-----------------+-------------------------+
  299. | ioctl | 3 | Filesystem | sys_ioctl() |
  300. +-------------------+-----------+-----------------+-------------------------+
  301. | dup2 | 1 | Filesystem | sys_dup2() |
  302. +-------------------+-----------+-----------------+-------------------------+
  303. | execve | 2 | Filesystem | sys_execve() |
  304. +-------------------+-----------+-----------------+-------------------------+
  305. | fcntl | 8779 | Filesystem | sys_fcntl() |
  306. +-------------------+-----------+-----------------+-------------------------+
  307. | statfs | 1 | Filesystem | sys_statfs() |
  308. +-------------------+-----------+-----------------+-------------------------+
  309. | epoll_create | 2 | Filesystem | sys_epoll_create() |
  310. +-------------------+-----------+-----------------+-------------------------+
  311. | epoll_ctl | 64 | Filesystem | sys_epoll_ctl() |
  312. +-------------------+-----------+-----------------+-------------------------+
  313. | newfstatat | 8318 | Filesystem | sys_newfstatat() |
  314. +-------------------+-----------+-----------------+-------------------------+
  315. | eventfd2 | 192 | Filesystem | sys_eventfd2() |
  316. +-------------------+-----------+-----------------+-------------------------+
  317. | mmap | 243 | Memory Mgmt. | sys_mmap() |
  318. +-------------------+-----------+-----------------+-------------------------+
  319. | mprotect | 32 | Memory Mgmt. | sys_mprotect() |
  320. +-------------------+-----------+-----------------+-------------------------+
  321. | brk | 21 | Memory Mgmt. | sys_brk() |
  322. +-------------------+-----------+-----------------+-------------------------+
  323. | munmap | 128 | Memory Mgmt. | sys_munmap() |
  324. +-------------------+-----------+-----------------+-------------------------+
  325. | set_mempolicy | 156 | Memory Mgmt. | sys_set_mempolicy() |
  326. +-------------------+-----------+-----------------+-------------------------+
  327. | set_tid_address | 1 | Process Mgmt. | sys_set_tid_address() |
  328. +-------------------+-----------+-----------------+-------------------------+
  329. | set_robust_list | 1 | Futex | sys_set_robust_list() |
  330. +-------------------+-----------+-----------------+-------------------------+
  331. | futex | 341 | Futex | sys_futex() |
  332. +-------------------+-----------+-----------------+-------------------------+
  333. | sched_getaffinity | 79 | Scheduler | sys_sched_getaffinity() |
  334. +-------------------+-----------+-----------------+-------------------------+
  335. | sched_setaffinity | 223 | Scheduler | sys_sched_setaffinity() |
  336. +-------------------+-----------+-----------------+-------------------------+
  337. | socketpair | 202 | Network | sys_socketpair() |
  338. +-------------------+-----------+-----------------+-------------------------+
  339. | rt_sigprocmask | 21 | Signal | sys_rt_sigprocmask() |
  340. +-------------------+-----------+-----------------+-------------------------+
  341. | rt_sigaction | 36 | Signal | sys_rt_sigaction() |
  342. +-------------------+-----------+-----------------+-------------------------+
  343. | rt_sigreturn | 2 | Signal | sys_rt_sigreturn() |
  344. +-------------------+-----------+-----------------+-------------------------+
  345. | wait4 | 889 | Time | sys_wait4() |
  346. +-------------------+-----------+-----------------+-------------------------+
  347. | clock_nanosleep | 37 | Time | sys_clock_nanosleep() |
  348. +-------------------+-----------+-----------------+-------------------------+
  349. | capget | 4 | Capability | sys_capget() |
  350. +-------------------+-----------+-----------------+-------------------------+
  351. Tracing stress-ng netdev stressor workload
  352. ------------------------------------------
  353. Run the following command to trace stress-ng netdev stressor workload::
  354. strace -c stress-ng --netdev 1 -t 60 --metrics
  355. **System Calls made by the workload**
  356. The below table shows the system calls invoked by the workload, number of
  357. times each system call is invoked, and the corresponding Linux subsystem.
  358. +-------------------+-----------+-----------------+-------------------------+
  359. | System Call | # calls | Linux Subsystem | System Call (API) |
  360. +===================+===========+=================+=========================+
  361. | openat | 74 | Filesystem | sys_openat() |
  362. +-------------------+-----------+-----------------+-------------------------+
  363. | close | 75 | Filesystem | sys_close() |
  364. +-------------------+-----------+-----------------+-------------------------+
  365. | read | 58 | Filesystem | sys_read() |
  366. +-------------------+-----------+-----------------+-------------------------+
  367. | fstat | 20 | Filesystem | sys_fstat() |
  368. +-------------------+-----------+-----------------+-------------------------+
  369. | flock | 10 | Filesystem | sys_flock() |
  370. +-------------------+-----------+-----------------+-------------------------+
  371. | write | 7 | Filesystem | sys_write() |
  372. +-------------------+-----------+-----------------+-------------------------+
  373. | getdents64 | 8 | Filesystem | sys_getdents64() |
  374. +-------------------+-----------+-----------------+-------------------------+
  375. | pread64 | 8 | Filesystem | sys_pread64() |
  376. +-------------------+-----------+-----------------+-------------------------+
  377. | lseek | 1 | Filesystem | sys_lseek() |
  378. +-------------------+-----------+-----------------+-------------------------+
  379. | access | 2 | Filesystem | sys_access() |
  380. +-------------------+-----------+-----------------+-------------------------+
  381. | getcwd | 1 | Filesystem | sys_getcwd() |
  382. +-------------------+-----------+-----------------+-------------------------+
  383. | execve | 1 | Filesystem | sys_execve() |
  384. +-------------------+-----------+-----------------+-------------------------+
  385. | mmap | 61 | Memory Mgmt. | sys_mmap() |
  386. +-------------------+-----------+-----------------+-------------------------+
  387. | munmap | 3 | Memory Mgmt. | sys_munmap() |
  388. +-------------------+-----------+-----------------+-------------------------+
  389. | mprotect | 20 | Memory Mgmt. | sys_mprotect() |
  390. +-------------------+-----------+-----------------+-------------------------+
  391. | mlock | 2 | Memory Mgmt. | sys_mlock() |
  392. +-------------------+-----------+-----------------+-------------------------+
  393. | brk | 3 | Memory Mgmt. | sys_brk() |
  394. +-------------------+-----------+-----------------+-------------------------+
  395. | rt_sigaction | 21 | Signal | sys_rt_sigaction() |
  396. +-------------------+-----------+-----------------+-------------------------+
  397. | rt_sigprocmask | 1 | Signal | sys_rt_sigprocmask() |
  398. +-------------------+-----------+-----------------+-------------------------+
  399. | sigaltstack | 1 | Signal | sys_sigaltstack() |
  400. +-------------------+-----------+-----------------+-------------------------+
  401. | rt_sigreturn | 1 | Signal | sys_rt_sigreturn() |
  402. +-------------------+-----------+-----------------+-------------------------+
  403. | getpid | 8 | Process Mgmt. | sys_getpid() |
  404. +-------------------+-----------+-----------------+-------------------------+
  405. | prlimit64 | 5 | Process Mgmt. | sys_prlimit64() |
  406. +-------------------+-----------+-----------------+-------------------------+
  407. | arch_prctl | 2 | Process Mgmt. | sys_arch_prctl() |
  408. +-------------------+-----------+-----------------+-------------------------+
  409. | sysinfo | 2 | Process Mgmt. | sys_sysinfo() |
  410. +-------------------+-----------+-----------------+-------------------------+
  411. | getuid | 2 | Process Mgmt. | sys_getuid() |
  412. +-------------------+-----------+-----------------+-------------------------+
  413. | uname | 1 | Process Mgmt. | sys_uname() |
  414. +-------------------+-----------+-----------------+-------------------------+
  415. | setpgid | 1 | Process Mgmt. | sys_setpgid() |
  416. +-------------------+-----------+-----------------+-------------------------+
  417. | getrusage | 1 | Process Mgmt. | sys_getrusage() |
  418. +-------------------+-----------+-----------------+-------------------------+
  419. | geteuid | 1 | Process Mgmt. | sys_geteuid() |
  420. +-------------------+-----------+-----------------+-------------------------+
  421. | getppid | 1 | Process Mgmt. | sys_getppid() |
  422. +-------------------+-----------+-----------------+-------------------------+
  423. | sendto | 3 | Network | sys_sendto() |
  424. +-------------------+-----------+-----------------+-------------------------+
  425. | connect | 1 | Network | sys_connect() |
  426. +-------------------+-----------+-----------------+-------------------------+
  427. | socket | 1 | Network | sys_socket() |
  428. +-------------------+-----------+-----------------+-------------------------+
  429. | clone | 1 | Process Mgmt. | sys_clone() |
  430. +-------------------+-----------+-----------------+-------------------------+
  431. | set_tid_address | 1 | Process Mgmt. | sys_set_tid_address() |
  432. +-------------------+-----------+-----------------+-------------------------+
  433. | wait4 | 2 | Time | sys_wait4() |
  434. +-------------------+-----------+-----------------+-------------------------+
  435. | alarm | 1 | Time | sys_alarm() |
  436. +-------------------+-----------+-----------------+-------------------------+
  437. | set_robust_list | 1 | Futex | sys_set_robust_list() |
  438. +-------------------+-----------+-----------------+-------------------------+
  439. Tracing paxtest kiddie workload
  440. -------------------------------
  441. Run the following command to trace paxtest kiddie workload::
  442. strace -c paxtest kiddie
  443. **System Calls made by the workload**
  444. The below table shows the system calls invoked by the workload, number of
  445. times each system call is invoked, and the corresponding Linux subsystem.
  446. +-------------------+-----------+-----------------+----------------------+
  447. | System Call | # calls | Linux Subsystem | System Call (API) |
  448. +===================+===========+=================+======================+
  449. | read | 3 | Filesystem | sys_read() |
  450. +-------------------+-----------+-----------------+----------------------+
  451. | write | 11 | Filesystem | sys_write() |
  452. +-------------------+-----------+-----------------+----------------------+
  453. | close | 41 | Filesystem | sys_close() |
  454. +-------------------+-----------+-----------------+----------------------+
  455. | stat | 24 | Filesystem | sys_stat() |
  456. +-------------------+-----------+-----------------+----------------------+
  457. | fstat | 2 | Filesystem | sys_fstat() |
  458. +-------------------+-----------+-----------------+----------------------+
  459. | pread64 | 6 | Filesystem | sys_pread64() |
  460. +-------------------+-----------+-----------------+----------------------+
  461. | access | 1 | Filesystem | sys_access() |
  462. +-------------------+-----------+-----------------+----------------------+
  463. | pipe | 1 | Filesystem | sys_pipe() |
  464. +-------------------+-----------+-----------------+----------------------+
  465. | dup2 | 24 | Filesystem | sys_dup2() |
  466. +-------------------+-----------+-----------------+----------------------+
  467. | execve | 1 | Filesystem | sys_execve() |
  468. +-------------------+-----------+-----------------+----------------------+
  469. | fcntl | 26 | Filesystem | sys_fcntl() |
  470. +-------------------+-----------+-----------------+----------------------+
  471. | openat | 14 | Filesystem | sys_openat() |
  472. +-------------------+-----------+-----------------+----------------------+
  473. | rt_sigaction | 7 | Signal | sys_rt_sigaction() |
  474. +-------------------+-----------+-----------------+----------------------+
  475. | rt_sigreturn | 38 | Signal | sys_rt_sigreturn() |
  476. +-------------------+-----------+-----------------+----------------------+
  477. | clone | 38 | Process Mgmt. | sys_clone() |
  478. +-------------------+-----------+-----------------+----------------------+
  479. | wait4 | 44 | Time | sys_wait4() |
  480. +-------------------+-----------+-----------------+----------------------+
  481. | mmap | 7 | Memory Mgmt. | sys_mmap() |
  482. +-------------------+-----------+-----------------+----------------------+
  483. | mprotect | 3 | Memory Mgmt. | sys_mprotect() |
  484. +-------------------+-----------+-----------------+----------------------+
  485. | munmap | 1 | Memory Mgmt. | sys_munmap() |
  486. +-------------------+-----------+-----------------+----------------------+
  487. | brk | 3 | Memory Mgmt. | sys_brk() |
  488. +-------------------+-----------+-----------------+----------------------+
  489. | getpid | 1 | Process Mgmt. | sys_getpid() |
  490. +-------------------+-----------+-----------------+----------------------+
  491. | getuid | 1 | Process Mgmt. | sys_getuid() |
  492. +-------------------+-----------+-----------------+----------------------+
  493. | getgid | 1 | Process Mgmt. | sys_getgid() |
  494. +-------------------+-----------+-----------------+----------------------+
  495. | geteuid | 2 | Process Mgmt. | sys_geteuid() |
  496. +-------------------+-----------+-----------------+----------------------+
  497. | getegid | 1 | Process Mgmt. | sys_getegid() |
  498. +-------------------+-----------+-----------------+----------------------+
  499. | getppid | 1 | Process Mgmt. | sys_getppid() |
  500. +-------------------+-----------+-----------------+----------------------+
  501. | arch_prctl | 2 | Process Mgmt. | sys_arch_prctl() |
  502. +-------------------+-----------+-----------------+----------------------+
  503. Conclusion
  504. ==========
  505. This document is intended to be used as a guide on how to gather fine-grained
  506. information on the resources in use by workloads using strace.
  507. References
  508. ==========
  509. * `Discovery Linux Kernel Subsystems used by OpenAPS <https://elisa.tech/blog/2022/02/02/discovery-linux-kernel-subsystems-used-by-openaps>`_
  510. * `ELISA-White-Papers-Discovering Linux kernel subsystems used by a workload <https://github.com/elisa-tech/ELISA-White-Papers/blob/master/Processes/Discovering_Linux_kernel_subsystems_used_by_a_workload.md>`_
  511. * `strace <https://man7.org/linux/man-pages/man1/strace.1.html>`_
  512. * `perf <https://man7.org/linux/man-pages/man1/perf.1.html>`_
  513. * `paxtest README <https://github.com/opntr/paxtest-freebsd/blob/hardenedbsd/0.9.14-hbsd/README>`_
  514. * `stress-ng <https://www.mankier.com/1/stress-ng>`_
  515. * `Monitoring and managing system status and performance <https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/monitoring_and_managing_system_status_and_performance/index>`_