direct-io.hg

changeset 12506:da5c5fc8908f

[XENOPROFILE] Replace x86 specific code in xen/common/xenoprof.c
- replace nmi_ prefix with xenoprof_arch_ prefix
- move config_counter to xen/arch/x86/oprofile/xenoprof.c

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author kfraser@localhost.localdomain
date Wed Nov 22 09:48:42 2006 +0000 (2006-11-22)
parents fc11c91e5371
children 2f15fce77758
files xen/arch/x86/oprofile/xenoprof.c xen/common/xenoprof.c xen/include/asm-x86/xenoprof.h xen/include/xen/xenoprof.h
line diff
     1.1 --- a/xen/arch/x86/oprofile/xenoprof.c	Wed Nov 22 09:35:50 2006 +0000
     1.2 +++ b/xen/arch/x86/oprofile/xenoprof.c	Wed Nov 22 09:48:42 2006 +0000
     1.3 @@ -13,6 +13,28 @@
     1.4  #include <public/xenoprof.h>
     1.5  #include <asm/hvm/support.h>
     1.6  
     1.7 +#include "op_counter.h"
     1.8 +
     1.9 +int xenoprof_arch_counter(XEN_GUEST_HANDLE(void) arg)
    1.10 +{
    1.11 +    struct xenoprof_counter counter;
    1.12 +
    1.13 +    if ( copy_from_guest(&counter, arg, 1) )
    1.14 +        return -EFAULT;
    1.15 +
    1.16 +    if ( counter.ind > OP_MAX_COUNTER )
    1.17 +        return -E2BIG;
    1.18 +
    1.19 +    counter_config[counter.ind].count     = counter.count;
    1.20 +    counter_config[counter.ind].enabled   = counter.enabled;
    1.21 +    counter_config[counter.ind].event     = counter.event;
    1.22 +    counter_config[counter.ind].kernel    = counter.kernel;
    1.23 +    counter_config[counter.ind].user      = counter.user;
    1.24 +    counter_config[counter.ind].unit_mask = counter.unit_mask;
    1.25 +
    1.26 +    return 0;
    1.27 +}
    1.28 +
    1.29  int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs)
    1.30  {
    1.31      if ( !guest_mode(regs) )
     2.1 --- a/xen/common/xenoprof.c	Wed Nov 22 09:35:50 2006 +0000
     2.2 +++ b/xen/common/xenoprof.c	Wed Nov 22 09:48:42 2006 +0000
     2.3 @@ -12,8 +12,6 @@
     2.4  #include <public/xenoprof.h>
     2.5  #include <asm/hvm/support.h>
     2.6  
     2.7 -#include "../arch/x86/oprofile/op_counter.h"
     2.8 -
     2.9  /* Limit amount of pages used for shared buffer (per domain) */
    2.10  #define MAX_OPROF_SHARED_PAGES 32
    2.11  
    2.12 @@ -40,16 +38,6 @@ u64 passive_samples;
    2.13  u64 idle_samples;
    2.14  u64 others_samples;
    2.15  
    2.16 -
    2.17 -extern int nmi_init(int *num_events, int *is_primary, char *cpu_type);
    2.18 -extern int nmi_reserve_counters(void);
    2.19 -extern int nmi_setup_events(void);
    2.20 -extern int nmi_enable_virq(void);
    2.21 -extern int nmi_start(void);
    2.22 -extern void nmi_stop(void);
    2.23 -extern void nmi_disable_virq(void);
    2.24 -extern void nmi_release_counters(void);
    2.25 -
    2.26  int is_active(struct domain *d)
    2.27  {
    2.28      struct xenoprof *x = d->xenoprof;
    2.29 @@ -445,9 +433,9 @@ static int xenoprof_op_init(XEN_GUEST_HA
    2.30      if ( copy_from_guest(&xenoprof_init, arg, 1) )
    2.31          return -EFAULT;
    2.32  
    2.33 -    if ( (ret = nmi_init(&xenoprof_init.num_events, 
    2.34 -                         &xenoprof_init.is_primary, 
    2.35 -                         xenoprof_init.cpu_type)) )
    2.36 +    if ( (ret = xenoprof_arch_init(&xenoprof_init.num_events, 
    2.37 +                                   &xenoprof_init.is_primary, 
    2.38 +                                   xenoprof_init.cpu_type)) )
    2.39          return ret;
    2.40  
    2.41      if ( copy_to_guest(arg, &xenoprof_init, 1) )
    2.42 @@ -574,14 +562,12 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN
    2.43              ret = -EPERM;
    2.44              break;
    2.45          }
    2.46 -        ret = nmi_reserve_counters();
    2.47 +        ret = xenoprof_arch_reserve_counters();
    2.48          if ( !ret )
    2.49              xenoprof_state = XENOPROF_COUNTERS_RESERVED;
    2.50          break;
    2.51  
    2.52      case XENOPROF_counter:
    2.53 -    {
    2.54 -        struct xenoprof_counter counter;
    2.55          if ( (xenoprof_state != XENOPROF_COUNTERS_RESERVED) ||
    2.56               (adomains == 0) )
    2.57          {
    2.58 @@ -589,22 +575,8 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN
    2.59              break;
    2.60          }
    2.61  
    2.62 -        if ( copy_from_guest(&counter, arg, 1) )
    2.63 -            return -EFAULT;
    2.64 -
    2.65 -        if ( counter.ind > OP_MAX_COUNTER )
    2.66 -            return -E2BIG;
    2.67 -
    2.68 -        counter_config[counter.ind].count     = counter.count;
    2.69 -        counter_config[counter.ind].enabled   = counter.enabled;
    2.70 -        counter_config[counter.ind].event     = counter.event;
    2.71 -        counter_config[counter.ind].kernel    = counter.kernel;
    2.72 -        counter_config[counter.ind].user      = counter.user;
    2.73 -        counter_config[counter.ind].unit_mask = counter.unit_mask;
    2.74 -
    2.75 -        ret = 0;
    2.76 +        ret = xenoprof_arch_counter(arg);
    2.77          break;
    2.78 -    }
    2.79  
    2.80      case XENOPROF_setup_events:
    2.81          if ( xenoprof_state != XENOPROF_COUNTERS_RESERVED )
    2.82 @@ -612,7 +584,7 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN
    2.83              ret = -EPERM;
    2.84              break;
    2.85          }
    2.86 -        ret = nmi_setup_events();
    2.87 +        ret = xenoprof_arch_setup_events();
    2.88          if ( !ret )
    2.89              xenoprof_state = XENOPROF_READY;
    2.90          break;
    2.91 @@ -622,7 +594,7 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN
    2.92          int i;
    2.93          if ( current->domain == primary_profiler )
    2.94          {
    2.95 -            nmi_enable_virq();
    2.96 +            xenoprof_arch_enable_virq();
    2.97              xenoprof_reset_stat();
    2.98              for ( i = 0; i < pdomains; i++ )
    2.99                  xenoprof_reset_buf(passive_domains[i]);
   2.100 @@ -636,7 +608,7 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN
   2.101          ret = -EPERM;
   2.102          if ( (xenoprof_state == XENOPROF_READY) &&
   2.103               (activated == adomains) )
   2.104 -            ret = nmi_start();
   2.105 +            ret = xenoprof_arch_start();
   2.106  
   2.107          if ( ret == 0 )
   2.108              xenoprof_state = XENOPROF_PROFILING;
   2.109 @@ -647,7 +619,7 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN
   2.110              ret = -EPERM;
   2.111              break;
   2.112          }
   2.113 -        nmi_stop();
   2.114 +        xenoprof_arch_stop();
   2.115          xenoprof_state = XENOPROF_READY;
   2.116          break;
   2.117  
   2.118 @@ -667,8 +639,8 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN
   2.119               (xenoprof_state == XENOPROF_READY) )
   2.120          {
   2.121              xenoprof_state = XENOPROF_IDLE;
   2.122 -            nmi_release_counters();
   2.123 -            nmi_disable_virq();
   2.124 +            xenoprof_arch_release_counters();
   2.125 +            xenoprof_arch_disable_virq();
   2.126              reset_passive_list();
   2.127              ret = 0;
   2.128          }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/include/asm-x86/xenoprof.h	Wed Nov 22 09:48:42 2006 +0000
     3.3 @@ -0,0 +1,57 @@
     3.4 +/******************************************************************************
     3.5 + * asm-x86/xenoprof.h
     3.6 + * xenoprof x86 arch specific header file
     3.7 + *
     3.8 + * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
     3.9 + *                    VA Linux Systems Japan K.K.
    3.10 + *
    3.11 + * This program is free software; you can redistribute it and/or modify
    3.12 + * it under the terms of the GNU General Public License as published by
    3.13 + * the Free Software Foundation; either version 2 of the License, or
    3.14 + * (at your option) any later version.
    3.15 + *
    3.16 + * This program is distributed in the hope that it will be useful,
    3.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.19 + * GNU General Public License for more details.
    3.20 + *
    3.21 + * You should have received a copy of the GNU General Public License
    3.22 + * along with this program; if not, write to the Free Software
    3.23 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    3.24 + */
    3.25 +
    3.26 +#ifndef __ASM_X86_XENOPROF_H__
    3.27 +#define __ASM_X86_XENOPROF_H__
    3.28 +
    3.29 +int nmi_init(int *num_events, int *is_primary, char *cpu_type);
    3.30 +int nmi_reserve_counters(void);
    3.31 +int nmi_setup_events(void);
    3.32 +int nmi_enable_virq(void);
    3.33 +int nmi_start(void);
    3.34 +void nmi_stop(void);
    3.35 +void nmi_disable_virq(void);
    3.36 +void nmi_release_counters(void);
    3.37 +
    3.38 +#define xenoprof_arch_init(num_events, is_primary, cpu_type)    \
    3.39 +    nmi_init(num_events, is_primary, cpu_type)
    3.40 +#define xenoprof_arch_reserve_counters()        nmi_reserve_counters()
    3.41 +#define xenoprof_arch_setup_events()            nmi_setup_events()
    3.42 +#define xenoprof_arch_enable_virq()             nmi_enable_virq()
    3.43 +#define xenoprof_arch_start()                   nmi_start()
    3.44 +#define xenoprof_arch_stop()                    nmi_stop()
    3.45 +#define xenoprof_arch_disable_virq()            nmi_disable_virq()
    3.46 +#define xenoprof_arch_release_counters()        nmi_release_counters()
    3.47 +
    3.48 +int xenoprof_arch_counter(XEN_GUEST_HANDLE(void) arg);
    3.49 +
    3.50 +#endif /* __ASM_X86_XENOPROF_H__ */
    3.51 +
    3.52 +/*
    3.53 + * Local variables:
    3.54 + * mode: C
    3.55 + * c-set-style: "BSD"
    3.56 + * c-basic-offset: 4
    3.57 + * tab-width: 4
    3.58 + * indent-tabs-mode: nil
    3.59 + * End:
    3.60 + */
     4.1 --- a/xen/include/xen/xenoprof.h	Wed Nov 22 09:35:50 2006 +0000
     4.2 +++ b/xen/include/xen/xenoprof.h	Wed Nov 22 09:48:42 2006 +0000
     4.3 @@ -11,6 +11,7 @@
     4.4  #define __XEN_XENOPROF_H__
     4.5  
     4.6  #include <public/xenoprof.h>
     4.7 +#include <asm/xenoprof.h>
     4.8  
     4.9  #define XENOPROF_DOMAIN_IGNORED    0
    4.10  #define XENOPROF_DOMAIN_ACTIVE     1
    4.11 @@ -27,7 +28,7 @@ struct xenoprof_vcpu {
    4.12  };
    4.13  
    4.14  struct xenoprof {
    4.15 -    char* rawbuf;
    4.16 +    char *rawbuf;
    4.17      int npages;
    4.18      int nbuf;
    4.19      int bufsize;