Re: [Xen-devel] [PATCH v7 04/14] x86: maintain COS to CBM mapping for each socket

2015-05-19 Thread Chao Peng
On Mon, May 18, 2015 at 02:35:39PM +0100, Jan Beulich wrote:
> >>> On 08.05.15 at 10:56,  wrote:
> > @@ -237,6 +243,14 @@ static void cat_cpu_init(void)
> >  info->cbm_len = (eax & 0x1f) + 1;
> >  info->cos_max = min(opt_cos_max, edx & 0x);
> >  
> > +info->cos_to_cbm = xzalloc_array(struct psr_cat_cbm,
> > + info->cos_max + 1UL);
> 
> How does the array dimension here match the "for each socket"
> in the title?

info is already per-socket data so the dimension here is for only one
socket.

Chao

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


Re: [Xen-devel] [PATCH v7 04/14] x86: maintain COS to CBM mapping for each socket

2015-05-18 Thread Jan Beulich
>>> On 08.05.15 at 10:56,  wrote:
> @@ -237,6 +243,14 @@ static void cat_cpu_init(void)
>  info->cbm_len = (eax & 0x1f) + 1;
>  info->cos_max = min(opt_cos_max, edx & 0x);
>  
> +info->cos_to_cbm = xzalloc_array(struct psr_cat_cbm,
> + info->cos_max + 1UL);

How does the array dimension here match the "for each socket"
in the title?

Jan


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


[Xen-devel] [PATCH v7 04/14] x86: maintain COS to CBM mapping for each socket

2015-05-08 Thread Chao Peng
For each socket, a COS to CBM mapping structure is maintained for each
COS. The mapping is indexed by COS and the value is the corresponding
CBM. Different VMs may use the same CBM, a reference count is used to
indicate if the CBM is available.

Signed-off-by: Chao Peng 
Reviewed-by: Andrew Cooper 
---
Changes in v5:
* rename cos_cbm_map to cos_to_cbm.
---
 xen/arch/x86/psr.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index 848eacc..b775dbf 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -21,9 +21,15 @@
 #define PSR_CMT(1<<0)
 #define PSR_CAT(1<<1)
 
+struct psr_cat_cbm {
+uint64_t cbm;
+unsigned int ref;
+};
+
 struct psr_cat_socket_info {
 unsigned int cbm_len;
 unsigned int cos_max;
+struct psr_cat_cbm *cos_to_cbm;
 };
 
 struct psr_assoc {
@@ -237,6 +243,14 @@ static void cat_cpu_init(void)
 info->cbm_len = (eax & 0x1f) + 1;
 info->cos_max = min(opt_cos_max, edx & 0x);
 
+info->cos_to_cbm = xzalloc_array(struct psr_cat_cbm,
+ info->cos_max + 1UL);
+if ( !info->cos_to_cbm )
+return;
+
+/* cos=0 is reserved as default cbm(all ones). */
+info->cos_to_cbm[0].cbm = (1ull << info->cbm_len) - 1;
+
 set_bit(socket, cat_socket_enable_bitmap);
 printk(XENLOG_INFO "CAT: enabled on socket %u, cos_max:%u, 
cbm_len:%u\n",
socket, info->cos_max, info->cbm_len);
-- 
1.9.1


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