From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Chao Peng <chao.p.peng@linux.intel.com>, xen-devel@lists.xen.org
Cc: keir@xen.org, Ian.Campbell@citrix.com,
stefano.stabellini@eu.citrix.com, George.Dunlap@eu.citrix.com,
Ian.Jackson@eu.citrix.com, JBeulich@suse.com,
dgdegra@tycho.nsa.gov
Subject: Re: [PATCH v15 05/11] x86: detect and initialize Platform QoS Monitoring feature
Date: Fri, 5 Sep 2014 12:05:36 +0100 [thread overview]
Message-ID: <54099900.7080701@citrix.com> (raw)
In-Reply-To: <1409906249-6057-6-git-send-email-chao.p.peng@linux.intel.com>
On 05/09/14 09:37, Chao Peng wrote:
> Detect platform QoS feature status and enumerate the resource types,
> one of which is to monitor the L3 cache occupancy.
>
> Also introduce a Xen command line parameter to control the QoS
> feature status.
>
> Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> ---
> docs/misc/xen-command-line.markdown | 14 +++++
> xen/arch/x86/Makefile | 1 +
> xen/arch/x86/pqos.c | 108 +++++++++++++++++++++++++++++++++++
> xen/arch/x86/setup.c | 3 +
> xen/include/asm-x86/cpufeature.h | 1 +
> xen/include/asm-x86/pqos.h | 53 +++++++++++++++++
> 6 files changed, 180 insertions(+)
> create mode 100644 xen/arch/x86/pqos.c
> create mode 100644 xen/include/asm-x86/pqos.h
>
> diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown
> index af93e17..fcda322 100644
> --- a/docs/misc/xen-command-line.markdown
> +++ b/docs/misc/xen-command-line.markdown
> @@ -1005,6 +1005,20 @@ This option can be specified more than once (up to 8 times at present).
> ### ple\_window
> > `= <integer>`
>
> +### pqos (Intel)
> +> `= List of ( pqos_monitor:<boolean> | rmid_max:<integer> )`
> +
> +> Default: `pqos=pqos_monitor:0,rmid_max:255`
> +
> +Configure platform QoS services, which are available on Intel Haswell Server
> +family and future platforms.
> +
> +`pqos` instructs Xen to enable/disable platform QoS service.
> +
> +`pqos_monitor` instructs Xen to enable/disable QoS monitoring service.
> +
> +`rmid_max` indicates the max value for rmid.
> +
> ### reboot
> > `= t[riple] | k[bd] | a[cpi] | p[ci] | n[o] [, [w]arm | [c]old]`
>
> diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
> index c1e244d..3d92fd7 100644
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -59,6 +59,7 @@ obj-y += crash.o
> obj-y += tboot.o
> obj-y += hpet.o
> obj-y += xstate.o
> +obj-y += pqos.o
>
> obj-$(crash_debug) += gdbstub.o
>
> diff --git a/xen/arch/x86/pqos.c b/xen/arch/x86/pqos.c
> new file mode 100644
> index 0000000..aca9ea2
> --- /dev/null
> +++ b/xen/arch/x86/pqos.c
> @@ -0,0 +1,108 @@
> +/*
> + * pqos.c: Platform QoS related service for guest.
> + *
> + * Copyright (c) 2014, Intel Corporation
> + * Author: Dongxiao Xu <dongxiao.xu@intel.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + * more details.
> + */
> +#include <xen/init.h>
> +#include <xen/cpu.h>
> +#include <asm/pqos.h>
> +
> +#define PQOS_MONITOR (1<<0)
> +
> +struct pqos_monitor *__read_mostly pqosm = NULL;
> +static bool_t __initdata opt_pqos = 0;
> +static unsigned int __initdata opt_rmid_max = 255;
> +
> +static void __init parse_pqos_param(char *s)
> +{
> + char *ss, *val_str;
> +
> + do {
> + ss = strchr(s, ',');
> + if ( ss )
> + *ss = '\0';
> +
> + val_str = strchr(s, ':');
> + if ( val_str )
> + *val_str++ = '\0';
> +
> + if ( !strcmp(s, "pqos_monitor")
> + && ( !val_str || parse_bool(val_str) == 1 )) {
> + opt_pqos &= PQOS_MONITOR;
> + } else if ( val_str && !strcmp(s, "rmid_max") )
> + opt_rmid_max = simple_strtoul(val_str, NULL, 0);
> +
> + s = ss + 1;
> + } while ( ss );
> +}
> +custom_param("pqos", parse_pqos_param);
> +
> +static void __init init_pqos_monitor(unsigned int rmid_max)
> +{
> + unsigned int eax, ebx, ecx, edx;
> + unsigned int rmid;
> +
> + if ( !boot_cpu_has(X86_FEATURE_QOSM) )
> + return;
> +
> + cpuid_count(0xf, 0, &eax, &ebx, &ecx, &edx);
> + if ( !edx )
> + return;
> +
> + pqosm = xzalloc(struct pqos_monitor);
> + if ( !pqosm )
> + return;
> +
> + pqosm->qm_features = edx;
> + pqosm->rmid_mask = ~(~0ull << get_count_order(ebx));
> + pqosm->rmid_max = min(rmid_max, ebx);
> +
> + if ( pqosm->qm_features & QOS_MONITOR_TYPE_L3 )
> + {
> + cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx);
> + pqosm->l3m.upscaling_factor = ebx;
> + pqosm->l3m.rmid_max = ecx;
> + pqosm->l3m.l3_features = edx;
> + }
> +
> + pqosm->rmid_max = min(rmid_max, pqosm->l3m.rmid_max);
> + BUG_ON(pqosm->rmid_max < 0xffffffff);
Given that rmid_max defaults to 255 and pqosm->rmid_max is unsigned, how
can this possibly work?
~Andrew
> + pqosm->rmid_to_dom = xmalloc_array(domid_t, pqosm->rmid_max + 1);
> + if ( !pqosm->rmid_to_dom )
> + {
> + xfree(pqosm);
> + return;
> + }
> + /* Reserve RMID 0 for all domains not being monitored */
> + pqosm->rmid_to_dom[0] = DOMID_XEN;
> + for ( rmid = 1; rmid <= pqosm->rmid_max; rmid++ )
> + pqosm->rmid_to_dom[rmid] = DOMID_INVALID;
> +
> + printk(XENLOG_INFO "Platform QoS Monitoring Enabled.\n");
> +}
> +
> +void __init init_platform_qos(void)
> +{
> + if ( opt_pqos && opt_rmid_max )
> + init_pqos_monitor(opt_rmid_max);
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * tab-width: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 6a814cd..b4ad3a6 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -49,6 +49,7 @@
> #include <xen/cpu.h>
> #include <asm/nmi.h>
> #include <asm/alternative.h>
> +#include <asm/pqos.h>
>
> /* opt_nosmp: If true, secondary processors are ignored. */
> static bool_t __initdata opt_nosmp;
> @@ -1440,6 +1441,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>
> domain_unpause_by_systemcontroller(dom0);
>
> + init_platform_qos();
> +
> reset_stack_and_jump(init_done);
> }
>
> diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h
> index 8014241..eb1dd27 100644
> --- a/xen/include/asm-x86/cpufeature.h
> +++ b/xen/include/asm-x86/cpufeature.h
> @@ -148,6 +148,7 @@
> #define X86_FEATURE_ERMS (7*32+ 9) /* Enhanced REP MOVSB/STOSB */
> #define X86_FEATURE_INVPCID (7*32+10) /* Invalidate Process Context ID */
> #define X86_FEATURE_RTM (7*32+11) /* Restricted Transactional Memory */
> +#define X86_FEATURE_QOSM (7*32+12) /* Platform QoS monitoring capability */
> #define X86_FEATURE_NO_FPU_SEL (7*32+13) /* FPU CS/DS stored as zero */
> #define X86_FEATURE_MPX (7*32+14) /* Memory Protection Extensions */
> #define X86_FEATURE_RDSEED (7*32+18) /* RDSEED instruction */
> diff --git a/xen/include/asm-x86/pqos.h b/xen/include/asm-x86/pqos.h
> new file mode 100644
> index 0000000..96bfdc6
> --- /dev/null
> +++ b/xen/include/asm-x86/pqos.h
> @@ -0,0 +1,53 @@
> +/*
> + * pqos.h: Platform QoS related service for guest.
> + *
> + * Copyright (c) 2014, Intel Corporation
> + * Author: Dongxiao Xu <dongxiao.xu@intel.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + * more details.
> + */
> +#ifndef __ASM_PQOS_H__
> +#define __ASM_PQOS_H__
> +
> +/* QoS Resource Type Enumeration */
> +#define QOS_MONITOR_TYPE_L3 0x2
> +
> +/* L3 Monitoring Features */
> +#define L3_FEATURE_OCCUPANCY 0x1
> +
> +struct pqos_monitor_l3 {
> + unsigned int l3_features;
> + unsigned int upscaling_factor;
> + unsigned int rmid_max;
> +};
> +
> +struct pqos_monitor {
> + unsigned long rmid_mask;
> + unsigned int rmid_max;
> + unsigned int qm_features;
> + domid_t *rmid_to_dom;
> + struct pqos_monitor_l3 l3m;
> +};
> +
> +extern struct pqos_monitor *pqosm;
> +
> +void init_platform_qos(void);
> +
> +#endif /* __ASM_PQOS_H__ */
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * tab-width: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
next prev parent reply other threads:[~2014-09-05 11:05 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 8:37 [PATCH v15 00/11] enable Cache QoS Monitoring (CQM) feature Chao Peng
2014-09-05 8:37 ` [PATCH v15 01/11] multicall: add no preemption ability between two calls Chao Peng
2014-09-05 10:46 ` Andrew Cooper
2014-09-09 6:43 ` Chao Peng
2014-09-09 10:39 ` Jan Beulich
2014-09-09 10:51 ` Andrew Cooper
2014-09-09 11:51 ` Jan Beulich
2014-09-09 12:44 ` Andrew Cooper
2014-09-09 13:15 ` Jan Beulich
2014-09-10 1:32 ` Chao Peng
2014-09-10 9:43 ` Andrew Cooper
2014-09-10 10:07 ` Jan Beulich
2014-09-10 10:15 ` Andrew Cooper
2014-09-10 10:25 ` Jan Beulich
2014-09-10 11:12 ` Andrew Cooper
2014-09-12 2:55 ` Chao Peng
2014-09-17 9:22 ` Chao Peng
2014-09-17 9:44 ` Jan Beulich
2014-09-18 13:45 ` Chao Peng
2014-09-18 14:22 ` Jan Beulich
2014-09-05 8:37 ` [PATCH v15 02/11] x86: add generic resource (e.g. MSR) access hypercall Chao Peng
2014-09-05 10:59 ` Andrew Cooper
2014-09-05 11:49 ` Jan Beulich
2014-09-10 2:55 ` Chao Peng
2014-09-29 18:52 ` Konrad Rzeszutek Wilk
2014-09-30 7:45 ` Jan Beulich
2014-09-05 8:37 ` [PATCH v15 03/11] xsm: add resource operation related xsm policy Chao Peng
2014-09-05 8:37 ` [PATCH v15 04/11] tools: provide interface for generic resource access Chao Peng
2014-09-05 8:37 ` [PATCH v15 05/11] x86: detect and initialize Platform QoS Monitoring feature Chao Peng
2014-09-05 11:05 ` Andrew Cooper [this message]
2014-09-05 8:37 ` [PATCH v15 06/11] x86: dynamically attach/detach QoS monitoring service for a guest Chao Peng
2014-09-05 8:37 ` [PATCH v15 07/11] x86: collect global QoS monitoring information Chao Peng
2014-09-05 8:37 ` [PATCH v15 08/11] x86: enable QoS monitoring for each domain RMID Chao Peng
2014-09-05 8:37 ` [PATCH v15 09/11] x86: add QoS monitoring related MSRs in allowed list Chao Peng
2014-09-05 8:37 ` [PATCH v15 10/11] xsm: add platform QoS related xsm policies Chao Peng
2014-09-05 8:37 ` [PATCH v15 11/11] tools: CMDs and APIs for Platform QoS Monitoring Chao Peng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54099900.7080701@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=chao.p.peng@linux.intel.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).