From: Chao Peng Date: Tue, 7 Jul 2015 13:47:18 +0000 (+0200) Subject: x86: add scheduling support for Intel CAT X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2921 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4cbbe62a92434242c973cc56108d695ea6f053e7;p=xen.git x86: add scheduling support for Intel CAT On context switch, write the the domain's Class of Service(COS) to MSR IA32_PQR_ASSOC, to notify hardware to use the new COS. For performance reason, the COS mask for current cpu is also cached in the local per-CPU variable. Signed-off-by: Chao Peng Acked-by: Jan Beulich --- diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 288bded852..861683fe29 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -36,6 +36,7 @@ struct psr_cat_socket_info { struct psr_assoc { uint64_t val; + uint64_t cos_mask; }; struct psr_cmt *__read_mostly psr_cmt; @@ -201,7 +202,16 @@ static inline void psr_assoc_init(void) { struct psr_assoc *psra = &this_cpu(psr_assoc); - if ( psr_cmt_enabled() ) + if ( cat_socket_info ) + { + unsigned int socket = cpu_to_socket(smp_processor_id()); + + if ( test_bit(socket, cat_socket_enable) ) + psra->cos_mask = ((1ull << get_count_order( + cat_socket_info[socket].cos_max)) - 1) << 32; + } + + if ( psr_cmt_enabled() || psra->cos_mask ) rdmsrl(MSR_IA32_PSR_ASSOC, psra->val); } @@ -210,6 +220,12 @@ static inline void psr_assoc_rmid(uint64_t *reg, unsigned int rmid) *reg = (*reg & ~rmid_mask) | (rmid & rmid_mask); } +static inline void psr_assoc_cos(uint64_t *reg, unsigned int cos, + uint64_t cos_mask) +{ + *reg = (*reg & ~cos_mask) | (((uint64_t)cos << 32) & cos_mask); +} + void psr_ctxt_switch_to(struct domain *d) { struct psr_assoc *psra = &this_cpu(psr_assoc); @@ -218,6 +234,11 @@ void psr_ctxt_switch_to(struct domain *d) if ( psr_cmt_enabled() ) psr_assoc_rmid(®, d->arch.psr_rmid); + if ( psra->cos_mask ) + psr_assoc_cos(®, d->arch.psr_cos_ids ? + d->arch.psr_cos_ids[cpu_to_socket(smp_processor_id())] : + 0, psra->cos_mask); + if ( reg != psra->val ) { wrmsrl(MSR_IA32_PSR_ASSOC, reg);