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: Pick the caches we will use as resctrl resources

Systems with MPAM support may have a variety of control types at any point
of their system layout. We can only expose certain types of control, and
only if they exist at particular locations.

Start with the well-known caches. These have to be depth 2 or 3 and support
MPAM's cache portion bitmap controls, with a number of portions fewer than
resctrl's limit.

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>

+89 -2
+89 -2
drivers/resctrl/mpam_resctrl.c
··· 65 65 return &mpam_resctrl_controls[l].resctrl_res; 66 66 } 67 67 68 + static bool cache_has_usable_cpor(struct mpam_class *class) 69 + { 70 + struct mpam_props *cprops = &class->props; 71 + 72 + if (!mpam_has_feature(mpam_feat_cpor_part, cprops)) 73 + return false; 74 + 75 + /* resctrl uses u32 for all bitmap configurations */ 76 + return class->props.cpbm_wd <= 32; 77 + } 78 + 79 + /* Test whether we can export MPAM_CLASS_CACHE:{2,3}? */ 80 + static void mpam_resctrl_pick_caches(void) 81 + { 82 + struct mpam_class *class; 83 + struct mpam_resctrl_res *res; 84 + 85 + lockdep_assert_cpus_held(); 86 + 87 + guard(srcu)(&mpam_srcu); 88 + list_for_each_entry_srcu(class, &mpam_classes, classes_list, 89 + srcu_read_lock_held(&mpam_srcu)) { 90 + if (class->type != MPAM_CLASS_CACHE) { 91 + pr_debug("class %u is not a cache\n", class->level); 92 + continue; 93 + } 94 + 95 + if (class->level != 2 && class->level != 3) { 96 + pr_debug("class %u is not L2 or L3\n", class->level); 97 + continue; 98 + } 99 + 100 + if (!cache_has_usable_cpor(class)) { 101 + pr_debug("class %u cache misses CPOR\n", class->level); 102 + continue; 103 + } 104 + 105 + if (!cpumask_equal(&class->affinity, cpu_possible_mask)) { 106 + pr_debug("class %u has missing CPUs, mask %*pb != %*pb\n", class->level, 107 + cpumask_pr_args(&class->affinity), 108 + cpumask_pr_args(cpu_possible_mask)); 109 + continue; 110 + } 111 + 112 + if (class->level == 2) 113 + res = &mpam_resctrl_controls[RDT_RESOURCE_L2]; 114 + else 115 + res = &mpam_resctrl_controls[RDT_RESOURCE_L3]; 116 + res->class = class; 117 + } 118 + } 119 + 68 120 static int mpam_resctrl_control_init(struct mpam_resctrl_res *res) 69 121 { 70 - /* TODO: initialise the resctrl resources */ 122 + struct mpam_class *class = res->class; 123 + struct rdt_resource *r = &res->resctrl_res; 124 + 125 + switch (r->rid) { 126 + case RDT_RESOURCE_L2: 127 + case RDT_RESOURCE_L3: 128 + r->schema_fmt = RESCTRL_SCHEMA_BITMAP; 129 + r->cache.arch_has_sparse_bitmasks = true; 130 + 131 + r->cache.cbm_len = class->props.cpbm_wd; 132 + /* mpam_devices will reject empty bitmaps */ 133 + r->cache.min_cbm_bits = 1; 134 + 135 + if (r->rid == RDT_RESOURCE_L2) { 136 + r->name = "L2"; 137 + r->ctrl_scope = RESCTRL_L2_CACHE; 138 + r->cdp_capable = true; 139 + } else { 140 + r->name = "L3"; 141 + r->ctrl_scope = RESCTRL_L3_CACHE; 142 + r->cdp_capable = true; 143 + } 144 + 145 + /* 146 + * Which bits are shared with other ...things... Unknown 147 + * devices use partid-0 which uses all the bitmap fields. Until 148 + * we have configured the SMMU and GIC not to do this 'all the 149 + * bits' is the correct answer here. 150 + */ 151 + r->cache.shareable_bits = resctrl_get_default_ctrl(r); 152 + r->alloc_capable = true; 153 + break; 154 + default: 155 + return -EINVAL; 156 + } 71 157 72 158 return 0; 73 159 } ··· 378 292 res->resctrl_res.rid = rid; 379 293 } 380 294 381 - /* TODO: pick MPAM classes to map to resctrl resources */ 295 + /* Find some classes to use for controls */ 296 + mpam_resctrl_pick_caches(); 382 297 383 298 /* Initialise the resctrl structures from the classes */ 384 299 for_each_mpam_resctrl_control(res, rid) {