From: "Jan Beulich" Subject: Re: [PATCH v11 6/9] x86: collect global QoS monitoring information Date: Fri, 20 Jun 2014 16:16:17 +0100 Message-ID: <53A46C61020000780001C113@mail.emea.novell.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dongxiao Xu Cc: keir@xen.org, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org >>> On 20.06.14 at 16:31, wrote: > This implementation tries to put all policies into user space, thus some > global QoS monitoring information needs to be exposed, such as the total > RMID count, L3 upscaling factor, etc. > > Signed-off-by: Dongxiao Xu > --- > xen/arch/x86/sysctl.c | 52 > +++++++++++++++++++++++++++++++++++++++++++++ > xen/include/public/sysctl.h | 14 ++++++++++++ > 2 files changed, 66 insertions(+) > > diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c > index 49f95e4..ea9b2e4 100644 > --- a/xen/arch/x86/sysctl.c > +++ b/xen/arch/x86/sysctl.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > > #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) > > @@ -152,6 +153,57 @@ long arch_do_sysctl( > } > break; > > + case XEN_SYSCTL_pqos_monitor_op: > + if ( !pqos_monitor_enabled() ) > + return -ENODEV; > + > + switch ( sysctl->u.pqos_monitor_op.cmd ) > + { > + case XEN_SYSCTL_PQOS_MONITOR_cqm_enabled: > + sysctl->u.pqos_monitor_op.data = > + (pqosm->qm_features & QOS_MONITOR_TYPE_L3) && > + (pqosm->l3m.l3_features & L3_FEATURE_OCCUPANCY); > + break; > + case XEN_SYSCTL_PQOS_MONITOR_get_total_rmid: > + sysctl->u.pqos_monitor_op.data = > + pqosm->rmid_max - pqosm->rmid_min + 1; > + break; > + case XEN_SYSCTL_PQOS_MONITOR_get_l3_upscaling_factor: > + sysctl->u.pqos_monitor_op.data = pqosm->l3m.upscaling_factor; > + break; > + case XEN_SYSCTL_PQOS_MONITOR_get_l3_cache_size: > + sysctl->u.pqos_monitor_op.data = boot_cpu_data.x86_cache_size; > + break; > + case XEN_SYSCTL_PQOS_MONITOR_get_socket_cpu: > + { > + unsigned int i, cpu; > + int socket = sysctl->u.pqos_monitor_op.data; unsigned int > + > + for ( i = 0; i < NR_CPUS; i++ ) Why NR_CPUS when a few lines down you show that you know of nr_cpu_ids? > + { > + if ( cpu_to_socket(i) < 0 || cpu_to_socket(i) != socket ) > + continue; > + cpu = cpumask_any(per_cpu(cpu_core_mask, i)); > + if ( cpu < nr_cpu_ids ) > + { > + sysctl->u.pqos_monitor_op.data = cpu; > + break; > + } > + } > + > + if ( i == NR_CPUS ) > + ret = -EFAULT; -EFAULT? > + } > + break; > + > + default: > + sysctl->u.pqos_monitor_op.data = 0; > + ret = -ENOSYS; > + break; > + } > + copyback = 1; > + break; Indentation. > --- a/xen/include/public/sysctl.h > +++ b/xen/include/public/sysctl.h > @@ -659,6 +659,18 @@ struct msr_access_info { > xen_sysctl_msr_data_t *msr_data; > }; > > +#define XEN_SYSCTL_PQOS_MONITOR_get_total_rmid 0 > +#define XEN_SYSCTL_PQOS_MONITOR_get_l3_upscaling_factor 1 > +#define XEN_SYSCTL_PQOS_MONITOR_get_l3_cache_size 2 > +#define XEN_SYSCTL_PQOS_MONITOR_get_socket_cpu 3 > +#define XEN_SYSCTL_PQOS_MONITOR_cqm_enabled 4 > +struct xen_sysctl_pqos_monitor_op { > + uint32_t cmd; > + uint64_t data; Missing explicit padding between the two fields, or need to use uint64_aligned_t. Jan