[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 5/7] 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 socket number and COS mask for current cpu is also cached in the local per-CPU variable. Signed-off-by: Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> --- Changes in v2: * merge common scheduling changes into scheduling improvement patch. * use readable expr for psra->cos_mask. --- xen/arch/x86/psr.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index af54aeb..e7e1dc0 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -36,6 +36,8 @@ struct psr_cat_socket_info { struct psr_assoc { uint64_t val; + unsigned int socket; + uint64_t cos_mask; }; struct psr_cmt *__read_mostly psr_cmt; @@ -211,9 +213,21 @@ void psr_free_rmid(struct domain *d) static inline void psr_assoc_init(void) { + unsigned int socket; + struct psr_cat_socket_info *info; struct psr_assoc *psra = &this_cpu(psr_assoc); - if ( psr_cmt_enabled() ) + socket = cpu_to_socket(smp_processor_id()); + psra->socket = socket; + if ( cat_socket_info && socket < opt_num_sockets ) + { + info = cat_socket_info + socket; + if ( info->enabled ) + psra->cos_mask = ((1ull << get_count_order(info->cos_max)) - 1) + << 32; + } + + if ( psr_cmt_enabled() || psra->cos_mask ) rdmsrl(MSR_IA32_PSR_ASSOC, psra->val); } @@ -236,6 +250,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) { uint64_t reg; @@ -246,6 +266,15 @@ void psr_ctxt_switch_to(struct domain *d) if ( psr_cmt_enabled() ) psr_assoc_rmid(®, d->arch.psr_rmid); + if ( psra->cos_mask ) + { + if ( d->arch.psr_cos_ids ) + psr_assoc_cos(®, d->arch.psr_cos_ids[psra->socket], + psra->cos_mask); + else + psr_assoc_cos(®, 0, psra->cos_mask); + } + psr_assoc_reg_write(psra, reg); } @@ -511,7 +540,7 @@ static void psr_cpu_init(unsigned int cpu) if ( cat_socket_info ) cat_cpu_init(cpu); - if ( psr_cmt_enabled() ) + if ( psr_cmt_enabled() || cat_socket_info ) psr_assoc_init(); } -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |