From: Chao Peng <chao.p.peng@linux.intel.com>
To: He Chen <he.chen@linux.intel.com>
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
Subject: Re: [PATCH v5 2/3] x86: add domctl cmd to set/get CDP code/data CBM
Date: Wed, 30 Sep 2015 11:29:46 +0800 [thread overview]
Message-ID: <20150930032946.GL5813@pengc-linux.bj.intel.com> (raw)
In-Reply-To: <1443428969-4695-3-git-send-email-he.chen@linux.intel.com>
> + bool_t cdp_enabled = cdp_is_enabled(socket, cdp_socket_enable);
>
> if ( IS_ERR(info) )
> return PTR_ERR(info);
>
> - *cbm = info->cos_to_cbm[d->arch.psr_cos_ids[socket]].cbm;
> + switch ( type )
> + {
> + case PSR_CBM_TYPE_L3:
> + if ( type == PSR_CBM_TYPE_L3 && cdp_enabled )
'type == PSR_CBM_TYPE_L3' here seems redundant.
> + return -EXDEV;
> + *cbm = info->cos_to_cbm[d->arch.psr_cos_ids[socket]].cbm;
> + break;
...
> -int psr_set_l3_cbm(struct domain *d, unsigned int socket, uint64_t cbm)
> +static int find_cos(struct psr_cat_cbm *map, int cos_max,
cos_max should be unsigned.
> + uint64_t cbm_code, uint64_t cbm_data, bool_t cdp_enabled)
> {
> - unsigned int old_cos, cos;
> - struct psr_cat_cbm *map, *found = NULL;
> + unsigned int cos;
> +
> + for ( cos = 0; cos <= cos_max; cos++ )
> + {
> + if( map[cos].ref &&
> + ((!cdp_enabled && map[cos].cbm == cbm_code) ||
> + (cdp_enabled && map[cos].code == cbm_code &&
> + map[cos].data == cbm_data)))
> + return cos;
> + }
> +
...
> + else
> + {
> + bool_t need_write = 1;
>
> - if ( ret )
> + cos = pick_avail_cos(map, cos_max, old_cos);
> + if ( cos < 0 )
> {
> spin_unlock(&info->cbm_lock);
> - return ret;
> + return cos;
> + }
> +
> + /* We try to avoid writing MSR. */
> + if ( cdp_enabled )
> + {
> + if ( map[cos].code == cbm_code &&
> + map[cos].data == cbm_data )
> + need_write = 0;
> + }
> + else
> + need_write = !(map[cos].cbm == cbm_code);
> +
need_write here seems useless, you can put it in inline below.
> + if ( need_write )
> + {
> + ret = write_l3_cbm(socket, cos, cbm_code, cbm_data, cdp_enabled);
> + if ( ret )
> + {
> + spin_unlock(&info->cbm_lock);
> + return ret;
> + }
> + map[cos].code = cbm_code;
> + map[cos].data = cbm_data;
> }
> - found->cbm = cbm;
> }
Chao
next prev parent reply other threads:[~2015-09-30 3:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 8:29 [PATCH v5 0/3] detect and initialize CDP (Code/Data Prioritization) feature He Chen
2015-09-28 8:29 ` [PATCH v5 1/3] x86: Support enable CDP by boot parameter and add get CDP status He Chen
2015-09-30 3:10 ` Chao Peng
2015-09-28 8:29 ` [PATCH v5 2/3] x86: add domctl cmd to set/get CDP code/data CBM He Chen
2015-09-30 3:29 ` Chao Peng [this message]
2015-09-28 8:29 ` [PATCH v5 3/3] tools & docs: add tools and docs support for Intel CDP He Chen
2015-09-29 13:47 ` Ian Campbell
2015-09-30 2:46 ` Chao Peng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150930032946.GL5813@pengc-linux.bj.intel.com \
--to=chao.p.peng@linux.intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=he.chen@linux.intel.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.