From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chao Peng Subject: Re: [PATCH v3 2/4] x86: add domctl cmd to set/get CDP code/data CBM Date: Mon, 14 Sep 2015 17:04:14 +0800 Message-ID: <20150914090414.GB4475@pengc-linux.bj.intel.com> References: <1442201227-8610-1-git-send-email-he.chen@linux.intel.com> <1442201227-8610-3-git-send-email-he.chen@linux.intel.com> Reply-To: Chao Peng Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZbPjx-0006PU-27 for xen-devel@lists.xenproject.org; Mon, 14 Sep 2015 09:07:57 +0000 Content-Disposition: inline In-Reply-To: <1442201227-8610-3-git-send-email-he.chen@linux.intel.com> 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, jbeulich@suse.com, xen-devel@lists.xenproject.org, keir@xen.org List-Id: xen-devel@lists.xenproject.org On Mon, Sep 14, 2015 at 11:27:05AM +0800, He Chen wrote: > CDP extends CAT and provides the capacity to control L3 code & data > cache. With CDP, one COS correspond to two CMBs(code & data). cbm_type ^s > is added to support distinguish different CBM operation. Besides, new ^'support' can be ommitted. ^s > domctl cmds are introdunced to support set/get CDP CBM. Some CAT > functions to operation CBMs are extended to support CDP. > > Signed-off-by: He Chen > + > + /* If old cos is referred only by the domain, then use it. */ > + if ( map[old_cos].ref == 1 ) > + return old_cos; > + > + /* Find an unused one other than cos0 */ Missing stop. > + for ( cos = 1; cos <= cos_max; cos++ ) > + if ( map[cos].ref == 0 ) > + return cos; > + > + return -ENOENT; > +} > + > +int psr_set_l3_cbm(struct domain *d, unsigned int socket, > + uint64_t cbm, enum cbm_type type) > +{ > + unsigned int old_cos, cos_max; > + int cos, ret; > + uint64_t cbm_data, cbm_code; > + bool_t need_write = 1; > + bool_t cdp_enabled = test_bit(socket, cdp_socket_enable); > + struct psr_cat_cbm *map; > struct psr_cat_socket_info *info = get_cat_socket_info(socket); > > if ( IS_ERR(info) ) > @@ -381,53 +449,79 @@ int psr_set_l3_cbm(struct domain *d, unsigned int socket, uint64_t cbm) > if ( !psr_check_cbm(info->cbm_len, cbm) ) > return -EINVAL; > > + if ( !cdp_enabled && (type == PSR_CBM_TYPE_L3_CODE || > + type == PSR_CBM_TYPE_L3_DATA) ) Nice code can be made by aligning PSR_CBM_TYPE_L3_DATA with PSR_CBM_TYPE_L3_DATA. > + return -EINVAL; > + > + cos_max = info->cos_max; > old_cos = d->arch.psr_cos_ids[socket]; > map = info->cos_to_cbm; > > - spin_lock(&info->cbm_lock); > > - for ( cos = 0; cos <= info->cos_max; cos++ ) > + switch( type ) Coding style. > + { > + cos = pick_avail_cos(map, cos_max, old_cos); > + if ( cos < 0 ) > + { > + spin_unlock(&info->cbm_lock); > + return cos; > + } > + > + /* We try to avoid writing MSR */ Missing stop. Overall it looks only some minor issues, with these being fixed, then Reviewed-by: Chao peng Chao