[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v8 16/24] x86: refactor psr: implement set value callback functions for CDP.
On Wed, Feb 15, 2017 at 04:49:31PM +0800, Yi Sun wrote: > This patch implements L3 CDP set value related callback functions. > > With this patch, 'psr-cat-cbm-set' command can work for L3 CDP. > > Signed-off-by: Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx> > --- > v8: > - modify 'l3_cdp_write_msr' to 'void'. > --- > xen/arch/x86/psr.c | 118 > +++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 118 insertions(+) > > diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c > index 72ed923..0a0bab9 100644 > --- a/xen/arch/x86/psr.c > +++ b/xen/arch/x86/psr.c > @@ -560,10 +560,128 @@ static bool l3_cdp_get_val(const struct feat_node > *feat, unsigned int cos, > return true; > } > > +static unsigned int l3_cdp_get_cos_num(const struct feat_node *feat) > +{ > + return 2; Please avoid using magic number, or document where 2 comes from. > +} > + > +static int l3_cdp_get_old_val(uint64_t val[], Hmm... so val is indeed an array. I think we need to pass the length as well. > + const struct feat_node *feat, > + unsigned int old_cos) > +{ > + if ( old_cos > feat->info.l3_cdp_info.cos_max ) > + /* Use default value. */ > + old_cos = 0; > + > + /* Data */ > + val[0] = get_cdp_data(feat, old_cos); > + /* Code */ > + val[1] = get_cdp_code(feat, old_cos); > + > + return 0; > +} > + > +static int l3_cdp_set_new_val(uint64_t val[], > + const struct feat_node *feat, > + enum cbm_type type, > + uint64_t m) > +{ > + if ( !psr_check_cbm(feat->info.l3_cdp_info.cbm_len, m) ) > + return -EINVAL; > + > + if ( type == PSR_CBM_TYPE_L3_DATA ) > + val[0] = m; > + else > + val[1] = m; > + > + return 0; > +} > + > +static int l3_cdp_compare_val(const uint64_t val[], > + const struct feat_node *feat, > + unsigned int cos, bool *found) > +{ > + uint64_t l3_def_cbm; > + > + l3_def_cbm = (1ull << feat->info.l3_cdp_info.cbm_len) - 1; This is getting repetitive. Please consider providing a macro to calculate this value. Wei. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |