intel_rdt_ui.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. User Interface for Resource Allocation in Intel Resource Director Technology
  2. Copyright (C) 2016 Intel Corporation
  3. Fenghua Yu <fenghua.yu@intel.com>
  4. Tony Luck <tony.luck@intel.com>
  5. Vikas Shivappa <vikas.shivappa@intel.com>
  6. This feature is enabled by the CONFIG_INTEL_RDT Kconfig and the
  7. X86 /proc/cpuinfo flag bits:
  8. RDT (Resource Director Technology) Allocation - "rdt_a"
  9. CAT (Cache Allocation Technology) - "cat_l3", "cat_l2"
  10. CDP (Code and Data Prioritization ) - "cdp_l3", "cdp_l2"
  11. CQM (Cache QoS Monitoring) - "cqm_llc", "cqm_occup_llc"
  12. MBM (Memory Bandwidth Monitoring) - "cqm_mbm_total", "cqm_mbm_local"
  13. MBA (Memory Bandwidth Allocation) - "mba"
  14. To use the feature mount the file system:
  15. # mount -t resctrl resctrl [-o cdp[,cdpl2]] /sys/fs/resctrl
  16. mount options are:
  17. "cdp": Enable code/data prioritization in L3 cache allocations.
  18. "cdpl2": Enable code/data prioritization in L2 cache allocations.
  19. L2 and L3 CDP are controlled seperately.
  20. RDT features are orthogonal. A particular system may support only
  21. monitoring, only control, or both monitoring and control.
  22. The mount succeeds if either of allocation or monitoring is present, but
  23. only those files and directories supported by the system will be created.
  24. For more details on the behavior of the interface during monitoring
  25. and allocation, see the "Resource alloc and monitor groups" section.
  26. Info directory
  27. --------------
  28. The 'info' directory contains information about the enabled
  29. resources. Each resource has its own subdirectory. The subdirectory
  30. names reflect the resource names.
  31. Each subdirectory contains the following files with respect to
  32. allocation:
  33. Cache resource(L3/L2) subdirectory contains the following files
  34. related to allocation:
  35. "num_closids": The number of CLOSIDs which are valid for this
  36. resource. The kernel uses the smallest number of
  37. CLOSIDs of all enabled resources as limit.
  38. "cbm_mask": The bitmask which is valid for this resource.
  39. This mask is equivalent to 100%.
  40. "min_cbm_bits": The minimum number of consecutive bits which
  41. must be set when writing a mask.
  42. "shareable_bits": Bitmask of shareable resource with other executing
  43. entities (e.g. I/O). User can use this when
  44. setting up exclusive cache partitions. Note that
  45. some platforms support devices that have their
  46. own settings for cache use which can over-ride
  47. these bits.
  48. Memory bandwitdh(MB) subdirectory contains the following files
  49. with respect to allocation:
  50. "min_bandwidth": The minimum memory bandwidth percentage which
  51. user can request.
  52. "bandwidth_gran": The granularity in which the memory bandwidth
  53. percentage is allocated. The allocated
  54. b/w percentage is rounded off to the next
  55. control step available on the hardware. The
  56. available bandwidth control steps are:
  57. min_bandwidth + N * bandwidth_gran.
  58. "delay_linear": Indicates if the delay scale is linear or
  59. non-linear. This field is purely informational
  60. only.
  61. If RDT monitoring is available there will be an "L3_MON" directory
  62. with the following files:
  63. "num_rmids": The number of RMIDs available. This is the
  64. upper bound for how many "CTRL_MON" + "MON"
  65. groups can be created.
  66. "mon_features": Lists the monitoring events if
  67. monitoring is enabled for the resource.
  68. "max_threshold_occupancy":
  69. Read/write file provides the largest value (in
  70. bytes) at which a previously used LLC_occupancy
  71. counter can be considered for re-use.
  72. Finally, in the top level of the "info" directory there is a file
  73. named "last_cmd_status". This is reset with every "command" issued
  74. via the file system (making new directories or writing to any of the
  75. control files). If the command was successful, it will read as "ok".
  76. If the command failed, it will provide more information that can be
  77. conveyed in the error returns from file operations. E.g.
  78. # echo L3:0=f7 > schemata
  79. bash: echo: write error: Invalid argument
  80. # cat info/last_cmd_status
  81. mask f7 has non-consecutive 1-bits
  82. Resource alloc and monitor groups
  83. ---------------------------------
  84. Resource groups are represented as directories in the resctrl file
  85. system. The default group is the root directory which, immediately
  86. after mounting, owns all the tasks and cpus in the system and can make
  87. full use of all resources.
  88. On a system with RDT control features additional directories can be
  89. created in the root directory that specify different amounts of each
  90. resource (see "schemata" below). The root and these additional top level
  91. directories are referred to as "CTRL_MON" groups below.
  92. On a system with RDT monitoring the root directory and other top level
  93. directories contain a directory named "mon_groups" in which additional
  94. directories can be created to monitor subsets of tasks in the CTRL_MON
  95. group that is their ancestor. These are called "MON" groups in the rest
  96. of this document.
  97. Removing a directory will move all tasks and cpus owned by the group it
  98. represents to the parent. Removing one of the created CTRL_MON groups
  99. will automatically remove all MON groups below it.
  100. All groups contain the following files:
  101. "tasks":
  102. Reading this file shows the list of all tasks that belong to
  103. this group. Writing a task id to the file will add a task to the
  104. group. If the group is a CTRL_MON group the task is removed from
  105. whichever previous CTRL_MON group owned the task and also from
  106. any MON group that owned the task. If the group is a MON group,
  107. then the task must already belong to the CTRL_MON parent of this
  108. group. The task is removed from any previous MON group.
  109. "cpus":
  110. Reading this file shows a bitmask of the logical CPUs owned by
  111. this group. Writing a mask to this file will add and remove
  112. CPUs to/from this group. As with the tasks file a hierarchy is
  113. maintained where MON groups may only include CPUs owned by the
  114. parent CTRL_MON group.
  115. "cpus_list":
  116. Just like "cpus", only using ranges of CPUs instead of bitmasks.
  117. When control is enabled all CTRL_MON groups will also contain:
  118. "schemata":
  119. A list of all the resources available to this group.
  120. Each resource has its own line and format - see below for details.
  121. When monitoring is enabled all MON groups will also contain:
  122. "mon_data":
  123. This contains a set of files organized by L3 domain and by
  124. RDT event. E.g. on a system with two L3 domains there will
  125. be subdirectories "mon_L3_00" and "mon_L3_01". Each of these
  126. directories have one file per event (e.g. "llc_occupancy",
  127. "mbm_total_bytes", and "mbm_local_bytes"). In a MON group these
  128. files provide a read out of the current value of the event for
  129. all tasks in the group. In CTRL_MON groups these files provide
  130. the sum for all tasks in the CTRL_MON group and all tasks in
  131. MON groups. Please see example section for more details on usage.
  132. Resource allocation rules
  133. -------------------------
  134. When a task is running the following rules define which resources are
  135. available to it:
  136. 1) If the task is a member of a non-default group, then the schemata
  137. for that group is used.
  138. 2) Else if the task belongs to the default group, but is running on a
  139. CPU that is assigned to some specific group, then the schemata for the
  140. CPU's group is used.
  141. 3) Otherwise the schemata for the default group is used.
  142. Resource monitoring rules
  143. -------------------------
  144. 1) If a task is a member of a MON group, or non-default CTRL_MON group
  145. then RDT events for the task will be reported in that group.
  146. 2) If a task is a member of the default CTRL_MON group, but is running
  147. on a CPU that is assigned to some specific group, then the RDT events
  148. for the task will be reported in that group.
  149. 3) Otherwise RDT events for the task will be reported in the root level
  150. "mon_data" group.
  151. Notes on cache occupancy monitoring and control
  152. -----------------------------------------------
  153. When moving a task from one group to another you should remember that
  154. this only affects *new* cache allocations by the task. E.g. you may have
  155. a task in a monitor group showing 3 MB of cache occupancy. If you move
  156. to a new group and immediately check the occupancy of the old and new
  157. groups you will likely see that the old group is still showing 3 MB and
  158. the new group zero. When the task accesses locations still in cache from
  159. before the move, the h/w does not update any counters. On a busy system
  160. you will likely see the occupancy in the old group go down as cache lines
  161. are evicted and re-used while the occupancy in the new group rises as
  162. the task accesses memory and loads into the cache are counted based on
  163. membership in the new group.
  164. The same applies to cache allocation control. Moving a task to a group
  165. with a smaller cache partition will not evict any cache lines. The
  166. process may continue to use them from the old partition.
  167. Hardware uses CLOSid(Class of service ID) and an RMID(Resource monitoring ID)
  168. to identify a control group and a monitoring group respectively. Each of
  169. the resource groups are mapped to these IDs based on the kind of group. The
  170. number of CLOSid and RMID are limited by the hardware and hence the creation of
  171. a "CTRL_MON" directory may fail if we run out of either CLOSID or RMID
  172. and creation of "MON" group may fail if we run out of RMIDs.
  173. max_threshold_occupancy - generic concepts
  174. ------------------------------------------
  175. Note that an RMID once freed may not be immediately available for use as
  176. the RMID is still tagged the cache lines of the previous user of RMID.
  177. Hence such RMIDs are placed on limbo list and checked back if the cache
  178. occupancy has gone down. If there is a time when system has a lot of
  179. limbo RMIDs but which are not ready to be used, user may see an -EBUSY
  180. during mkdir.
  181. max_threshold_occupancy is a user configurable value to determine the
  182. occupancy at which an RMID can be freed.
  183. Schemata files - general concepts
  184. ---------------------------------
  185. Each line in the file describes one resource. The line starts with
  186. the name of the resource, followed by specific values to be applied
  187. in each of the instances of that resource on the system.
  188. Cache IDs
  189. ---------
  190. On current generation systems there is one L3 cache per socket and L2
  191. caches are generally just shared by the hyperthreads on a core, but this
  192. isn't an architectural requirement. We could have multiple separate L3
  193. caches on a socket, multiple cores could share an L2 cache. So instead
  194. of using "socket" or "core" to define the set of logical cpus sharing
  195. a resource we use a "Cache ID". At a given cache level this will be a
  196. unique number across the whole system (but it isn't guaranteed to be a
  197. contiguous sequence, there may be gaps). To find the ID for each logical
  198. CPU look in /sys/devices/system/cpu/cpu*/cache/index*/id
  199. Cache Bit Masks (CBM)
  200. ---------------------
  201. For cache resources we describe the portion of the cache that is available
  202. for allocation using a bitmask. The maximum value of the mask is defined
  203. by each cpu model (and may be different for different cache levels). It
  204. is found using CPUID, but is also provided in the "info" directory of
  205. the resctrl file system in "info/{resource}/cbm_mask". X86 hardware
  206. requires that these masks have all the '1' bits in a contiguous block. So
  207. 0x3, 0x6 and 0xC are legal 4-bit masks with two bits set, but 0x5, 0x9
  208. and 0xA are not. On a system with a 20-bit mask each bit represents 5%
  209. of the capacity of the cache. You could partition the cache into four
  210. equal parts with masks: 0x1f, 0x3e0, 0x7c00, 0xf8000.
  211. Memory bandwidth(b/w) percentage
  212. --------------------------------
  213. For Memory b/w resource, user controls the resource by indicating the
  214. percentage of total memory b/w.
  215. The minimum bandwidth percentage value for each cpu model is predefined
  216. and can be looked up through "info/MB/min_bandwidth". The bandwidth
  217. granularity that is allocated is also dependent on the cpu model and can
  218. be looked up at "info/MB/bandwidth_gran". The available bandwidth
  219. control steps are: min_bw + N * bw_gran. Intermediate values are rounded
  220. to the next control step available on the hardware.
  221. The bandwidth throttling is a core specific mechanism on some of Intel
  222. SKUs. Using a high bandwidth and a low bandwidth setting on two threads
  223. sharing a core will result in both threads being throttled to use the
  224. low bandwidth.
  225. L3 schemata file details (code and data prioritization disabled)
  226. ----------------------------------------------------------------
  227. With CDP disabled the L3 schemata format is:
  228. L3:<cache_id0>=<cbm>;<cache_id1>=<cbm>;...
  229. L3 schemata file details (CDP enabled via mount option to resctrl)
  230. ------------------------------------------------------------------
  231. When CDP is enabled L3 control is split into two separate resources
  232. so you can specify independent masks for code and data like this:
  233. L3data:<cache_id0>=<cbm>;<cache_id1>=<cbm>;...
  234. L3code:<cache_id0>=<cbm>;<cache_id1>=<cbm>;...
  235. L2 schemata file details
  236. ------------------------
  237. L2 cache does not support code and data prioritization, so the
  238. schemata format is always:
  239. L2:<cache_id0>=<cbm>;<cache_id1>=<cbm>;...
  240. Memory b/w Allocation details
  241. -----------------------------
  242. Memory b/w domain is L3 cache.
  243. MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;...
  244. Reading/writing the schemata file
  245. ---------------------------------
  246. Reading the schemata file will show the state of all resources
  247. on all domains. When writing you only need to specify those values
  248. which you wish to change. E.g.
  249. # cat schemata
  250. L3DATA:0=fffff;1=fffff;2=fffff;3=fffff
  251. L3CODE:0=fffff;1=fffff;2=fffff;3=fffff
  252. # echo "L3DATA:2=3c0;" > schemata
  253. # cat schemata
  254. L3DATA:0=fffff;1=fffff;2=3c0;3=fffff
  255. L3CODE:0=fffff;1=fffff;2=fffff;3=fffff
  256. Examples for RDT allocation usage:
  257. Example 1
  258. ---------
  259. On a two socket machine (one L3 cache per socket) with just four bits
  260. for cache bit masks, minimum b/w of 10% with a memory bandwidth
  261. granularity of 10%
  262. # mount -t resctrl resctrl /sys/fs/resctrl
  263. # cd /sys/fs/resctrl
  264. # mkdir p0 p1
  265. # echo "L3:0=3;1=c\nMB:0=50;1=50" > /sys/fs/resctrl/p0/schemata
  266. # echo "L3:0=3;1=3\nMB:0=50;1=50" > /sys/fs/resctrl/p1/schemata
  267. The default resource group is unmodified, so we have access to all parts
  268. of all caches (its schemata file reads "L3:0=f;1=f").
  269. Tasks that are under the control of group "p0" may only allocate from the
  270. "lower" 50% on cache ID 0, and the "upper" 50% of cache ID 1.
  271. Tasks in group "p1" use the "lower" 50% of cache on both sockets.
  272. Similarly, tasks that are under the control of group "p0" may use a
  273. maximum memory b/w of 50% on socket0 and 50% on socket 1.
  274. Tasks in group "p1" may also use 50% memory b/w on both sockets.
  275. Note that unlike cache masks, memory b/w cannot specify whether these
  276. allocations can overlap or not. The allocations specifies the maximum
  277. b/w that the group may be able to use and the system admin can configure
  278. the b/w accordingly.
  279. Example 2
  280. ---------
  281. Again two sockets, but this time with a more realistic 20-bit mask.
  282. Two real time tasks pid=1234 running on processor 0 and pid=5678 running on
  283. processor 1 on socket 0 on a 2-socket and dual core machine. To avoid noisy
  284. neighbors, each of the two real-time tasks exclusively occupies one quarter
  285. of L3 cache on socket 0.
  286. # mount -t resctrl resctrl /sys/fs/resctrl
  287. # cd /sys/fs/resctrl
  288. First we reset the schemata for the default group so that the "upper"
  289. 50% of the L3 cache on socket 0 and 50% of memory b/w cannot be used by
  290. ordinary tasks:
  291. # echo "L3:0=3ff;1=fffff\nMB:0=50;1=100" > schemata
  292. Next we make a resource group for our first real time task and give
  293. it access to the "top" 25% of the cache on socket 0.
  294. # mkdir p0
  295. # echo "L3:0=f8000;1=fffff" > p0/schemata
  296. Finally we move our first real time task into this resource group. We
  297. also use taskset(1) to ensure the task always runs on a dedicated CPU
  298. on socket 0. Most uses of resource groups will also constrain which
  299. processors tasks run on.
  300. # echo 1234 > p0/tasks
  301. # taskset -cp 1 1234
  302. Ditto for the second real time task (with the remaining 25% of cache):
  303. # mkdir p1
  304. # echo "L3:0=7c00;1=fffff" > p1/schemata
  305. # echo 5678 > p1/tasks
  306. # taskset -cp 2 5678
  307. For the same 2 socket system with memory b/w resource and CAT L3 the
  308. schemata would look like(Assume min_bandwidth 10 and bandwidth_gran is
  309. 10):
  310. For our first real time task this would request 20% memory b/w on socket
  311. 0.
  312. # echo -e "L3:0=f8000;1=fffff\nMB:0=20;1=100" > p0/schemata
  313. For our second real time task this would request an other 20% memory b/w
  314. on socket 0.
  315. # echo -e "L3:0=f8000;1=fffff\nMB:0=20;1=100" > p0/schemata
  316. Example 3
  317. ---------
  318. A single socket system which has real-time tasks running on core 4-7 and
  319. non real-time workload assigned to core 0-3. The real-time tasks share text
  320. and data, so a per task association is not required and due to interaction
  321. with the kernel it's desired that the kernel on these cores shares L3 with
  322. the tasks.
  323. # mount -t resctrl resctrl /sys/fs/resctrl
  324. # cd /sys/fs/resctrl
  325. First we reset the schemata for the default group so that the "upper"
  326. 50% of the L3 cache on socket 0, and 50% of memory bandwidth on socket 0
  327. cannot be used by ordinary tasks:
  328. # echo "L3:0=3ff\nMB:0=50" > schemata
  329. Next we make a resource group for our real time cores and give it access
  330. to the "top" 50% of the cache on socket 0 and 50% of memory bandwidth on
  331. socket 0.
  332. # mkdir p0
  333. # echo "L3:0=ffc00\nMB:0=50" > p0/schemata
  334. Finally we move core 4-7 over to the new group and make sure that the
  335. kernel and the tasks running there get 50% of the cache. They should
  336. also get 50% of memory bandwidth assuming that the cores 4-7 are SMT
  337. siblings and only the real time threads are scheduled on the cores 4-7.
  338. # echo F0 > p0/cpus
  339. 4) Locking between applications
  340. Certain operations on the resctrl filesystem, composed of read/writes
  341. to/from multiple files, must be atomic.
  342. As an example, the allocation of an exclusive reservation of L3 cache
  343. involves:
  344. 1. Read the cbmmasks from each directory
  345. 2. Find a contiguous set of bits in the global CBM bitmask that is clear
  346. in any of the directory cbmmasks
  347. 3. Create a new directory
  348. 4. Set the bits found in step 2 to the new directory "schemata" file
  349. If two applications attempt to allocate space concurrently then they can
  350. end up allocating the same bits so the reservations are shared instead of
  351. exclusive.
  352. To coordinate atomic operations on the resctrlfs and to avoid the problem
  353. above, the following locking procedure is recommended:
  354. Locking is based on flock, which is available in libc and also as a shell
  355. script command
  356. Write lock:
  357. A) Take flock(LOCK_EX) on /sys/fs/resctrl
  358. B) Read/write the directory structure.
  359. C) funlock
  360. Read lock:
  361. A) Take flock(LOCK_SH) on /sys/fs/resctrl
  362. B) If success read the directory structure.
  363. C) funlock
  364. Example with bash:
  365. # Atomically read directory structure
  366. $ flock -s /sys/fs/resctrl/ find /sys/fs/resctrl
  367. # Read directory contents and create new subdirectory
  368. $ cat create-dir.sh
  369. find /sys/fs/resctrl/ > output.txt
  370. mask = function-of(output.txt)
  371. mkdir /sys/fs/resctrl/newres/
  372. echo mask > /sys/fs/resctrl/newres/schemata
  373. $ flock /sys/fs/resctrl/ ./create-dir.sh
  374. Example with C:
  375. /*
  376. * Example code do take advisory locks
  377. * before accessing resctrl filesystem
  378. */
  379. #include <sys/file.h>
  380. #include <stdlib.h>
  381. void resctrl_take_shared_lock(int fd)
  382. {
  383. int ret;
  384. /* take shared lock on resctrl filesystem */
  385. ret = flock(fd, LOCK_SH);
  386. if (ret) {
  387. perror("flock");
  388. exit(-1);
  389. }
  390. }
  391. void resctrl_take_exclusive_lock(int fd)
  392. {
  393. int ret;
  394. /* release lock on resctrl filesystem */
  395. ret = flock(fd, LOCK_EX);
  396. if (ret) {
  397. perror("flock");
  398. exit(-1);
  399. }
  400. }
  401. void resctrl_release_lock(int fd)
  402. {
  403. int ret;
  404. /* take shared lock on resctrl filesystem */
  405. ret = flock(fd, LOCK_UN);
  406. if (ret) {
  407. perror("flock");
  408. exit(-1);
  409. }
  410. }
  411. void main(void)
  412. {
  413. int fd, ret;
  414. fd = open("/sys/fs/resctrl", O_DIRECTORY);
  415. if (fd == -1) {
  416. perror("open");
  417. exit(-1);
  418. }
  419. resctrl_take_shared_lock(fd);
  420. /* code to read directory contents */
  421. resctrl_release_lock(fd);
  422. resctrl_take_exclusive_lock(fd);
  423. /* code to read and write directory contents */
  424. resctrl_release_lock(fd);
  425. }
  426. Examples for RDT Monitoring along with allocation usage:
  427. Reading monitored data
  428. ----------------------
  429. Reading an event file (for ex: mon_data/mon_L3_00/llc_occupancy) would
  430. show the current snapshot of LLC occupancy of the corresponding MON
  431. group or CTRL_MON group.
  432. Example 1 (Monitor CTRL_MON group and subset of tasks in CTRL_MON group)
  433. ---------
  434. On a two socket machine (one L3 cache per socket) with just four bits
  435. for cache bit masks
  436. # mount -t resctrl resctrl /sys/fs/resctrl
  437. # cd /sys/fs/resctrl
  438. # mkdir p0 p1
  439. # echo "L3:0=3;1=c" > /sys/fs/resctrl/p0/schemata
  440. # echo "L3:0=3;1=3" > /sys/fs/resctrl/p1/schemata
  441. # echo 5678 > p1/tasks
  442. # echo 5679 > p1/tasks
  443. The default resource group is unmodified, so we have access to all parts
  444. of all caches (its schemata file reads "L3:0=f;1=f").
  445. Tasks that are under the control of group "p0" may only allocate from the
  446. "lower" 50% on cache ID 0, and the "upper" 50% of cache ID 1.
  447. Tasks in group "p1" use the "lower" 50% of cache on both sockets.
  448. Create monitor groups and assign a subset of tasks to each monitor group.
  449. # cd /sys/fs/resctrl/p1/mon_groups
  450. # mkdir m11 m12
  451. # echo 5678 > m11/tasks
  452. # echo 5679 > m12/tasks
  453. fetch data (data shown in bytes)
  454. # cat m11/mon_data/mon_L3_00/llc_occupancy
  455. 16234000
  456. # cat m11/mon_data/mon_L3_01/llc_occupancy
  457. 14789000
  458. # cat m12/mon_data/mon_L3_00/llc_occupancy
  459. 16789000
  460. The parent ctrl_mon group shows the aggregated data.
  461. # cat /sys/fs/resctrl/p1/mon_data/mon_l3_00/llc_occupancy
  462. 31234000
  463. Example 2 (Monitor a task from its creation)
  464. ---------
  465. On a two socket machine (one L3 cache per socket)
  466. # mount -t resctrl resctrl /sys/fs/resctrl
  467. # cd /sys/fs/resctrl
  468. # mkdir p0 p1
  469. An RMID is allocated to the group once its created and hence the <cmd>
  470. below is monitored from its creation.
  471. # echo $$ > /sys/fs/resctrl/p1/tasks
  472. # <cmd>
  473. Fetch the data
  474. # cat /sys/fs/resctrl/p1/mon_data/mon_l3_00/llc_occupancy
  475. 31789000
  476. Example 3 (Monitor without CAT support or before creating CAT groups)
  477. ---------
  478. Assume a system like HSW has only CQM and no CAT support. In this case
  479. the resctrl will still mount but cannot create CTRL_MON directories.
  480. But user can create different MON groups within the root group thereby
  481. able to monitor all tasks including kernel threads.
  482. This can also be used to profile jobs cache size footprint before being
  483. able to allocate them to different allocation groups.
  484. # mount -t resctrl resctrl /sys/fs/resctrl
  485. # cd /sys/fs/resctrl
  486. # mkdir mon_groups/m01
  487. # mkdir mon_groups/m02
  488. # echo 3478 > /sys/fs/resctrl/mon_groups/m01/tasks
  489. # echo 2467 > /sys/fs/resctrl/mon_groups/m02/tasks
  490. Monitor the groups separately and also get per domain data. From the
  491. below its apparent that the tasks are mostly doing work on
  492. domain(socket) 0.
  493. # cat /sys/fs/resctrl/mon_groups/m01/mon_L3_00/llc_occupancy
  494. 31234000
  495. # cat /sys/fs/resctrl/mon_groups/m01/mon_L3_01/llc_occupancy
  496. 34555
  497. # cat /sys/fs/resctrl/mon_groups/m02/mon_L3_00/llc_occupancy
  498. 31234000
  499. # cat /sys/fs/resctrl/mon_groups/m02/mon_L3_01/llc_occupancy
  500. 32789
  501. Example 4 (Monitor real time tasks)
  502. -----------------------------------
  503. A single socket system which has real time tasks running on cores 4-7
  504. and non real time tasks on other cpus. We want to monitor the cache
  505. occupancy of the real time threads on these cores.
  506. # mount -t resctrl resctrl /sys/fs/resctrl
  507. # cd /sys/fs/resctrl
  508. # mkdir p1
  509. Move the cpus 4-7 over to p1
  510. # echo f0 > p0/cpus
  511. View the llc occupancy snapshot
  512. # cat /sys/fs/resctrl/p1/mon_data/mon_L3_00/llc_occupancy
  513. 11234000