Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm_mpam: resctrl: Add plumbing against arm64 task and cpu hooks

arm64 provides helpers for changing a task's and a cpu's mpam partid/pmg
values.

These are used to back a number of resctrl_arch_ functions. Connect them
up.

Tested-by: Gavin Shan <gshan@redhat.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Punit Agrawal <punit.agrawal@oss.qualcomm.com>
Tested-by: Jesse Chick <jessechick@os.amperecomputing.com>
Reviewed-by: Zeng Heng <zengheng4@huawei.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Co-developed-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>

+63
+58
drivers/resctrl/mpam_resctrl.c
··· 8 8 #include <linux/cpu.h> 9 9 #include <linux/cpumask.h> 10 10 #include <linux/errno.h> 11 + #include <linux/limits.h> 11 12 #include <linux/list.h> 12 13 #include <linux/printk.h> 13 14 #include <linux/rculist.h> ··· 35 34 /* The lock for modifying resctrl's domain lists from cpuhp callbacks. */ 36 35 static DEFINE_MUTEX(domain_list_lock); 37 36 37 + static bool cdp_enabled; 38 + 38 39 bool resctrl_arch_alloc_capable(void) 39 40 { 40 41 struct mpam_resctrl_res *res; ··· 58 55 u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) 59 56 { 60 57 return mpam_partid_max + 1; 58 + } 59 + 60 + void resctrl_arch_sched_in(struct task_struct *tsk) 61 + { 62 + lockdep_assert_preemption_disabled(); 63 + 64 + mpam_thread_switch(tsk); 65 + } 66 + 67 + void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid) 68 + { 69 + WARN_ON_ONCE(closid > U16_MAX); 70 + WARN_ON_ONCE(rmid > U8_MAX); 71 + 72 + if (!cdp_enabled) { 73 + mpam_set_cpu_defaults(cpu, closid, closid, rmid, rmid); 74 + } else { 75 + /* 76 + * When CDP is enabled, resctrl halves the closid range and we 77 + * use odd/even partid for one closid. 78 + */ 79 + u32 partid_d = resctrl_get_config_index(closid, CDP_DATA); 80 + u32 partid_i = resctrl_get_config_index(closid, CDP_CODE); 81 + 82 + mpam_set_cpu_defaults(cpu, partid_d, partid_i, rmid, rmid); 83 + } 84 + } 85 + 86 + void resctrl_arch_sync_cpu_closid_rmid(void *info) 87 + { 88 + struct resctrl_cpu_defaults *r = info; 89 + 90 + lockdep_assert_preemption_disabled(); 91 + 92 + if (r) { 93 + resctrl_arch_set_cpu_default_closid_rmid(smp_processor_id(), 94 + r->closid, r->rmid); 95 + } 96 + 97 + resctrl_arch_sched_in(current); 98 + } 99 + 100 + void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid) 101 + { 102 + WARN_ON_ONCE(closid > U16_MAX); 103 + WARN_ON_ONCE(rmid > U8_MAX); 104 + 105 + if (!cdp_enabled) { 106 + mpam_set_task_partid_pmg(tsk, closid, closid, rmid, rmid); 107 + } else { 108 + u32 partid_d = resctrl_get_config_index(closid, CDP_DATA); 109 + u32 partid_i = resctrl_get_config_index(closid, CDP_CODE); 110 + 111 + mpam_set_task_partid_pmg(tsk, partid_d, partid_i, rmid, rmid); 112 + } 61 113 } 62 114 63 115 struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l)
+5
include/linux/arm_mpam.h
··· 52 52 bool resctrl_arch_alloc_capable(void); 53 53 bool resctrl_arch_mon_capable(void); 54 54 55 + void resctrl_arch_set_cpu_default_closid(int cpu, u32 closid); 56 + void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid); 57 + void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid); 58 + void resctrl_arch_sched_in(struct task_struct *tsk); 59 + 55 60 /** 56 61 * mpam_register_requestor() - Register a requestor with the MPAM driver 57 62 * @partid_max: The maximum PARTID value the requestor can generate.