Commit 8c19cd6d authored by James Morse's avatar James Morse Committed by Zeng Heng
Browse files

x86/resctrl: Move get_config_index() to a header

maillist inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8T2RT

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/log/?h=mpam/snapshot/v6.7-rc2



---------------------------

get_config_index() is used by the architecture specific code to map a
CLOSID+type pair to an index in the configuration arrays.

MPAM needs to do this too to preserve the ABI to user-space, there is
no reason to do it differently.

Move the helper to a header file.

Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent f658deb9
Loading
Loading
Loading
Loading
+3 −16
Original line number Diff line number Diff line
@@ -278,19 +278,6 @@ static int parse_line(char *line, struct resctrl_schema *s,
	return -EINVAL;
}

static u32 get_config_index(u32 closid, enum resctrl_conf_type type)
{
	switch (type) {
	default:
	case CDP_NONE:
		return closid;
	case CDP_CODE:
		return closid * 2 + 1;
	case CDP_DATA:
		return closid * 2;
	}
}

static bool apply_config(struct rdt_hw_domain *hw_dom,
			 struct resctrl_staged_config *cfg, u32 idx,
			 cpumask_var_t cpu_mask)
@@ -312,7 +299,7 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d,
{
	struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
	struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d);
	u32 idx = get_config_index(closid, t);
	u32 idx = resctrl_get_config_index(closid, t);
	struct msr_param msr_param;

	if (!cpumask_test_cpu(smp_processor_id(), &d->cpu_mask))
@@ -352,7 +339,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
			if (!cfg->have_new_ctrl)
				continue;

			idx = get_config_index(closid, t);
			idx = resctrl_get_config_index(closid, t);
			if (!apply_config(hw_dom, cfg, idx, cpu_mask))
				continue;

@@ -477,7 +464,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d,
			    u32 closid, enum resctrl_conf_type type)
{
	struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d);
	u32 idx = get_config_index(closid, type);
	u32 idx = resctrl_get_config_index(closid, type);

	return hw_dom->ctrl_val[idx];
}
+15 −0
Original line number Diff line number Diff line
@@ -256,6 +256,21 @@ bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);
void resctrl_arch_mon_event_config_write(void *info);
void resctrl_arch_mon_event_config_read(void *info);

/* For use by arch code that needs to remap resctrl's smaller CDP closid */
static inline u32 resctrl_get_config_index(u32 closid,
					   enum resctrl_conf_type type)
{
	switch (type) {
	default:
	case CDP_NONE:
		return closid;
	case CDP_CODE:
			return (closid * 2) + 1;
	case CDP_DATA:
			return (closid * 2);
	}
}

/*
 * Update the ctrl_val and apply this config right now.
 * Must be called on one of the domain's CPUs.