Skip to content

Commit 09e61da

Browse files
author
James Morse
committed
arm_mpam: resctrl: Add boilerplate cpuhp and domain allocation
resctrl has its own data structures to describe its resources. We can't use these directly as we play tricks with the 'MBA' resource, picking the MPAM controls or monitors that best apply. We may export the same component as both L3 and MBA. Add mpam_resctrl_res[] as the array of class->resctrl mappings we are exporting, and add the cpuhp hooks that allocated and free the resctrl domain structures. Only the mpam control feature are considered here and monitor support will be added later. While we're here, plumb in a few other obvious things. CONFIG_ARM_CPU_RESCTRL is used to allow this code to be built even though it can't yet be linked against resctrl. 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>
1 parent 67faed4 commit 09e61da

5 files changed

Lines changed: 361 additions & 0 deletions

File tree

drivers/resctrl/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
obj-$(CONFIG_ARM64_MPAM_DRIVER) += mpam.o
22
mpam-y += mpam_devices.o
3+
mpam-$(CONFIG_ARM_CPU_RESCTRL) += mpam_resctrl.o
34

45
ccflags-$(CONFIG_ARM64_MPAM_DRIVER_DEBUG) += -DDEBUG

drivers/resctrl/mpam_devices.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,9 @@ static int mpam_cpu_online(unsigned int cpu)
16121612
mpam_reprogram_msc(msc);
16131613
}
16141614

1615+
if (mpam_is_enabled())
1616+
return mpam_resctrl_online_cpu(cpu);
1617+
16151618
return 0;
16161619
}
16171620

@@ -1655,6 +1658,9 @@ static int mpam_cpu_offline(unsigned int cpu)
16551658
{
16561659
struct mpam_msc *msc;
16571660

1661+
if (mpam_is_enabled())
1662+
mpam_resctrl_offline_cpu(cpu);
1663+
16581664
guard(srcu)(&mpam_srcu);
16591665
list_for_each_entry_srcu(msc, &mpam_all_msc, all_msc_list,
16601666
srcu_read_lock_held(&mpam_srcu)) {
@@ -2500,6 +2506,12 @@ static void mpam_enable_once(void)
25002506
mutex_unlock(&mpam_list_lock);
25012507
cpus_read_unlock();
25022508

2509+
if (!err) {
2510+
err = mpam_resctrl_setup();
2511+
if (err)
2512+
pr_err("Failed to initialise resctrl: %d\n", err);
2513+
}
2514+
25032515
if (err) {
25042516
mpam_disable_reason = "Failed to enable.";
25052517
schedule_work(&mpam_broken_work);

drivers/resctrl/mpam_internal.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/jump_label.h>
1313
#include <linux/llist.h>
1414
#include <linux/mutex.h>
15+
#include <linux/resctrl.h>
1516
#include <linux/spinlock.h>
1617
#include <linux/srcu.h>
1718
#include <linux/types.h>
@@ -333,6 +334,16 @@ struct mpam_msc_ris {
333334
struct mpam_garbage garbage;
334335
};
335336

337+
struct mpam_resctrl_dom {
338+
struct mpam_component *ctrl_comp;
339+
struct rdt_ctrl_domain resctrl_ctrl_dom;
340+
};
341+
342+
struct mpam_resctrl_res {
343+
struct mpam_class *class;
344+
struct rdt_resource resctrl_res;
345+
};
346+
336347
static inline int mpam_alloc_csu_mon(struct mpam_class *class)
337348
{
338349
struct mpam_props *cprops = &class->props;
@@ -387,6 +398,16 @@ void mpam_msmon_reset_mbwu(struct mpam_component *comp, struct mon_cfg *ctx);
387398
int mpam_get_cpumask_from_cache_id(unsigned long cache_id, u32 cache_level,
388399
cpumask_t *affinity);
389400

401+
#ifdef CONFIG_RESCTRL_FS
402+
int mpam_resctrl_setup(void);
403+
int mpam_resctrl_online_cpu(unsigned int cpu);
404+
void mpam_resctrl_offline_cpu(unsigned int cpu);
405+
#else
406+
static inline int mpam_resctrl_setup(void) { return 0; }
407+
static inline int mpam_resctrl_online_cpu(unsigned int cpu) { return 0; }
408+
static inline void mpam_resctrl_offline_cpu(unsigned int cpu) { }
409+
#endif /* CONFIG_RESCTRL_FS */
410+
390411
/*
391412
* MPAM MSCs have the following register layout. See:
392413
* Arm Memory System Resource Partitioning and Monitoring (MPAM) System

0 commit comments

Comments
 (0)