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

Re: [Xen-devel] [PATCH v3 1/4] x86: Support enable CDP by boot parameter and add get CDP status



>>> On 14.09.15 at 05:27, <he.chen@xxxxxxxxxxxxxxx> wrote:
> --- a/xen/arch/x86/psr.c
> +++ b/xen/arch/x86/psr.c
> @@ -21,9 +21,16 @@
>  
>  #define PSR_CMT        (1<<0)
>  #define PSR_CAT        (1<<1)
> +#define PSR_CDP        (1<<2)
>  
>  struct psr_cat_cbm {
> -    uint64_t cbm;
> +    union {
> +        uint64_t cbm;
> +        struct {
> +            uint64_t code;
> +            uint64_t data;
> +        } cdp;
> +    } u;

While in the public interfaces use of gcc extensions is not allowed
without very special care, please make use of such in internal
headers when that helps readability (as well as in the case patch
size): No need to name the union member of the outer structure.

> @@ -490,13 +519,33 @@ static void cat_cpu_init(void)
>          info->cos_to_cbm = temp_cos_to_cbm;
>          temp_cos_to_cbm = NULL;
>          /* cos=0 is reserved as default cbm(all ones). */
> -        info->cos_to_cbm[0].cbm = (1ull << info->cbm_len) - 1;
> +        info->cos_to_cbm[0].u.cbm = (1ull << info->cbm_len) - 1;
>  
>          spin_lock_init(&info->cbm_lock);
>  
>          set_bit(socket, cat_socket_enable);
> -        printk(XENLOG_INFO "CAT: enabled on socket %u, cos_max:%u, 
> cbm_len:%u\n",
> -               socket, info->cos_max, info->cbm_len);

I fail to see a replacement for this message.

> +        if ( (ecx & PSR_CAT_CDP_CAPABILITY) && (opt_psr & PSR_CDP) )
> +        {
> +            if ( test_bit(socket, cdp_socket_enable) )
> +                return;

This will make future changes more cumbersome, especially if one
would not require CDP as a prereq. Please fold the two if()s,
allowing execution to progress past the outer if() in all cases.

> +            rdmsrl(MSR_IA32_PSR_L3_QOS_CFG, val);
> +            wrmsrl(MSR_IA32_PSR_L3_QOS_CFG, val | 1 << 
> PSR_L3_QOS_CDP_ENABLE_BIT);

Missing parentheses around the <<.

> +            info->cos_to_cbm[0].u.cdp.code = (1ull << info->cbm_len) - 1;
> +            info->cos_to_cbm[0].u.cdp.data = (1ull << info->cbm_len) - 1;
> +
> +            /* We only write mask1 since mask0 is always all ones by default 
> */
> +            wrmsrl(MSR_IA32_PSR_L3_MASK(1), (1ull << info->cbm_len) - 1);
> +
> +            /* Cut half of cos_max when CDP enabled */
> +            info->cos_max = info->cos_max / 2;

Please use /= or >>=.

> @@ -535,8 +588,9 @@ static void __init init_psr_cat(void)
>  
>      cat_socket_enable = xzalloc_array(unsigned long, 
> BITS_TO_LONGS(nr_sockets));
>      cat_socket_info = xzalloc_array(struct psr_cat_socket_info, nr_sockets);
> +    cdp_socket_enable = xzalloc_array(unsigned long, 
> BITS_TO_LONGS(nr_sockets));
>  
> -    if ( !cat_socket_enable || !cat_socket_info )
> +    if ( !cat_socket_enable || !cat_socket_info || !cdp_socket_enable )
>          psr_cat_free();

No - just disable CDP if only that third allocation fails.

> --- a/xen/include/asm-x86/msr-index.h
> +++ b/xen/include/asm-x86/msr-index.h
> @@ -328,7 +328,10 @@
>  #define MSR_IA32_CMT_EVTSEL          0x00000c8d
>  #define MSR_IA32_CMT_CTR             0x00000c8e
>  #define MSR_IA32_PSR_ASSOC           0x00000c8f
> +#define MSR_IA32_PSR_L3_QOS_CFG      0x00000c81
>  #define MSR_IA32_PSR_L3_MASK(n)      (0x00000c90 + (n))
> +#define MSR_IA32_PSR_L3_MASK_CODE(n) (0x00000c90 + (n * 2 + 1))
> +#define MSR_IA32_PSR_L3_MASK_DATA(n) (0x00000c90 + (n * 2))

Please always fully parenthesize uses of macro parameters (in fact
the parentheses you have could simply be moved to isolate just n).

> --- a/xen/include/public/sysctl.h
> +++ b/xen/include/public/sysctl.h
> @@ -704,6 +704,8 @@ struct xen_sysctl_psr_cat_op {
>          struct {
>              uint32_t cbm_len;   /* OUT: CBM length */
>              uint32_t cos_max;   /* OUT: Maximum COS */
> +            #define XEN_SYSCTL_PSR_CAT_L3_CDP       (1u << 0)
> +            uint32_t flags;     /* OUT: CAT flags */
>          } l3_info;

Even if only mildly incompatible, any interface change to sysctl (or
domctl) should make sure the respective interface version got
bumped after branching the previous release tree.

Jan

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