xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Chao Peng <chao.p.peng@linux.intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: wei.liu2@citrix.com, Ian.Campbell@citrix.com,
	stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com,
	dario.faggioli@citrix.com, Ian.Jackson@eu.citrix.com,
	xen-devel@lists.xen.org, will.auld@intel.com, keir@xen.org,
	dgdegra@tycho.nsa.gov
Subject: Re: [PATCH v9 06/13] x86: dynamically get/set CBM for a domain
Date: Tue, 23 Jun 2015 17:03:34 +0800	[thread overview]
Message-ID: <20150623090334.GC6447@pengc-linux.bj.intel.com> (raw)
In-Reply-To: <558936720200007800087F8E@mail.emea.novell.com>

On Tue, Jun 23, 2015 at 09:35:30AM +0100, Jan Beulich wrote:
> >>> On 23.06.15 at 09:19, <chao.p.peng@linux.intel.com> wrote:
> > On Tue, Jun 16, 2015 at 08:08:34AM +0100, Jan Beulich wrote:
> >> >>> On 03.06.15 at 06:53, <chao.p.peng@linux.intel.com> wrote:
> >> > +int psr_set_l3_cbm(struct domain *d, unsigned int socket, uint64_t cbm)
> >> > +{
> >> > +    unsigned int old_cos, cos;
> >> > +    struct psr_cat_cbm *map, *found = NULL;
> >> > +    struct psr_cat_socket_info *info = NULL;
> >> > +    int ret = get_cat_socket_info(socket, &info);
> >> > +
> >> > +    if ( ret )
> >> > +        return ret;
> >> > +
> >> > +    if ( !psr_check_cbm(info->cbm_len, cbm) )
> >> > +        return -EINVAL;
> >> > +
> >> > +    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++ )
> >> > +    {
> >> > +        /* If still not found, then keep unused one. */
> >> > +        if ( !found && cos != 0 && map[cos].ref == 0 )
> >> > +            found = map + cos;
> >> > +        else if ( map[cos].cbm == cbm )
> >> > +        {
> >> > +            if ( unlikely(cos == old_cos) )
> >> > +            {
> >> > +                spin_unlock(&info->cbm_lock);
> >> > +                return 0;
> >> 
> >> Is this in particular, but also the surrounding "else if", correct when
> >> map[cos].ref == 0? 
> > 
> > I can't see any problem now.
> 
> Further down in the function you increment found->ref, and it looks
> suspicious that you return success here having found a slot possibly
> having refount zero (and thus available for re-use for another CBM).

In such case 'cos == old_cos' can't be true, otherwise refcount can't be
zero.

> I.e. if this indeed is intended and correct, I think this needs to be
> explained in a brief comment.

So yes, I can leave a comment here.

Chao

  reply	other threads:[~2015-06-23  9:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-03  4:52 [PATCH v9 00/13] enable Cache Allocation Technology (CAT) for VMs Chao Peng
2015-06-03  4:52 ` [PATCH v9 01/13] x86: add socket_cpumask Chao Peng
2015-06-15 15:59   ` Jan Beulich
2015-06-03  4:52 ` [PATCH v9 02/13] x86: detect and initialize Intel CAT feature Chao Peng
2015-06-15 15:56   ` Jan Beulich
2015-06-03  4:53 ` [PATCH v9 03/13] x86: maintain COS to CBM mapping for each socket Chao Peng
2015-06-15 16:02   ` Jan Beulich
2015-06-23  7:08     ` Chao Peng
2015-06-23  8:27       ` Jan Beulich
2015-06-03  4:53 ` [PATCH v9 04/13] x86: add COS information for each domain Chao Peng
2015-06-16  6:55   ` Jan Beulich
2015-06-03  4:53 ` [PATCH v9 05/13] x86: expose CBM length and COS number information Chao Peng
2015-06-16  6:58   ` Jan Beulich
2015-06-03  4:53 ` [PATCH v9 06/13] x86: dynamically get/set CBM for a domain Chao Peng
2015-06-16  7:08   ` Jan Beulich
2015-06-23  7:19     ` Chao Peng
2015-06-23  8:35       ` Jan Beulich
2015-06-23  9:03         ` Chao Peng [this message]
2015-06-23  9:14           ` Jan Beulich
2015-06-03  4:53 ` [PATCH v9 07/13] x86: add scheduling support for Intel CAT Chao Peng
2015-06-03  4:53 ` [PATCH v9 08/13] xsm: add CAT related xsm policies Chao Peng
2015-06-03  4:53 ` [PATCH v9 09/13] tools/libxl: minor name changes for CMT commands Chao Peng
2015-06-03  4:53 ` [PATCH v9 10/13] tools/libxl: add command to show PSR hardware info Chao Peng
2015-06-03  4:53 ` [PATCH v9 11/13] tools/libxl: introduce some socket helpers Chao Peng
2015-06-03  4:53 ` [PATCH v9 12/13] tools: add tools support for Intel CAT Chao Peng
2015-06-03  4:53 ` [PATCH v9 13/13] docs: add xl-psr.markdown 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=20150623090334.GC6447@pengc-linux.bj.intel.com \
    --to=chao.p.peng@linux.intel.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dario.faggioli@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=keir@xen.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=will.auld@intel.com \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).