From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH v3 1/4] x86: Support enable CDP by boot parameter and add get CDP status Date: Mon, 14 Sep 2015 08:12:42 -0600 Message-ID: <55F6F1FA02000078000A29BF@prv-mh.provo.novell.com> References: <1442201227-8610-1-git-send-email-he.chen@linux.intel.com> <1442201227-8610-2-git-send-email-he.chen@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZbUV1-0000BD-Al for xen-devel@lists.xenproject.org; Mon, 14 Sep 2015 14:12:51 +0000 In-Reply-To: <1442201227-8610-2-git-send-email-he.chen@linux.intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: He Chen Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xenproject.org, chao.p.peng@linux.intel.com, keir@xen.org List-Id: xen-devel@lists.xenproject.org >>> On 14.09.15 at 05:27, wrote: > --- a/xen/arch/x86/psr.c > +++ b/xen/arch/x86/psr.c > @@ -21,9 +21,16 @@ > > #define PSR_CMT (1<<0) > #define PSR_CAT (1<<1) > +#define PSR_CDP (1<<2) > > struct psr_cat_cbm { > - uint64_t cbm; > + union { > + uint64_t cbm; > + struct { > + uint64_t code; > + uint64_t data; > + } cdp; > + } u; While in the public interfaces use of gcc extensions is not allowed without very special care, please make use of such in internal headers when that helps readability (as well as in the case patch size): No need to name the union member of the outer structure. > @@ -490,13 +519,33 @@ static void cat_cpu_init(void) > info->cos_to_cbm = temp_cos_to_cbm; > temp_cos_to_cbm = NULL; > /* cos=0 is reserved as default cbm(all ones). */ > - info->cos_to_cbm[0].cbm = (1ull << info->cbm_len) - 1; > + info->cos_to_cbm[0].u.cbm = (1ull << info->cbm_len) - 1; > > spin_lock_init(&info->cbm_lock); > > set_bit(socket, cat_socket_enable); > - printk(XENLOG_INFO "CAT: enabled on socket %u, cos_max:%u, cbm_len:%u\n", > - socket, info->cos_max, info->cbm_len); I fail to see a replacement for this message. > + if ( (ecx & PSR_CAT_CDP_CAPABILITY) && (opt_psr & PSR_CDP) ) > + { > + if ( test_bit(socket, cdp_socket_enable) ) > + return; This will make future changes more cumbersome, especially if one would not require CDP as a prereq. Please fold the two if()s, allowing execution to progress past the outer if() in all cases. > + rdmsrl(MSR_IA32_PSR_L3_QOS_CFG, val); > + wrmsrl(MSR_IA32_PSR_L3_QOS_CFG, val | 1 << PSR_L3_QOS_CDP_ENABLE_BIT); Missing parentheses around the <<. > + info->cos_to_cbm[0].u.cdp.code = (1ull << info->cbm_len) - 1; > + info->cos_to_cbm[0].u.cdp.data = (1ull << info->cbm_len) - 1; > + > + /* We only write mask1 since mask0 is always all ones by default */ > + wrmsrl(MSR_IA32_PSR_L3_MASK(1), (1ull << info->cbm_len) - 1); > + > + /* Cut half of cos_max when CDP enabled */ > + info->cos_max = info->cos_max / 2; Please use /= or >>=. > @@ -535,8 +588,9 @@ static void __init init_psr_cat(void) > > cat_socket_enable = xzalloc_array(unsigned long, BITS_TO_LONGS(nr_sockets)); > cat_socket_info = xzalloc_array(struct psr_cat_socket_info, nr_sockets); > + cdp_socket_enable = xzalloc_array(unsigned long, BITS_TO_LONGS(nr_sockets)); > > - if ( !cat_socket_enable || !cat_socket_info ) > + if ( !cat_socket_enable || !cat_socket_info || !cdp_socket_enable ) > psr_cat_free(); No - just disable CDP if only that third allocation fails. > --- a/xen/include/asm-x86/msr-index.h > +++ b/xen/include/asm-x86/msr-index.h > @@ -328,7 +328,10 @@ > #define MSR_IA32_CMT_EVTSEL 0x00000c8d > #define MSR_IA32_CMT_CTR 0x00000c8e > #define MSR_IA32_PSR_ASSOC 0x00000c8f > +#define MSR_IA32_PSR_L3_QOS_CFG 0x00000c81 > #define MSR_IA32_PSR_L3_MASK(n) (0x00000c90 + (n)) > +#define MSR_IA32_PSR_L3_MASK_CODE(n) (0x00000c90 + (n * 2 + 1)) > +#define MSR_IA32_PSR_L3_MASK_DATA(n) (0x00000c90 + (n * 2)) Please always fully parenthesize uses of macro parameters (in fact the parentheses you have could simply be moved to isolate just n). > --- a/xen/include/public/sysctl.h > +++ b/xen/include/public/sysctl.h > @@ -704,6 +704,8 @@ struct xen_sysctl_psr_cat_op { > struct { > uint32_t cbm_len; /* OUT: CBM length */ > uint32_t cos_max; /* OUT: Maximum COS */ > + #define XEN_SYSCTL_PSR_CAT_L3_CDP (1u << 0) > + uint32_t flags; /* OUT: CAT flags */ > } l3_info; Even if only mildly incompatible, any interface change to sysctl (or domctl) should make sure the respective interface version got bumped after branching the previous release tree. Jan