Skip to content

Commit 4cf9acf

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr
resctrl_arch_pseudo_lock_fn() has architecture specific behaviour, and takes a struct rdtgroup as an argument. After the filesystem code moves to /fs/, the definition of struct rdtgroup will not be available to the architecture code. The only reason resctrl_arch_pseudo_lock_fn() wants the rdtgroup is for the CLOSID. Embed that in the pseudo_lock_region as a closid, and move the definition of struct pseudo_lock_region to resctrl.h. Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Babu Moger <babu.moger@amd.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64 Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64 Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64 Tested-by: Babu Moger <babu.moger@amd.com> Link: https://lore.kernel.org/r/20250311183715.16445-27-james.morse@arm.com
1 parent 4d20f38 commit 4cf9acf

File tree

4 files changed

+46
-44
lines changed

4 files changed

+46
-44
lines changed

arch/x86/include/asm/resctrl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid,
204204
void *ctx) { };
205205

206206
u64 resctrl_arch_get_prefetch_disable_bits(void);
207-
int resctrl_arch_pseudo_lock_fn(void *_rdtgrp);
207+
int resctrl_arch_pseudo_lock_fn(void *_plr);
208208
int resctrl_arch_measure_cycles_lat_fn(void *_plr);
209209
int resctrl_arch_measure_l2_residency(void *_plr);
210210
int resctrl_arch_measure_l3_residency(void *_plr);

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -208,43 +208,6 @@ struct mongroup {
208208
u32 rmid;
209209
};
210210

211-
/**
212-
* struct pseudo_lock_region - pseudo-lock region information
213-
* @s: Resctrl schema for the resource to which this
214-
* pseudo-locked region belongs
215-
* @d: RDT domain to which this pseudo-locked region
216-
* belongs
217-
* @cbm: bitmask of the pseudo-locked region
218-
* @lock_thread_wq: waitqueue used to wait on the pseudo-locking thread
219-
* completion
220-
* @thread_done: variable used by waitqueue to test if pseudo-locking
221-
* thread completed
222-
* @cpu: core associated with the cache on which the setup code
223-
* will be run
224-
* @line_size: size of the cache lines
225-
* @size: size of pseudo-locked region in bytes
226-
* @kmem: the kernel memory associated with pseudo-locked region
227-
* @minor: minor number of character device associated with this
228-
* region
229-
* @debugfs_dir: pointer to this region's directory in the debugfs
230-
* filesystem
231-
* @pm_reqs: Power management QoS requests related to this region
232-
*/
233-
struct pseudo_lock_region {
234-
struct resctrl_schema *s;
235-
struct rdt_ctrl_domain *d;
236-
u32 cbm;
237-
wait_queue_head_t lock_thread_wq;
238-
int thread_done;
239-
int cpu;
240-
unsigned int line_size;
241-
unsigned int size;
242-
void *kmem;
243-
unsigned int minor;
244-
struct dentry *debugfs_dir;
245-
struct list_head pm_reqs;
246-
};
247-
248211
/**
249212
* struct rdtgroup - store rdtgroup's data in resctrl file system.
250213
* @kn: kernfs node

arch/x86/kernel/cpu/resctrl/pseudo_lock.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static void pseudo_lock_free(struct rdtgroup *rdtgrp)
414414

415415
/**
416416
* resctrl_arch_pseudo_lock_fn - Load kernel memory into cache
417-
* @_rdtgrp: resource group to which pseudo-lock region belongs
417+
* @_plr: the pseudo-lock region descriptor
418418
*
419419
* This is the core pseudo-locking flow.
420420
*
@@ -431,10 +431,9 @@ static void pseudo_lock_free(struct rdtgroup *rdtgrp)
431431
*
432432
* Return: 0. Waiter on waitqueue will be woken on completion.
433433
*/
434-
int resctrl_arch_pseudo_lock_fn(void *_rdtgrp)
434+
int resctrl_arch_pseudo_lock_fn(void *_plr)
435435
{
436-
struct rdtgroup *rdtgrp = _rdtgrp;
437-
struct pseudo_lock_region *plr = rdtgrp->plr;
436+
struct pseudo_lock_region *plr = _plr;
438437
u32 rmid_p, closid_p;
439438
unsigned long i;
440439
u64 saved_msr;
@@ -494,7 +493,8 @@ int resctrl_arch_pseudo_lock_fn(void *_rdtgrp)
494493
* pseudo-locked followed by reading of kernel memory to load it
495494
* into the cache.
496495
*/
497-
__wrmsr(MSR_IA32_PQR_ASSOC, rmid_p, rdtgrp->closid);
496+
__wrmsr(MSR_IA32_PQR_ASSOC, rmid_p, plr->closid);
497+
498498
/*
499499
* Cache was flushed earlier. Now access kernel memory to read it
500500
* into cache region associated with just activated plr->closid.
@@ -1312,7 +1312,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)
13121312

13131313
plr->thread_done = 0;
13141314

1315-
thread = kthread_run_on_cpu(resctrl_arch_pseudo_lock_fn, rdtgrp,
1315+
thread = kthread_run_on_cpu(resctrl_arch_pseudo_lock_fn, plr,
13161316
plr->cpu, "pseudo_lock/%u");
13171317
if (IS_ERR(thread)) {
13181318
ret = PTR_ERR(thread);

include/linux/resctrl.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,45 @@ enum resctrl_conf_type {
5858

5959
#define CDP_NUM_TYPES (CDP_DATA + 1)
6060

61+
/*
62+
* struct pseudo_lock_region - pseudo-lock region information
63+
* @s: Resctrl schema for the resource to which this
64+
* pseudo-locked region belongs
65+
* @closid: The closid that this pseudo-locked region uses
66+
* @d: RDT domain to which this pseudo-locked region
67+
* belongs
68+
* @cbm: bitmask of the pseudo-locked region
69+
* @lock_thread_wq: waitqueue used to wait on the pseudo-locking thread
70+
* completion
71+
* @thread_done: variable used by waitqueue to test if pseudo-locking
72+
* thread completed
73+
* @cpu: core associated with the cache on which the setup code
74+
* will be run
75+
* @line_size: size of the cache lines
76+
* @size: size of pseudo-locked region in bytes
77+
* @kmem: the kernel memory associated with pseudo-locked region
78+
* @minor: minor number of character device associated with this
79+
* region
80+
* @debugfs_dir: pointer to this region's directory in the debugfs
81+
* filesystem
82+
* @pm_reqs: Power management QoS requests related to this region
83+
*/
84+
struct pseudo_lock_region {
85+
struct resctrl_schema *s;
86+
u32 closid;
87+
struct rdt_ctrl_domain *d;
88+
u32 cbm;
89+
wait_queue_head_t lock_thread_wq;
90+
int thread_done;
91+
int cpu;
92+
unsigned int line_size;
93+
unsigned int size;
94+
void *kmem;
95+
unsigned int minor;
96+
struct dentry *debugfs_dir;
97+
struct list_head pm_reqs;
98+
};
99+
61100
/**
62101
* struct resctrl_staged_config - parsed configuration to be applied
63102
* @new_ctrl: new ctrl value to be loaded

0 commit comments

Comments
 (0)