Skip to content

Commit bc74042

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Drop __init/__exit on assorted symbols
Because ARM's MPAM controls are probed using MMIO, resctrl can't be initialised until enough CPUs are online to have determined the system-wide supported num_closid. Arm64 also supports 'late onlined secondaries', where only a subset of CPUs are online during boot. These two combine to mean the MPAM driver may not be able to initialise resctrl until user-space has brought 'enough' CPUs online. To allow MPAM to initialise resctrl after __init text has been free'd, remove all the __init markings from resctrl. The existing __exit markings cause these functions to be removed by the linker as it has never been possible to build resctrl as a module. MPAM has an error interrupt which causes the driver to reset and disable itself. Remove the __exit markings to allow the MPAM driver to tear down resctrl when an error occurs. 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> Tested-by: Fenghua Yu <fenghuay@nvidia.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> Tested-by: Tony Luck <tony.luck@intel.com> Link: https://lore.kernel.org/20250515165855.31452-10-james.morse@arm.com
1 parent 8c992e2 commit bc74042

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ struct rdt_options {
737737
bool force_off, force_on;
738738
};
739739

740-
static struct rdt_options rdt_options[] __initdata = {
740+
static struct rdt_options rdt_options[] __ro_after_init = {
741741
RDT_OPT(RDT_FLAG_CMT, "cmt", X86_FEATURE_CQM_OCCUP_LLC),
742742
RDT_OPT(RDT_FLAG_MBM_TOTAL, "mbmtotal", X86_FEATURE_CQM_MBM_TOTAL),
743743
RDT_OPT(RDT_FLAG_MBM_LOCAL, "mbmlocal", X86_FEATURE_CQM_MBM_LOCAL),
@@ -777,7 +777,7 @@ static int __init set_rdt_options(char *str)
777777
}
778778
__setup("rdt", set_rdt_options);
779779

780-
bool __init rdt_cpu_has(int flag)
780+
bool rdt_cpu_has(int flag)
781781
{
782782
bool ret = boot_cpu_has(flag);
783783
struct rdt_options *o;
@@ -797,7 +797,7 @@ bool __init rdt_cpu_has(int flag)
797797
return ret;
798798
}
799799

800-
__init bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt)
800+
bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt)
801801
{
802802
if (!rdt_cpu_has(X86_FEATURE_BMEC))
803803
return false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,13 @@ int alloc_rmid(u32 closid);
472472
void free_rmid(u32 closid, u32 rmid);
473473
int rdt_get_mon_l3_config(struct rdt_resource *r);
474474
void resctrl_mon_resource_exit(void);
475-
bool __init rdt_cpu_has(int flag);
475+
bool rdt_cpu_has(int flag);
476476
void mon_event_count(void *info);
477477
int rdtgroup_mondata_show(struct seq_file *m, void *arg);
478478
void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
479479
struct rdt_mon_domain *d, struct rdtgroup *rdtgrp,
480480
cpumask_t *cpumask, int evtid, int first);
481-
int __init resctrl_mon_resource_init(void);
481+
int resctrl_mon_resource_init(void);
482482
void mbm_setup_overflow_handler(struct rdt_mon_domain *dom,
483483
unsigned long delay_ms,
484484
int exclude_cpu);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ static __init int snc_get_config(void)
12041204
*
12051205
* Returns 0 for success, or -ENOMEM.
12061206
*/
1207-
int __init resctrl_mon_resource_init(void)
1207+
int resctrl_mon_resource_init(void)
12081208
{
12091209
struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
12101210
int ret;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4144,7 +4144,7 @@ static void rdtgroup_destroy_root(void)
41444144
rdtgroup_default.kn = NULL;
41454145
}
41464146

4147-
static void __init rdtgroup_setup_default(void)
4147+
static void rdtgroup_setup_default(void)
41484148
{
41494149
mutex_lock(&rdtgroup_mutex);
41504150

@@ -4376,7 +4376,7 @@ void resctrl_offline_cpu(unsigned int cpu)
43764376
*
43774377
* Return: 0 on success or -errno
43784378
*/
4379-
int __init resctrl_init(void)
4379+
int resctrl_init(void)
43804380
{
43814381
int ret = 0;
43824382

@@ -4433,7 +4433,7 @@ int __init resctrl_init(void)
44334433
return ret;
44344434
}
44354435

4436-
static bool __exit resctrl_online_domains_exist(void)
4436+
static bool resctrl_online_domains_exist(void)
44374437
{
44384438
struct rdt_resource *r;
44394439

@@ -4471,7 +4471,7 @@ static bool __exit resctrl_online_domains_exist(void)
44714471
* resctrl_arch_get_resource() must continue to return struct rdt_resources
44724472
* with the correct rid field to ensure the filesystem can be unmounted.
44734473
*/
4474-
void __exit resctrl_exit(void)
4474+
void resctrl_exit(void)
44754475
{
44764476
cpus_read_lock();
44774477
WARN_ON_ONCE(resctrl_online_domains_exist());

include/linux/resctrl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
358358
u32 resctrl_arch_system_num_rmid_idx(void);
359359
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
360360

361-
__init bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);
361+
bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);
362362

363363
/**
364364
* resctrl_arch_mon_event_config_write() - Write the config for an event.
@@ -514,7 +514,7 @@ void resctrl_arch_reset_all_ctrls(struct rdt_resource *r);
514514
extern unsigned int resctrl_rmid_realloc_threshold;
515515
extern unsigned int resctrl_rmid_realloc_limit;
516516

517-
int __init resctrl_init(void);
518-
void __exit resctrl_exit(void);
517+
int resctrl_init(void);
518+
void resctrl_exit(void);
519519

520520
#endif /* _RESCTRL_H */

0 commit comments

Comments
 (0)