[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v9 13/25] x86: refactor psr: L3 CAT: set value: implement write msr flow.
Continue from previous patch: 'x86: refactor psr: L3 CAT: set value: implement cos id picking flow.' We have got the feature value and COS ID to set. Then, we write MSR of the designated feature. Till now, set value process is completed. Signed-off-by: Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx> --- v9: - replace feature list handling to feature array handling. (suggested by Roger Pau) - add 'array_len' in 'struct cos_write_info' and check if val array exceeds it. - modify 'write_psr_msr' flow only to set one value a time. No need to set whole feature array values. - modify patch title to indicate 'L3 CAT'. (suggested by Jan Beulich) - changes about 'uint64_t' to 'uint32_t'. (suggested by Jan Beulich) v8: - modify 'write_msr' callback function to 'void' because we have to set all features' cbm. When input cos exceeds some features' cos_max, just skip them but not break the iteration. v5: - modify commit message to provide exact patch name to continue from. (suggested by Jan Beulich) - modify return value of callback functions because we do not need them to return number of entries the feature uses. In caller, we call 'get_cos_num' to get the number of entries the feature uses. (suggested by Jan Beulich) - move type check out from callback functions to caller. (suggested by Jan Beulich) - modify variables names to make them better, e.g. 'feat_tmp' to 'feat'. (suggested by Jan Beulich) - correct code format. (suggested by Jan Beulich) v4: - create this patch to make codes easier understand. (suggested by Jan Beulich) --- xen/arch/x86/psr.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index d4db407..2bc7f3c 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -149,6 +149,10 @@ struct feat_node { bool (*fits_cos_max)(const uint32_t val[], const struct feat_node *feat, unsigned int cos); + + /* write_msr is used to write out feature MSR register. */ + void (*write_msr)(unsigned int cos, uint32_t val, + enum cbm_type type, struct feat_node *feat); } ops; /* Encapsulate feature specific HW info here. */ @@ -421,6 +425,18 @@ static bool cat_fits_cos_max(const uint32_t val[], } /* L3 CAT ops */ +static void l3_cat_write_msr(unsigned int cos, uint32_t val, + enum cbm_type type, struct feat_node *feat) +{ + if ( feat->cos_reg_val[cos] != val ) + { + feat->cos_reg_val[cos] = val; + wrmsrl(MSR_IA32_PSR_L3_MASK(cos), (uint64_t)val); + } + + return; +} + static const struct feat_ops l3_cat_ops = { .get_cos_max = cat_get_cos_max, .get_feat_info = cat_get_feat_info, @@ -429,6 +445,7 @@ static const struct feat_ops l3_cat_ops = { .set_new_val = cat_set_new_val, .compare_val = cat_compare_val, .fits_cos_max = cat_fits_cos_max, + .write_msr = l3_cat_write_msr, }; static void __init parse_psr_bool(char *s, char *value, char *feature, @@ -957,11 +974,62 @@ static int pick_avail_cos(const struct psr_socket_info *info, return -EOVERFLOW; } +static unsigned int get_socket_cpu(unsigned int socket) +{ + if ( likely(socket < nr_sockets) ) + return cpumask_any(socket_cpumask[socket]); + + return nr_cpu_ids; +} + +struct cos_write_info +{ + unsigned int cos; + struct feat_node *feature; + uint32_t val; + enum cbm_type type; +}; + +static void do_write_psr_msr(void *data) +{ + struct cos_write_info *info = (struct cos_write_info *)data; + unsigned int cos = info->cos; + struct feat_node *feat = info->feature; + + if ( !feat ) + return; + + if ( cos > feat->ops.get_cos_max(feat) ) + return; + + feat->ops.write_msr(cos, info->val, info->type, feat); +} + static int write_psr_msr(unsigned int socket, unsigned int cos, uint32_t val, enum cbm_type type, enum psr_feat_type feat_type) { - return -ENOENT; + struct psr_socket_info *info = get_socket_info(socket); + struct cos_write_info data = + { + .cos = cos, + .feature = info->features[feat_type], + .val = val, + .type = type, + }; + + if ( socket == cpu_to_socket(smp_processor_id()) ) + do_write_psr_msr(&data); + else + { + unsigned int cpu = get_socket_cpu(socket); + + if ( cpu >= nr_cpu_ids ) + return -ENOTSOCK; + on_selected_cpus(cpumask_of(cpu), do_write_psr_msr, &data, 1); + } + + return 0; } int psr_set_val(struct domain *d, unsigned int socket, -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |