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

Re: [Xen-devel] [PATCH v5 2/3] x86: add domctl cmd to set/get CDP code/data CBM



> +    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

_______________________________________________
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®.