[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v9 06/13] x86: dynamically get/set CBM for a domain



On Tue, Jun 23, 2015 at 09:35:30AM +0100, Jan Beulich wrote:
> >>> On 23.06.15 at 09:19, <chao.p.peng@xxxxxxxxxxxxxxx> wrote:
> > On Tue, Jun 16, 2015 at 08:08:34AM +0100, Jan Beulich wrote:
> >> >>> On 03.06.15 at 06:53, <chao.p.peng@xxxxxxxxxxxxxxx> 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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.