internal.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_RESCTRL_INTERNAL_H
  3. #define _ASM_X86_RESCTRL_INTERNAL_H
  4. #include <linux/resctrl.h>
  5. #include <linux/sched.h>
  6. #include <linux/kernfs.h>
  7. #include <linux/fs_context.h>
  8. #include <linux/jump_label.h>
  9. #include <linux/tick.h>
  10. #include <asm/resctrl.h>
  11. #define L3_QOS_CDP_ENABLE 0x01ULL
  12. #define L2_QOS_CDP_ENABLE 0x01ULL
  13. #define CQM_LIMBOCHECK_INTERVAL 1000
  14. #define MBM_CNTR_WIDTH_BASE 24
  15. #define MBM_OVERFLOW_INTERVAL 1000
  16. #define MAX_MBA_BW 100u
  17. #define MBA_IS_LINEAR 0x4
  18. #define MBM_CNTR_WIDTH_OFFSET_AMD 20
  19. #define RMID_VAL_ERROR BIT_ULL(63)
  20. #define RMID_VAL_UNAVAIL BIT_ULL(62)
  21. /*
  22. * With the above fields in use 62 bits remain in MSR_IA32_QM_CTR for
  23. * data to be returned. The counter width is discovered from the hardware
  24. * as an offset from MBM_CNTR_WIDTH_BASE.
  25. */
  26. #define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE)
  27. /* Reads to Local DRAM Memory */
  28. #define READS_TO_LOCAL_MEM BIT(0)
  29. /* Reads to Remote DRAM Memory */
  30. #define READS_TO_REMOTE_MEM BIT(1)
  31. /* Non-Temporal Writes to Local Memory */
  32. #define NON_TEMP_WRITE_TO_LOCAL_MEM BIT(2)
  33. /* Non-Temporal Writes to Remote Memory */
  34. #define NON_TEMP_WRITE_TO_REMOTE_MEM BIT(3)
  35. /* Reads to Local Memory the system identifies as "Slow Memory" */
  36. #define READS_TO_LOCAL_S_MEM BIT(4)
  37. /* Reads to Remote Memory the system identifies as "Slow Memory" */
  38. #define READS_TO_REMOTE_S_MEM BIT(5)
  39. /* Dirty Victims to All Types of Memory */
  40. #define DIRTY_VICTIMS_TO_ALL_MEM BIT(6)
  41. /* Max event bits supported */
  42. #define MAX_EVT_CONFIG_BITS GENMASK(6, 0)
  43. /**
  44. * cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that
  45. * aren't marked nohz_full
  46. * @mask: The mask to pick a CPU from.
  47. * @exclude_cpu:The CPU to avoid picking.
  48. *
  49. * Returns a CPU from @mask, but not @exclude_cpu. If there are housekeeping
  50. * CPUs that don't use nohz_full, these are preferred. Pass
  51. * RESCTRL_PICK_ANY_CPU to avoid excluding any CPUs.
  52. *
  53. * When a CPU is excluded, returns >= nr_cpu_ids if no CPUs are available.
  54. */
  55. static inline unsigned int
  56. cpumask_any_housekeeping(const struct cpumask *mask, int exclude_cpu)
  57. {
  58. unsigned int cpu, hk_cpu;
  59. if (exclude_cpu == RESCTRL_PICK_ANY_CPU)
  60. cpu = cpumask_any(mask);
  61. else
  62. cpu = cpumask_any_but(mask, exclude_cpu);
  63. /* Only continue if tick_nohz_full_mask has been initialized. */
  64. if (!tick_nohz_full_enabled())
  65. return cpu;
  66. /* If the CPU picked isn't marked nohz_full nothing more needs doing. */
  67. if (cpu < nr_cpu_ids && !tick_nohz_full_cpu(cpu))
  68. return cpu;
  69. /* Try to find a CPU that isn't nohz_full to use in preference */
  70. hk_cpu = cpumask_nth_andnot(0, mask, tick_nohz_full_mask);
  71. if (hk_cpu == exclude_cpu)
  72. hk_cpu = cpumask_nth_andnot(1, mask, tick_nohz_full_mask);
  73. if (hk_cpu < nr_cpu_ids)
  74. cpu = hk_cpu;
  75. return cpu;
  76. }
  77. struct rdt_fs_context {
  78. struct kernfs_fs_context kfc;
  79. bool enable_cdpl2;
  80. bool enable_cdpl3;
  81. bool enable_mba_mbps;
  82. bool enable_debug;
  83. };
  84. static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
  85. {
  86. struct kernfs_fs_context *kfc = fc->fs_private;
  87. return container_of(kfc, struct rdt_fs_context, kfc);
  88. }
  89. /**
  90. * struct mon_evt - Entry in the event list of a resource
  91. * @evtid: event id
  92. * @name: name of the event
  93. * @configurable: true if the event is configurable
  94. * @list: entry in &rdt_resource->evt_list
  95. */
  96. struct mon_evt {
  97. enum resctrl_event_id evtid;
  98. char *name;
  99. bool configurable;
  100. struct list_head list;
  101. };
  102. /**
  103. * union mon_data_bits - Monitoring details for each event file.
  104. * @priv: Used to store monitoring event data in @u
  105. * as kernfs private data.
  106. * @u.rid: Resource id associated with the event file.
  107. * @u.evtid: Event id associated with the event file.
  108. * @u.sum: Set when event must be summed across multiple
  109. * domains.
  110. * @u.domid: When @u.sum is zero this is the domain to which
  111. * the event file belongs. When @sum is one this
  112. * is the id of the L3 cache that all domains to be
  113. * summed share.
  114. * @u: Name of the bit fields struct.
  115. */
  116. union mon_data_bits {
  117. void *priv;
  118. struct {
  119. unsigned int rid : 10;
  120. enum resctrl_event_id evtid : 7;
  121. unsigned int sum : 1;
  122. unsigned int domid : 14;
  123. } u;
  124. };
  125. /**
  126. * struct rmid_read - Data passed across smp_call*() to read event count.
  127. * @rgrp: Resource group for which the counter is being read. If it is a parent
  128. * resource group then its event count is summed with the count from all
  129. * its child resource groups.
  130. * @r: Resource describing the properties of the event being read.
  131. * @d: Domain that the counter should be read from. If NULL then sum all
  132. * domains in @r sharing L3 @ci.id
  133. * @evtid: Which monitor event to read.
  134. * @first: Initialize MBM counter when true.
  135. * @ci: Cacheinfo for L3. Only set when @d is NULL. Used when summing domains.
  136. * @err: Error encountered when reading counter.
  137. * @val: Returned value of event counter. If @rgrp is a parent resource group,
  138. * @val includes the sum of event counts from its child resource groups.
  139. * If @d is NULL, @val includes the sum of all domains in @r sharing @ci.id,
  140. * (summed across child resource groups if @rgrp is a parent resource group).
  141. * @arch_mon_ctx: Hardware monitor allocated for this read request (MPAM only).
  142. */
  143. struct rmid_read {
  144. struct rdtgroup *rgrp;
  145. struct rdt_resource *r;
  146. struct rdt_mon_domain *d;
  147. enum resctrl_event_id evtid;
  148. bool first;
  149. struct cacheinfo *ci;
  150. int err;
  151. u64 val;
  152. void *arch_mon_ctx;
  153. };
  154. extern unsigned int rdt_mon_features;
  155. extern struct list_head resctrl_schema_all;
  156. extern bool resctrl_mounted;
  157. enum rdt_group_type {
  158. RDTCTRL_GROUP = 0,
  159. RDTMON_GROUP,
  160. RDT_NUM_GROUP,
  161. };
  162. /**
  163. * enum rdtgrp_mode - Mode of a RDT resource group
  164. * @RDT_MODE_SHAREABLE: This resource group allows sharing of its allocations
  165. * @RDT_MODE_EXCLUSIVE: No sharing of this resource group's allocations allowed
  166. * @RDT_MODE_PSEUDO_LOCKSETUP: Resource group will be used for Pseudo-Locking
  167. * @RDT_MODE_PSEUDO_LOCKED: No sharing of this resource group's allocations
  168. * allowed AND the allocations are Cache Pseudo-Locked
  169. * @RDT_NUM_MODES: Total number of modes
  170. *
  171. * The mode of a resource group enables control over the allowed overlap
  172. * between allocations associated with different resource groups (classes
  173. * of service). User is able to modify the mode of a resource group by
  174. * writing to the "mode" resctrl file associated with the resource group.
  175. *
  176. * The "shareable", "exclusive", and "pseudo-locksetup" modes are set by
  177. * writing the appropriate text to the "mode" file. A resource group enters
  178. * "pseudo-locked" mode after the schemata is written while the resource
  179. * group is in "pseudo-locksetup" mode.
  180. */
  181. enum rdtgrp_mode {
  182. RDT_MODE_SHAREABLE = 0,
  183. RDT_MODE_EXCLUSIVE,
  184. RDT_MODE_PSEUDO_LOCKSETUP,
  185. RDT_MODE_PSEUDO_LOCKED,
  186. /* Must be last */
  187. RDT_NUM_MODES,
  188. };
  189. /**
  190. * struct mongroup - store mon group's data in resctrl fs.
  191. * @mon_data_kn: kernfs node for the mon_data directory
  192. * @parent: parent rdtgrp
  193. * @crdtgrp_list: child rdtgroup node list
  194. * @rmid: rmid for this rdtgroup
  195. */
  196. struct mongroup {
  197. struct kernfs_node *mon_data_kn;
  198. struct rdtgroup *parent;
  199. struct list_head crdtgrp_list;
  200. u32 rmid;
  201. };
  202. /**
  203. * struct pseudo_lock_region - pseudo-lock region information
  204. * @s: Resctrl schema for the resource to which this
  205. * pseudo-locked region belongs
  206. * @d: RDT domain to which this pseudo-locked region
  207. * belongs
  208. * @cbm: bitmask of the pseudo-locked region
  209. * @lock_thread_wq: waitqueue used to wait on the pseudo-locking thread
  210. * completion
  211. * @thread_done: variable used by waitqueue to test if pseudo-locking
  212. * thread completed
  213. * @cpu: core associated with the cache on which the setup code
  214. * will be run
  215. * @line_size: size of the cache lines
  216. * @size: size of pseudo-locked region in bytes
  217. * @kmem: the kernel memory associated with pseudo-locked region
  218. * @minor: minor number of character device associated with this
  219. * region
  220. * @debugfs_dir: pointer to this region's directory in the debugfs
  221. * filesystem
  222. * @pm_reqs: Power management QoS requests related to this region
  223. */
  224. struct pseudo_lock_region {
  225. struct resctrl_schema *s;
  226. struct rdt_ctrl_domain *d;
  227. u32 cbm;
  228. wait_queue_head_t lock_thread_wq;
  229. int thread_done;
  230. int cpu;
  231. unsigned int line_size;
  232. unsigned int size;
  233. void *kmem;
  234. unsigned int minor;
  235. struct dentry *debugfs_dir;
  236. struct list_head pm_reqs;
  237. };
  238. /**
  239. * struct rdtgroup - store rdtgroup's data in resctrl file system.
  240. * @kn: kernfs node
  241. * @rdtgroup_list: linked list for all rdtgroups
  242. * @closid: closid for this rdtgroup
  243. * @cpu_mask: CPUs assigned to this rdtgroup
  244. * @flags: status bits
  245. * @waitcount: how many cpus expect to find this
  246. * group when they acquire rdtgroup_mutex
  247. * @type: indicates type of this rdtgroup - either
  248. * monitor only or ctrl_mon group
  249. * @mon: mongroup related data
  250. * @mode: mode of resource group
  251. * @plr: pseudo-locked region
  252. */
  253. struct rdtgroup {
  254. struct kernfs_node *kn;
  255. struct list_head rdtgroup_list;
  256. u32 closid;
  257. struct cpumask cpu_mask;
  258. int flags;
  259. atomic_t waitcount;
  260. enum rdt_group_type type;
  261. struct mongroup mon;
  262. enum rdtgrp_mode mode;
  263. struct pseudo_lock_region *plr;
  264. };
  265. /* rdtgroup.flags */
  266. #define RDT_DELETED 1
  267. /* rftype.flags */
  268. #define RFTYPE_FLAGS_CPUS_LIST 1
  269. /*
  270. * Define the file type flags for base and info directories.
  271. */
  272. #define RFTYPE_INFO BIT(0)
  273. #define RFTYPE_BASE BIT(1)
  274. #define RFTYPE_CTRL BIT(4)
  275. #define RFTYPE_MON BIT(5)
  276. #define RFTYPE_TOP BIT(6)
  277. #define RFTYPE_RES_CACHE BIT(8)
  278. #define RFTYPE_RES_MB BIT(9)
  279. #define RFTYPE_DEBUG BIT(10)
  280. #define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL)
  281. #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
  282. #define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
  283. #define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
  284. #define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
  285. /* List of all resource groups */
  286. extern struct list_head rdt_all_groups;
  287. extern int max_name_width, max_data_width;
  288. int __init rdtgroup_init(void);
  289. void __exit rdtgroup_exit(void);
  290. /**
  291. * struct rftype - describe each file in the resctrl file system
  292. * @name: File name
  293. * @mode: Access mode
  294. * @kf_ops: File operations
  295. * @flags: File specific RFTYPE_FLAGS_* flags
  296. * @fflags: File specific RFTYPE_* flags
  297. * @seq_show: Show content of the file
  298. * @write: Write to the file
  299. */
  300. struct rftype {
  301. char *name;
  302. umode_t mode;
  303. const struct kernfs_ops *kf_ops;
  304. unsigned long flags;
  305. unsigned long fflags;
  306. int (*seq_show)(struct kernfs_open_file *of,
  307. struct seq_file *sf, void *v);
  308. /*
  309. * write() is the generic write callback which maps directly to
  310. * kernfs write operation and overrides all other operations.
  311. * Maximum write size is determined by ->max_write_len.
  312. */
  313. ssize_t (*write)(struct kernfs_open_file *of,
  314. char *buf, size_t nbytes, loff_t off);
  315. };
  316. /**
  317. * struct mbm_state - status for each MBM counter in each domain
  318. * @prev_bw_bytes: Previous bytes value read for bandwidth calculation
  319. * @prev_bw: The most recent bandwidth in MBps
  320. */
  321. struct mbm_state {
  322. u64 prev_bw_bytes;
  323. u32 prev_bw;
  324. };
  325. /**
  326. * struct arch_mbm_state - values used to compute resctrl_arch_rmid_read()s
  327. * return value.
  328. * @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes)
  329. * @prev_msr: Value of IA32_QM_CTR last time it was read for the RMID used to
  330. * find this struct.
  331. */
  332. struct arch_mbm_state {
  333. u64 chunks;
  334. u64 prev_msr;
  335. };
  336. /**
  337. * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share
  338. * a resource for a control function
  339. * @d_resctrl: Properties exposed to the resctrl file system
  340. * @ctrl_val: array of cache or mem ctrl values (indexed by CLOSID)
  341. *
  342. * Members of this structure are accessed via helpers that provide abstraction.
  343. */
  344. struct rdt_hw_ctrl_domain {
  345. struct rdt_ctrl_domain d_resctrl;
  346. u32 *ctrl_val;
  347. };
  348. /**
  349. * struct rdt_hw_mon_domain - Arch private attributes of a set of CPUs that share
  350. * a resource for a monitor function
  351. * @d_resctrl: Properties exposed to the resctrl file system
  352. * @arch_mbm_total: arch private state for MBM total bandwidth
  353. * @arch_mbm_local: arch private state for MBM local bandwidth
  354. *
  355. * Members of this structure are accessed via helpers that provide abstraction.
  356. */
  357. struct rdt_hw_mon_domain {
  358. struct rdt_mon_domain d_resctrl;
  359. struct arch_mbm_state *arch_mbm_total;
  360. struct arch_mbm_state *arch_mbm_local;
  361. };
  362. static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct rdt_ctrl_domain *r)
  363. {
  364. return container_of(r, struct rdt_hw_ctrl_domain, d_resctrl);
  365. }
  366. static inline struct rdt_hw_mon_domain *resctrl_to_arch_mon_dom(struct rdt_mon_domain *r)
  367. {
  368. return container_of(r, struct rdt_hw_mon_domain, d_resctrl);
  369. }
  370. /**
  371. * struct msr_param - set a range of MSRs from a domain
  372. * @res: The resource to use
  373. * @dom: The domain to update
  374. * @low: Beginning index from base MSR
  375. * @high: End index
  376. */
  377. struct msr_param {
  378. struct rdt_resource *res;
  379. struct rdt_ctrl_domain *dom;
  380. u32 low;
  381. u32 high;
  382. };
  383. static inline bool is_llc_occupancy_enabled(void)
  384. {
  385. return (rdt_mon_features & (1 << QOS_L3_OCCUP_EVENT_ID));
  386. }
  387. static inline bool is_mbm_total_enabled(void)
  388. {
  389. return (rdt_mon_features & (1 << QOS_L3_MBM_TOTAL_EVENT_ID));
  390. }
  391. static inline bool is_mbm_local_enabled(void)
  392. {
  393. return (rdt_mon_features & (1 << QOS_L3_MBM_LOCAL_EVENT_ID));
  394. }
  395. static inline bool is_mbm_enabled(void)
  396. {
  397. return (is_mbm_total_enabled() || is_mbm_local_enabled());
  398. }
  399. static inline bool is_mbm_event(int e)
  400. {
  401. return (e >= QOS_L3_MBM_TOTAL_EVENT_ID &&
  402. e <= QOS_L3_MBM_LOCAL_EVENT_ID);
  403. }
  404. struct rdt_parse_data {
  405. struct rdtgroup *rdtgrp;
  406. char *buf;
  407. };
  408. /**
  409. * struct rdt_hw_resource - arch private attributes of a resctrl resource
  410. * @r_resctrl: Attributes of the resource used directly by resctrl.
  411. * @num_closid: Maximum number of closid this hardware can support,
  412. * regardless of CDP. This is exposed via
  413. * resctrl_arch_get_num_closid() to avoid confusion
  414. * with struct resctrl_schema's property of the same name,
  415. * which has been corrected for features like CDP.
  416. * @msr_base: Base MSR address for CBMs
  417. * @msr_update: Function pointer to update QOS MSRs
  418. * @mon_scale: cqm counter * mon_scale = occupancy in bytes
  419. * @mbm_width: Monitor width, to detect and correct for overflow.
  420. * @mbm_cfg_mask: Bandwidth sources that can be tracked when Bandwidth
  421. * Monitoring Event Configuration (BMEC) is supported.
  422. * @cdp_enabled: CDP state of this resource
  423. *
  424. * Members of this structure are either private to the architecture
  425. * e.g. mbm_width, or accessed via helpers that provide abstraction. e.g.
  426. * msr_update and msr_base.
  427. */
  428. struct rdt_hw_resource {
  429. struct rdt_resource r_resctrl;
  430. u32 num_closid;
  431. unsigned int msr_base;
  432. void (*msr_update)(struct msr_param *m);
  433. unsigned int mon_scale;
  434. unsigned int mbm_width;
  435. unsigned int mbm_cfg_mask;
  436. bool cdp_enabled;
  437. };
  438. static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r)
  439. {
  440. return container_of(r, struct rdt_hw_resource, r_resctrl);
  441. }
  442. int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
  443. struct rdt_ctrl_domain *d);
  444. int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
  445. struct rdt_ctrl_domain *d);
  446. extern struct mutex rdtgroup_mutex;
  447. extern struct rdt_hw_resource rdt_resources_all[];
  448. extern struct rdtgroup rdtgroup_default;
  449. extern struct dentry *debugfs_resctrl;
  450. enum resctrl_res_level {
  451. RDT_RESOURCE_L3,
  452. RDT_RESOURCE_L2,
  453. RDT_RESOURCE_MBA,
  454. RDT_RESOURCE_SMBA,
  455. /* Must be the last */
  456. RDT_NUM_RESOURCES,
  457. };
  458. static inline struct rdt_resource *resctrl_inc(struct rdt_resource *res)
  459. {
  460. struct rdt_hw_resource *hw_res = resctrl_to_arch_res(res);
  461. hw_res++;
  462. return &hw_res->r_resctrl;
  463. }
  464. static inline bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l)
  465. {
  466. return rdt_resources_all[l].cdp_enabled;
  467. }
  468. int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable);
  469. void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain *d);
  470. /*
  471. * To return the common struct rdt_resource, which is contained in struct
  472. * rdt_hw_resource, walk the resctrl member of struct rdt_hw_resource.
  473. */
  474. #define for_each_rdt_resource(r) \
  475. for (r = &rdt_resources_all[0].r_resctrl; \
  476. r <= &rdt_resources_all[RDT_NUM_RESOURCES - 1].r_resctrl; \
  477. r = resctrl_inc(r))
  478. #define for_each_capable_rdt_resource(r) \
  479. for_each_rdt_resource(r) \
  480. if (r->alloc_capable || r->mon_capable)
  481. #define for_each_alloc_capable_rdt_resource(r) \
  482. for_each_rdt_resource(r) \
  483. if (r->alloc_capable)
  484. #define for_each_mon_capable_rdt_resource(r) \
  485. for_each_rdt_resource(r) \
  486. if (r->mon_capable)
  487. /* CPUID.(EAX=10H, ECX=ResID=1).EAX */
  488. union cpuid_0x10_1_eax {
  489. struct {
  490. unsigned int cbm_len:5;
  491. } split;
  492. unsigned int full;
  493. };
  494. /* CPUID.(EAX=10H, ECX=ResID=3).EAX */
  495. union cpuid_0x10_3_eax {
  496. struct {
  497. unsigned int max_delay:12;
  498. } split;
  499. unsigned int full;
  500. };
  501. /* CPUID.(EAX=10H, ECX=ResID).ECX */
  502. union cpuid_0x10_x_ecx {
  503. struct {
  504. unsigned int reserved:3;
  505. unsigned int noncont:1;
  506. } split;
  507. unsigned int full;
  508. };
  509. /* CPUID.(EAX=10H, ECX=ResID).EDX */
  510. union cpuid_0x10_x_edx {
  511. struct {
  512. unsigned int cos_max:16;
  513. } split;
  514. unsigned int full;
  515. };
  516. void rdt_last_cmd_clear(void);
  517. void rdt_last_cmd_puts(const char *s);
  518. __printf(1, 2)
  519. void rdt_last_cmd_printf(const char *fmt, ...);
  520. void rdt_ctrl_update(void *arg);
  521. struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_node *kn);
  522. void rdtgroup_kn_unlock(struct kernfs_node *kn);
  523. int rdtgroup_kn_mode_restrict(struct rdtgroup *r, const char *name);
  524. int rdtgroup_kn_mode_restore(struct rdtgroup *r, const char *name,
  525. umode_t mask);
  526. struct rdt_domain_hdr *rdt_find_domain(struct list_head *h, int id,
  527. struct list_head **pos);
  528. ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
  529. char *buf, size_t nbytes, loff_t off);
  530. int rdtgroup_schemata_show(struct kernfs_open_file *of,
  531. struct seq_file *s, void *v);
  532. bool rdtgroup_cbm_overlaps(struct resctrl_schema *s, struct rdt_ctrl_domain *d,
  533. unsigned long cbm, int closid, bool exclusive);
  534. unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_ctrl_domain *d,
  535. unsigned long cbm);
  536. enum rdtgrp_mode rdtgroup_mode_by_closid(int closid);
  537. int rdtgroup_tasks_assigned(struct rdtgroup *r);
  538. int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp);
  539. int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp);
  540. bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_ctrl_domain *d, unsigned long cbm);
  541. bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_ctrl_domain *d);
  542. int rdt_pseudo_lock_init(void);
  543. void rdt_pseudo_lock_release(void);
  544. int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp);
  545. void rdtgroup_pseudo_lock_remove(struct rdtgroup *rdtgrp);
  546. struct rdt_ctrl_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r);
  547. struct rdt_mon_domain *get_mon_domain_from_cpu(int cpu, struct rdt_resource *r);
  548. int closids_supported(void);
  549. void closid_free(int closid);
  550. int alloc_rmid(u32 closid);
  551. void free_rmid(u32 closid, u32 rmid);
  552. int rdt_get_mon_l3_config(struct rdt_resource *r);
  553. void __exit rdt_put_mon_l3_config(void);
  554. bool __init rdt_cpu_has(int flag);
  555. void mon_event_count(void *info);
  556. int rdtgroup_mondata_show(struct seq_file *m, void *arg);
  557. void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
  558. struct rdt_mon_domain *d, struct rdtgroup *rdtgrp,
  559. cpumask_t *cpumask, int evtid, int first);
  560. void mbm_setup_overflow_handler(struct rdt_mon_domain *dom,
  561. unsigned long delay_ms,
  562. int exclude_cpu);
  563. void mbm_handle_overflow(struct work_struct *work);
  564. void __init intel_rdt_mbm_apply_quirk(void);
  565. bool is_mba_sc(struct rdt_resource *r);
  566. void cqm_setup_limbo_handler(struct rdt_mon_domain *dom, unsigned long delay_ms,
  567. int exclude_cpu);
  568. void cqm_handle_limbo(struct work_struct *work);
  569. bool has_busy_rmid(struct rdt_mon_domain *d);
  570. void __check_limbo(struct rdt_mon_domain *d, bool force_free);
  571. void rdt_domain_reconfigure_cdp(struct rdt_resource *r);
  572. void __init thread_throttle_mode_init(void);
  573. void __init mbm_config_rftype_init(const char *config);
  574. void rdt_staged_configs_clear(void);
  575. bool closid_allocated(unsigned int closid);
  576. int resctrl_find_cleanest_closid(void);
  577. #endif /* _ASM_X86_RESCTRL_INTERNAL_H */