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