direct-io.hg

changeset 13270:62f3df867d0e

Enable compatibility mode operation for HYPERVISOR_xenoprof_op.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Fri Jan 05 17:34:37 2007 +0000 (2007-01-05)
parents 56cd6d669151
children d80684d19ef4
files xen/arch/x86/x86_64/compat/entry.S xen/common/Makefile xen/common/compat/xenoprof.c xen/common/xenoprof.c xen/include/public/xenoprof.h xen/include/xen/xenoprof.h xen/include/xlat.lst
line diff
     1.1 --- a/xen/arch/x86/x86_64/compat/entry.S	Fri Jan 05 17:34:37 2007 +0000
     1.2 +++ b/xen/arch/x86/x86_64/compat/entry.S	Fri Jan 05 17:34:37 2007 +0000
     1.3 @@ -278,7 +278,6 @@ CFIX14:
     1.4  
     1.5  .section .rodata, "a", @progbits
     1.6  
     1.7 -#define compat_xenoprof_op domain_crash_synchronous
     1.8  #define compat_sysctl domain_crash_synchronous
     1.9  #define compat_domctl domain_crash_synchronous
    1.10  
     2.1 --- a/xen/common/Makefile	Fri Jan 05 17:34:37 2007 +0000
     2.2 +++ b/xen/common/Makefile	Fri Jan 05 17:34:37 2007 +0000
     2.3 @@ -45,4 +45,5 @@ ifeq ($(CONFIG_COMPAT),y)
     2.4  acm_ops.o: compat/acm_ops.c
     2.5  grant_table.o: compat/grant_table.c
     2.6  schedule.o: compat/schedule.c
     2.7 +xenoprof.o: compat/xenoprof.c
     2.8  endif
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/common/compat/xenoprof.c	Fri Jan 05 17:34:37 2007 +0000
     3.3 @@ -0,0 +1,40 @@
     3.4 +/*
     3.5 + * compat/xenoprof.c
     3.6 + */
     3.7 +
     3.8 +#include <compat/xenoprof.h>
     3.9 +
    3.10 +#define COMPAT
    3.11 +
    3.12 +#define do_xenoprof_op compat_xenoprof_op
    3.13 +
    3.14 +#define xen_oprof_init xenoprof_init
    3.15 +CHECK_oprof_init;
    3.16 +#undef xen_oprof_init
    3.17 +
    3.18 +#define xenoprof_get_buffer compat_oprof_get_buffer
    3.19 +#define xenoprof_op_get_buffer compat_oprof_op_get_buffer
    3.20 +
    3.21 +#define xen_domid_t domid_t
    3.22 +#define compat_domid_t domid_compat_t
    3.23 +CHECK_TYPE(domid);
    3.24 +#undef compat_domid_t
    3.25 +#undef xen_domid_t
    3.26 +
    3.27 +#define xen_oprof_passive xenoprof_passive
    3.28 +CHECK_oprof_passive;
    3.29 +#undef xen_oprof_passive
    3.30 +
    3.31 +#define xenoprof_counter compat_oprof_counter
    3.32 +
    3.33 +#include "../xenoprof.c"
    3.34 +
    3.35 +/*
    3.36 + * Local variables:
    3.37 + * mode: C
    3.38 + * c-set-style: "BSD"
    3.39 + * c-basic-offset: 4
    3.40 + * tab-width: 4
    3.41 + * indent-tabs-mode: nil
    3.42 + * End:
    3.43 + */
     4.1 --- a/xen/common/xenoprof.c	Fri Jan 05 17:34:37 2007 +0000
     4.2 +++ b/xen/common/xenoprof.c	Fri Jan 05 17:34:37 2007 +0000
     4.3 @@ -9,6 +9,7 @@
     4.4   *                    VA Linux Systems Japan K.K.
     4.5   */
     4.6  
     4.7 +#ifndef COMPAT
     4.8  #include <xen/guest_access.h>
     4.9  #include <xen/sched.h>
    4.10  #include <public/xenoprof.h>
    4.11 @@ -72,7 +73,7 @@ static void xenoprof_reset_stat(void)
    4.12  static void xenoprof_reset_buf(struct domain *d)
    4.13  {
    4.14      int j;
    4.15 -    struct xenoprof_buf *buf;
    4.16 +    xenoprof_buf_t *buf;
    4.17  
    4.18      if ( d->xenoprof == NULL )
    4.19      {
    4.20 @@ -86,8 +87,8 @@ static void xenoprof_reset_buf(struct do
    4.21          buf = d->xenoprof->vcpu[j].buffer;
    4.22          if ( buf != NULL )
    4.23          {
    4.24 -            buf->event_head = 0;
    4.25 -            buf->event_tail = 0;
    4.26 +            xenoprof_buf(d, buf, event_head) = 0;
    4.27 +            xenoprof_buf(d, buf, event_tail) = 0;
    4.28          }
    4.29      }
    4.30  }
    4.31 @@ -166,15 +167,24 @@ static int alloc_xenoprof_struct(
    4.32      for_each_vcpu ( d, v )
    4.33          nvcpu++;
    4.34  
    4.35 +    bufsize = sizeof(struct xenoprof_buf);
    4.36 +    i = sizeof(struct event_log);
    4.37 +#ifdef CONFIG_COMPAT
    4.38 +    d->xenoprof->is_compat = IS_COMPAT(is_passive ? dom0 : d);
    4.39 +    if ( XENOPROF_COMPAT(d->xenoprof) )
    4.40 +    {
    4.41 +        bufsize = sizeof(struct compat_oprof_buf);
    4.42 +        i = sizeof(struct compat_event_log);
    4.43 +    }
    4.44 +#endif
    4.45 +
    4.46      /* reduce max_samples if necessary to limit pages allocated */
    4.47      max_bufsize = (MAX_OPROF_SHARED_PAGES * PAGE_SIZE) / nvcpu;
    4.48 -    max_max_samples = ( (max_bufsize - sizeof(struct xenoprof_buf)) /
    4.49 -                        sizeof(struct event_log) ) + 1;
    4.50 +    max_max_samples = ( (max_bufsize - bufsize) / i ) + 1;
    4.51      if ( (unsigned)max_samples > max_max_samples )
    4.52          max_samples = max_max_samples;
    4.53  
    4.54 -    bufsize = sizeof(struct xenoprof_buf) +
    4.55 -        (max_samples - 1) * sizeof(struct event_log);
    4.56 +    bufsize += (max_samples - 1) * i;
    4.57      npages = (nvcpu * bufsize - 1) / PAGE_SIZE + 1;
    4.58  
    4.59      d->xenoprof->rawbuf = alloc_xenheap_pages(get_order_from_pages(npages));
    4.60 @@ -195,11 +205,12 @@ static int alloc_xenoprof_struct(
    4.61      i = 0;
    4.62      for_each_vcpu ( d, v )
    4.63      {
    4.64 +        xenoprof_buf_t *buf = (xenoprof_buf_t *)&d->xenoprof->rawbuf[i * bufsize];
    4.65 +
    4.66          d->xenoprof->vcpu[v->vcpu_id].event_size = max_samples;
    4.67 -        d->xenoprof->vcpu[v->vcpu_id].buffer =
    4.68 -            (struct xenoprof_buf *)&d->xenoprof->rawbuf[i * bufsize];
    4.69 -        d->xenoprof->vcpu[v->vcpu_id].buffer->event_size = max_samples;
    4.70 -        d->xenoprof->vcpu[v->vcpu_id].buffer->vcpu_id = v->vcpu_id;
    4.71 +        d->xenoprof->vcpu[v->vcpu_id].buffer = buf;
    4.72 +        xenoprof_buf(d, buf, event_size) = max_samples;
    4.73 +        xenoprof_buf(d, buf, vcpu_id) = v->vcpu_id;
    4.74  
    4.75          i++;
    4.76          /* in the unlikely case that the number of active vcpus changes */
    4.77 @@ -406,8 +417,9 @@ static int add_passive_list(XEN_GUEST_HA
    4.78  void xenoprof_log_event(
    4.79      struct vcpu *vcpu, unsigned long eip, int mode, int event)
    4.80  {
    4.81 +    struct domain *d = vcpu->domain;
    4.82      struct xenoprof_vcpu *v;
    4.83 -    struct xenoprof_buf *buf;
    4.84 +    xenoprof_buf_t *buf;
    4.85      int head;
    4.86      int tail;
    4.87      int size;
    4.88 @@ -417,13 +429,13 @@ void xenoprof_log_event(
    4.89  
    4.90      /* ignore samples of un-monitored domains */
    4.91      /* Count samples in idle separate from other unmonitored domains */
    4.92 -    if ( !is_profiled(vcpu->domain) )
    4.93 +    if ( !is_profiled(d) )
    4.94      {
    4.95          others_samples++;
    4.96          return;
    4.97      }
    4.98  
    4.99 -    v = &vcpu->domain->xenoprof->vcpu[vcpu->vcpu_id];
   4.100 +    v = &d->xenoprof->vcpu[vcpu->vcpu_id];
   4.101  
   4.102      /* Sanity check. Should never happen */ 
   4.103      if ( v->buffer == NULL )
   4.104 @@ -432,10 +444,10 @@ void xenoprof_log_event(
   4.105          return;
   4.106      }
   4.107  
   4.108 -    buf = vcpu->domain->xenoprof->vcpu[vcpu->vcpu_id].buffer;
   4.109 +    buf = v->buffer;
   4.110  
   4.111 -    head = buf->event_head;
   4.112 -    tail = buf->event_tail;
   4.113 +    head = xenoprof_buf(d, buf, event_head);
   4.114 +    tail = xenoprof_buf(d, buf, event_tail);
   4.115      size = v->event_size;
   4.116  
   4.117      /* make sure indexes in shared buffer are sane */
   4.118 @@ -447,28 +459,28 @@ void xenoprof_log_event(
   4.119  
   4.120      if ( (head == tail - 1) || (head == size - 1 && tail == 0) )
   4.121      {
   4.122 -        buf->lost_samples++;
   4.123 +        xenoprof_buf(d, buf, lost_samples)++;
   4.124          lost_samples++;
   4.125      }
   4.126      else
   4.127      {
   4.128 -        buf->event_log[head].eip = eip;
   4.129 -        buf->event_log[head].mode = mode;
   4.130 -        buf->event_log[head].event = event;
   4.131 +        xenoprof_buf(d, buf, event_log[head].eip) = eip;
   4.132 +        xenoprof_buf(d, buf, event_log[head].mode) = mode;
   4.133 +        xenoprof_buf(d, buf, event_log[head].event) = event;
   4.134          head++;
   4.135          if ( head >= size )
   4.136              head = 0;
   4.137 -        buf->event_head = head;
   4.138 +        xenoprof_buf(d, buf, event_head) = head;
   4.139          if ( is_active(vcpu->domain) )
   4.140              active_samples++;
   4.141          else
   4.142              passive_samples++;
   4.143          if ( mode == 0 )
   4.144 -            buf->user_samples++;
   4.145 +            xenoprof_buf(d, buf, user_samples)++;
   4.146          else if ( mode == 1 )
   4.147 -            buf->kernel_samples++;
   4.148 +            xenoprof_buf(d, buf, kernel_samples)++;
   4.149          else
   4.150 -            buf->xen_samples++;
   4.151 +            xenoprof_buf(d, buf, xen_samples)++;
   4.152      }
   4.153  }
   4.154  
   4.155 @@ -494,6 +506,8 @@ static int xenoprof_op_init(XEN_GUEST_HA
   4.156      return 0;
   4.157  }
   4.158  
   4.159 +#endif /* !COMPAT */
   4.160 +
   4.161  static int xenoprof_op_get_buffer(XEN_GUEST_HANDLE(void) arg)
   4.162  {
   4.163      struct xenoprof_get_buffer xenoprof_get_buffer;
   4.164 @@ -732,6 +746,10 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN
   4.165      return ret;
   4.166  }
   4.167  
   4.168 +#if defined(CONFIG_COMPAT) && !defined(COMPAT)
   4.169 +#include "compat/xenoprof.c"
   4.170 +#endif
   4.171 +
   4.172  /*
   4.173   * Local variables:
   4.174   * mode: C
     5.1 --- a/xen/include/public/xenoprof.h	Fri Jan 05 17:34:37 2007 +0000
     5.2 +++ b/xen/include/public/xenoprof.h	Fri Jan 05 17:34:37 2007 +0000
     5.3 @@ -74,8 +74,10 @@ struct xenoprof_buf {
     5.4      uint64_t lost_samples;
     5.5      struct event_log event_log[1];
     5.6  };
     5.7 +#ifndef __XEN__
     5.8  typedef struct xenoprof_buf xenoprof_buf_t;
     5.9  DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
    5.10 +#endif
    5.11  
    5.12  struct xenoprof_init {
    5.13      int32_t  num_events;
     6.1 --- a/xen/include/xen/xenoprof.h	Fri Jan 05 17:34:37 2007 +0000
     6.2 +++ b/xen/include/xen/xenoprof.h	Fri Jan 05 17:34:37 2007 +0000
     6.3 @@ -10,6 +10,7 @@
     6.4  #ifndef __XEN_XENOPROF_H__
     6.5  #define __XEN_XENOPROF_H__
     6.6  
     6.7 +#include <xen/config.h>
     6.8  #include <public/xenoprof.h>
     6.9  #include <asm/xenoprof.h>
    6.10  
    6.11 @@ -22,9 +23,19 @@
    6.12  #define XENOPROF_READY             2
    6.13  #define XENOPROF_PROFILING         3
    6.14  
    6.15 +#ifndef CONFIG_COMPAT
    6.16 +typedef struct xenoprof_buf xenoprof_buf_t;
    6.17 +#else
    6.18 +#include <compat/xenoprof.h>
    6.19 +typedef union {
    6.20 +	struct xenoprof_buf native;
    6.21 +	struct compat_oprof_buf compat;
    6.22 +} xenoprof_buf_t;
    6.23 +#endif
    6.24 +
    6.25  struct xenoprof_vcpu {
    6.26      int event_size;
    6.27 -    struct xenoprof_buf *buffer;
    6.28 +    xenoprof_buf_t *buffer;
    6.29  };
    6.30  
    6.31  struct xenoprof {
    6.32 @@ -35,9 +46,22 @@ struct xenoprof {
    6.33      int domain_type;
    6.34      int domain_ready;
    6.35      int is_primary;
    6.36 +#ifdef CONFIG_COMPAT
    6.37 +    int is_compat;
    6.38 +#endif
    6.39      struct xenoprof_vcpu vcpu [MAX_VIRT_CPUS];
    6.40  };
    6.41  
    6.42 +#ifndef CONFIG_COMPAT
    6.43 +#define XENOPROF_COMPAT(x) 0
    6.44 +#define xenoprof_buf(d, b, field) ((b)->field)
    6.45 +#else
    6.46 +#define XENOPROF_COMPAT(x) ((x)->is_compat)
    6.47 +#define xenoprof_buf(d, b, field) (*(!(d)->xenoprof->is_compat ? \
    6.48 +                                       &(b)->native.field : \
    6.49 +                                       &(b)->compat.field))
    6.50 +#endif
    6.51 +
    6.52  struct domain;
    6.53  void free_xenoprof_pages(struct domain *d);
    6.54  
     7.1 --- a/xen/include/xlat.lst	Fri Jan 05 17:34:37 2007 +0000
     7.2 +++ b/xen/include/xlat.lst	Fri Jan 05 17:34:37 2007 +0000
     7.3 @@ -38,3 +38,5 @@
     7.4  ?	sched_remote_shutdown		sched.h
     7.5  ?	sched_shutdown			sched.h
     7.6  !	vcpu_runstate_info		vcpu.h
     7.7 +?	xenoprof_init			xenoprof.h
     7.8 +?	xenoprof_passive		xenoprof.h