]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/resctrl: Make resctrl_arch_pseudo_lock_fn() take a plr
authorJames Morse <james.morse@arm.com>
Tue, 11 Mar 2025 18:37:11 +0000 (18:37 +0000)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 12 Mar 2025 11:24:33 +0000 (12:24 +0100)
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
arch/x86/include/asm/resctrl.h
arch/x86/kernel/cpu/resctrl/internal.h
arch/x86/kernel/cpu/resctrl/pseudo_lock.c
include/linux/resctrl.h

index 86407dbde583e99a333f1cbf1da048c657e293c9..011bf67a18664faab42a74a3aba1af2aa488eb8b 100644 (file)
@@ -204,7 +204,7 @@ static inline void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid,
                                             void *ctx) { };
 
 u64 resctrl_arch_get_prefetch_disable_bits(void);
-int resctrl_arch_pseudo_lock_fn(void *_rdtgrp);
+int resctrl_arch_pseudo_lock_fn(void *_plr);
 int resctrl_arch_measure_cycles_lat_fn(void *_plr);
 int resctrl_arch_measure_l2_residency(void *_plr);
 int resctrl_arch_measure_l3_residency(void *_plr);
index 8d35bb423aaddfa78708171555f3ebf1ac88d8e4..0d13006e920b3f513740c2d286cd4d43a588f3c0 100644 (file)
@@ -208,43 +208,6 @@ struct mongroup {
        u32                     rmid;
 };
 
-/**
- * struct pseudo_lock_region - pseudo-lock region information
- * @s:                 Resctrl schema for the resource to which this
- *                     pseudo-locked region belongs
- * @d:                 RDT domain to which this pseudo-locked region
- *                     belongs
- * @cbm:               bitmask of the pseudo-locked region
- * @lock_thread_wq:    waitqueue used to wait on the pseudo-locking thread
- *                     completion
- * @thread_done:       variable used by waitqueue to test if pseudo-locking
- *                     thread completed
- * @cpu:               core associated with the cache on which the setup code
- *                     will be run
- * @line_size:         size of the cache lines
- * @size:              size of pseudo-locked region in bytes
- * @kmem:              the kernel memory associated with pseudo-locked region
- * @minor:             minor number of character device associated with this
- *                     region
- * @debugfs_dir:       pointer to this region's directory in the debugfs
- *                     filesystem
- * @pm_reqs:           Power management QoS requests related to this region
- */
-struct pseudo_lock_region {
-       struct resctrl_schema   *s;
-       struct rdt_ctrl_domain  *d;
-       u32                     cbm;
-       wait_queue_head_t       lock_thread_wq;
-       int                     thread_done;
-       int                     cpu;
-       unsigned int            line_size;
-       unsigned int            size;
-       void                    *kmem;
-       unsigned int            minor;
-       struct dentry           *debugfs_dir;
-       struct list_head        pm_reqs;
-};
-
 /**
  * struct rdtgroup - store rdtgroup's data in resctrl file system.
  * @kn:                                kernfs node
index 90044a01d000392e76cd8a146e92d92065572f78..01fa7890b43f57379f7e89b772900e7bdf34bc1f 100644 (file)
@@ -414,7 +414,7 @@ static void pseudo_lock_free(struct rdtgroup *rdtgrp)
 
 /**
  * resctrl_arch_pseudo_lock_fn - Load kernel memory into cache
- * @_rdtgrp: resource group to which pseudo-lock region belongs
+ * @_plr: the pseudo-lock region descriptor
  *
  * This is the core pseudo-locking flow.
  *
@@ -431,10 +431,9 @@ static void pseudo_lock_free(struct rdtgroup *rdtgrp)
  *
  * Return: 0. Waiter on waitqueue will be woken on completion.
  */
-int resctrl_arch_pseudo_lock_fn(void *_rdtgrp)
+int resctrl_arch_pseudo_lock_fn(void *_plr)
 {
-       struct rdtgroup *rdtgrp = _rdtgrp;
-       struct pseudo_lock_region *plr = rdtgrp->plr;
+       struct pseudo_lock_region *plr = _plr;
        u32 rmid_p, closid_p;
        unsigned long i;
        u64 saved_msr;
@@ -494,7 +493,8 @@ int resctrl_arch_pseudo_lock_fn(void *_rdtgrp)
         * pseudo-locked followed by reading of kernel memory to load it
         * into the cache.
         */
-       __wrmsr(MSR_IA32_PQR_ASSOC, rmid_p, rdtgrp->closid);
+       __wrmsr(MSR_IA32_PQR_ASSOC, rmid_p, plr->closid);
+
        /*
         * Cache was flushed earlier. Now access kernel memory to read it
         * into cache region associated with just activated plr->closid.
@@ -1312,7 +1312,7 @@ int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)
 
        plr->thread_done = 0;
 
-       thread = kthread_run_on_cpu(resctrl_arch_pseudo_lock_fn, rdtgrp,
+       thread = kthread_run_on_cpu(resctrl_arch_pseudo_lock_fn, plr,
                                    plr->cpu, "pseudo_lock/%u");
        if (IS_ERR(thread)) {
                ret = PTR_ERR(thread);
index 914df24ffe483cf8fa79f769c9b06949a8928179..226cc5c0d765f244456e3887ef7e81f689cb242c 100644 (file)
@@ -58,6 +58,45 @@ enum resctrl_conf_type {
 
 #define CDP_NUM_TYPES  (CDP_DATA + 1)
 
+/*
+ * struct pseudo_lock_region - pseudo-lock region information
+ * @s:                 Resctrl schema for the resource to which this
+ *                     pseudo-locked region belongs
+ * @closid:            The closid that this pseudo-locked region uses
+ * @d:                 RDT domain to which this pseudo-locked region
+ *                     belongs
+ * @cbm:               bitmask of the pseudo-locked region
+ * @lock_thread_wq:    waitqueue used to wait on the pseudo-locking thread
+ *                     completion
+ * @thread_done:       variable used by waitqueue to test if pseudo-locking
+ *                     thread completed
+ * @cpu:               core associated with the cache on which the setup code
+ *                     will be run
+ * @line_size:         size of the cache lines
+ * @size:              size of pseudo-locked region in bytes
+ * @kmem:              the kernel memory associated with pseudo-locked region
+ * @minor:             minor number of character device associated with this
+ *                     region
+ * @debugfs_dir:       pointer to this region's directory in the debugfs
+ *                     filesystem
+ * @pm_reqs:           Power management QoS requests related to this region
+ */
+struct pseudo_lock_region {
+       struct resctrl_schema   *s;
+       u32                     closid;
+       struct rdt_ctrl_domain  *d;
+       u32                     cbm;
+       wait_queue_head_t       lock_thread_wq;
+       int                     thread_done;
+       int                     cpu;
+       unsigned int            line_size;
+       unsigned int            size;
+       void                    *kmem;
+       unsigned int            minor;
+       struct dentry           *debugfs_dir;
+       struct list_head        pm_reqs;
+};
+
 /**
  * struct resctrl_staged_config - parsed configuration to be applied
  * @new_ctrl:          new ctrl value to be loaded