ia64/xen-unstable

changeset 12539:b63584cc9376

[XENOPROF] Make xenoprof of linux side arch generic with some bug fixes.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author kfraser@localhost.localdomain
date Wed Nov 22 09:50:37 2006 +0000 (2006-11-22)
parents 2f15fce77758
children 1ef9954a2668
files linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c linux-2.6-xen-sparse/drivers/xen/xenoprof/xenoprofile.c linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/xenoprof.h linux-2.6-xen-sparse/include/xen/xenoprof.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c	Wed Nov 22 09:49:55 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c	Wed Nov 22 09:50:37 2006 +0000
     1.3 @@ -15,12 +15,130 @@
     1.4   *                    VA Linux Systems Japan K.K.
     1.5   */
     1.6  
     1.7 +#include <linux/init.h>
     1.8  #include <linux/oprofile.h>
     1.9 +#include <linux/sched.h>
    1.10 +#include <asm/pgtable.h>
    1.11  
    1.12 +#include <xen/driver_util.h>
    1.13 +#include <xen/interface/xen.h>
    1.14 +#include <xen/interface/xenoprof.h>
    1.15  #include <xen/xenoprof.h>
    1.16  #include "op_counter.h"
    1.17  
    1.18 -unsigned int num_events = 0;
    1.19 +static unsigned int num_events = 0;
    1.20 +
    1.21 +void __init xenoprof_arch_init_counter(struct xenoprof_init *init)
    1.22 +{
    1.23 +	num_events = init->num_events;
    1.24 +	/* just in case - make sure we do not overflow event list 
    1.25 +	   (i.e. counter_config list) */
    1.26 +	if (num_events > OP_MAX_COUNTER) {
    1.27 +		num_events = OP_MAX_COUNTER;
    1.28 +		init->num_events = num_events;
    1.29 +	}
    1.30 +}
    1.31 +
    1.32 +void xenoprof_arch_counter(void)
    1.33 +{
    1.34 +	int i;
    1.35 +	struct xenoprof_counter counter;
    1.36 +
    1.37 +	for (i=0; i<num_events; i++) {
    1.38 +		counter.ind       = i;
    1.39 +		counter.count     = (uint64_t)counter_config[i].count;
    1.40 +		counter.enabled   = (uint32_t)counter_config[i].enabled;
    1.41 +		counter.event     = (uint32_t)counter_config[i].event;
    1.42 +		counter.kernel    = (uint32_t)counter_config[i].kernel;
    1.43 +		counter.user      = (uint32_t)counter_config[i].user;
    1.44 +		counter.unit_mask = (uint64_t)counter_config[i].unit_mask;
    1.45 +		HYPERVISOR_xenoprof_op(XENOPROF_counter, 
    1.46 +				       &counter);
    1.47 +	}
    1.48 +}
    1.49 +
    1.50 +void xenoprof_arch_start(void) 
    1.51 +{
    1.52 +	/* nothing */
    1.53 +}
    1.54 +
    1.55 +void xenoprof_arch_stop(void)
    1.56 +{
    1.57 +	/* nothing */
    1.58 +}
    1.59 +
    1.60 +void xenoprof_arch_unmap_shared_buffer(struct xenoprof_shared_buffer * sbuf)
    1.61 +{
    1.62 +	if (sbuf->buffer) {
    1.63 +		vunmap(sbuf->buffer);
    1.64 +		sbuf->buffer = NULL;
    1.65 +	}
    1.66 +}
    1.67 +
    1.68 +int xenoprof_arch_map_shared_buffer(struct xenoprof_get_buffer * get_buffer,
    1.69 +				    struct xenoprof_shared_buffer * sbuf)
    1.70 +{
    1.71 +	int npages, ret;
    1.72 +	struct vm_struct *area;
    1.73 +
    1.74 +	sbuf->buffer = NULL;
    1.75 +	if ( (ret = HYPERVISOR_xenoprof_op(XENOPROF_get_buffer, get_buffer)) )
    1.76 +		return ret;
    1.77 +
    1.78 +	npages = (get_buffer->bufsize * get_buffer->nbuf - 1) / PAGE_SIZE + 1;
    1.79 +
    1.80 +	area = alloc_vm_area(npages * PAGE_SIZE);
    1.81 +	if (area == NULL)
    1.82 +		return -ENOMEM;
    1.83 +
    1.84 +	if ( (ret = direct_kernel_remap_pfn_range(
    1.85 +		      (unsigned long)area->addr,
    1.86 +		      get_buffer->buf_maddr >> PAGE_SHIFT,
    1.87 +		      npages * PAGE_SIZE, __pgprot(_KERNPG_TABLE),
    1.88 +		      DOMID_SELF)) ) {
    1.89 +		vunmap(area->addr);
    1.90 +		return ret;
    1.91 +	}
    1.92 +
    1.93 +	sbuf->buffer = area->addr;
    1.94 +	return ret;
    1.95 +}
    1.96 +
    1.97 +int xenoprof_arch_set_passive(struct xenoprof_passive * pdomain,
    1.98 +			      struct xenoprof_shared_buffer * sbuf)
    1.99 +{
   1.100 +	int ret;
   1.101 +	int npages;
   1.102 +	struct vm_struct *area;
   1.103 +	pgprot_t prot = __pgprot(_KERNPG_TABLE);
   1.104 +
   1.105 +	sbuf->buffer = NULL;
   1.106 +	ret = HYPERVISOR_xenoprof_op(XENOPROF_set_passive, pdomain);
   1.107 +	if (ret)
   1.108 +		goto out;
   1.109 +
   1.110 +	npages = (pdomain->bufsize * pdomain->nbuf - 1) / PAGE_SIZE + 1;
   1.111 +
   1.112 +	area = alloc_vm_area(npages * PAGE_SIZE);
   1.113 +	if (area == NULL) {
   1.114 +		ret = -ENOMEM;
   1.115 +		goto out;
   1.116 +	}
   1.117 +
   1.118 +	ret = direct_kernel_remap_pfn_range(
   1.119 +		(unsigned long)area->addr,
   1.120 +		pdomain->buf_maddr >> PAGE_SHIFT,
   1.121 +		npages * PAGE_SIZE, prot, DOMID_SELF);
   1.122 +	if (ret) {
   1.123 +		vunmap(area->addr);
   1.124 +		goto out;
   1.125 +	}
   1.126 +	sbuf->buffer = area->addr;
   1.127 +
   1.128 +out:
   1.129 +	return ret;
   1.130 +}
   1.131 +
   1.132  struct op_counter_config counter_config[OP_MAX_COUNTER];
   1.133  
   1.134  int xenoprof_create_files(struct super_block * sb, struct dentry * root)
   1.135 @@ -49,3 +167,13 @@ int xenoprof_create_files(struct super_b
   1.136  
   1.137  	return 0;
   1.138  }
   1.139 +
   1.140 +int __init oprofile_arch_init(struct oprofile_operations * ops)
   1.141 +{
   1.142 +	return xenoprofile_init(ops);
   1.143 +}
   1.144 +
   1.145 +void oprofile_arch_exit(void)
   1.146 +{
   1.147 +	xenoprofile_exit();
   1.148 +}
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenoprof/xenoprofile.c	Wed Nov 22 09:49:55 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenoprof/xenoprofile.c	Wed Nov 22 09:50:37 2006 +0000
     2.3 @@ -1,5 +1,5 @@
     2.4  /**
     2.5 - * @file xenoprof.c
     2.6 + * @file xenoprofile.c
     2.7   *
     2.8   * @remark Copyright 2002 OProfile authors
     2.9   * @remark Read the file COPYING
    2.10 @@ -23,14 +23,9 @@
    2.11  #include <linux/slab.h>
    2.12  #include <linux/interrupt.h>
    2.13  #include <linux/vmalloc.h>
    2.14 -#include <asm/nmi.h>
    2.15 -#include <asm/msr.h>
    2.16 -#include <asm/apic.h>
    2.17  #include <asm/pgtable.h>
    2.18  #include <xen/evtchn.h>
    2.19  #include <xen/xenoprof.h>
    2.20 -#include "../../../arch/i386/oprofile/op_counter.h"
    2.21 -
    2.22  #include <xen/driver_util.h>
    2.23  #include <xen/interface/xen.h>
    2.24  #include <xen/interface/xenoprof.h>
    2.25 @@ -39,18 +34,23 @@
    2.26  
    2.27  #define MAX_XENOPROF_SAMPLES 16
    2.28  
    2.29 +/* sample buffers shared with Xen */
    2.30 +xenoprof_buf_t * xenoprof_buf[MAX_VIRT_CPUS];
    2.31 +/* Shared buffer area */
    2.32 +struct xenoprof_shared_buffer shared_buffer;
    2.33 +
    2.34 +/* Passive sample buffers shared with Xen */
    2.35 +xenoprof_buf_t *p_xenoprof_buf[MAX_OPROF_DOMAINS][MAX_VIRT_CPUS];
    2.36 +/* Passive shared buffer area */
    2.37 +struct xenoprof_shared_buffer p_shared_buffer[MAX_OPROF_DOMAINS];
    2.38 +
    2.39  static int xenoprof_start(void);
    2.40  static void xenoprof_stop(void);
    2.41  
    2.42  static int xenoprof_enabled = 0;
    2.43 -extern unsigned int num_events;
    2.44 -static int is_primary = 0;
    2.45 +int xenoprof_is_primary = 0;
    2.46  static int active_defined;
    2.47  
    2.48 -/* sample buffers shared with Xen */
    2.49 -xenoprof_buf_t * xenoprof_buf[MAX_VIRT_CPUS];
    2.50 -/* Shared buffer area */
    2.51 -char * shared_buffer = NULL;
    2.52  /* Number of buffers in shared area (one per VCPU) */
    2.53  int nbuf;
    2.54  /* Mappings of VIRQ_XENOPROF to irq number (per cpu) */
    2.55 @@ -58,11 +58,6 @@ int ovf_irq[NR_CPUS];
    2.56  /* cpu model type string - copied from Xen memory space on XENOPROF_init command */
    2.57  char cpu_type[XENOPROF_CPU_TYPE_SIZE];
    2.58  
    2.59 -/* Passive sample buffers shared with Xen */
    2.60 -xenoprof_buf_t *p_xenoprof_buf[MAX_OPROF_DOMAINS][MAX_VIRT_CPUS];
    2.61 -/* Passive shared buffer area */
    2.62 -char *p_shared_buffer[MAX_OPROF_DOMAINS];
    2.63 -
    2.64  #ifdef CONFIG_PM
    2.65  
    2.66  static int xenoprof_suspend(struct sys_device * dev, pm_message_t state)
    2.67 @@ -103,7 +98,7 @@ static int __init init_driverfs(void)
    2.68  }
    2.69  
    2.70  
    2.71 -static void __exit exit_driverfs(void)
    2.72 +static void exit_driverfs(void)
    2.73  {
    2.74  	sysdev_unregister(&device_oprofile);
    2.75  	sysdev_class_unregister(&oprofile_sysclass);
    2.76 @@ -193,7 +188,7 @@ xenoprof_ovf_interrupt(int irq, void * d
    2.77  
    2.78  	xenoprof_add_pc(buf, 0);
    2.79  
    2.80 -	if (is_primary && !test_and_set_bit(0, &flag)) {
    2.81 +	if (xenoprof_is_primary && !test_and_set_bit(0, &flag)) {
    2.82  		xenoprof_handle_passive();
    2.83  		smp_mb__before_clear_bit();
    2.84  		clear_bit(0, &flag);
    2.85 @@ -207,7 +202,7 @@ static void unbind_virq(void)
    2.86  {
    2.87  	int i;
    2.88  
    2.89 -	for_each_cpu(i) {
    2.90 +	for_each_online_cpu(i) {
    2.91  		if (ovf_irq[i] >= 0) {
    2.92  			unbind_from_irqhandler(ovf_irq[i], NULL);
    2.93  			ovf_irq[i] = -1;
    2.94 @@ -220,7 +215,7 @@ static int bind_virq(void)
    2.95  {
    2.96  	int i, result;
    2.97  
    2.98 -	for_each_cpu(i) {
    2.99 +	for_each_online_cpu(i) {
   2.100  		result = bind_virq_to_irqhandler(VIRQ_XENOPROF,
   2.101  						 i,
   2.102  						 xenoprof_ovf_interrupt,
   2.103 @@ -240,40 +235,33 @@ static int bind_virq(void)
   2.104  }
   2.105  
   2.106  
   2.107 +static void unmap_passive_list(void)
   2.108 +{
   2.109 +	int i;
   2.110 +	for (i = 0; i < pdomains; i++)
   2.111 +		xenoprof_arch_unmap_shared_buffer(&p_shared_buffer[i]);
   2.112 +	pdomains = 0;
   2.113 +}
   2.114 +
   2.115 +
   2.116  static int map_xenoprof_buffer(int max_samples)
   2.117  {
   2.118  	struct xenoprof_get_buffer get_buffer;
   2.119  	struct xenoprof_buf *buf;
   2.120 -	int npages, ret, i;
   2.121 -	struct vm_struct *area;
   2.122 +	int ret, i;
   2.123  
   2.124 -	if ( shared_buffer )
   2.125 +	if ( shared_buffer.buffer )
   2.126  		return 0;
   2.127  
   2.128  	get_buffer.max_samples = max_samples;
   2.129 -
   2.130 -	if ( (ret = HYPERVISOR_xenoprof_op(XENOPROF_get_buffer, &get_buffer)) )
   2.131 +	ret = xenoprof_arch_map_shared_buffer(&get_buffer, &shared_buffer);
   2.132 +	if (ret)
   2.133  		return ret;
   2.134 -
   2.135  	nbuf = get_buffer.nbuf;
   2.136 -	npages = (get_buffer.bufsize * nbuf - 1) / PAGE_SIZE + 1;
   2.137  
   2.138 -	area = alloc_vm_area(npages * PAGE_SIZE);
   2.139 -	if (area == NULL)
   2.140 -		return -ENOMEM;
   2.141 -
   2.142 -	if ( (ret = direct_kernel_remap_pfn_range(
   2.143 -		      (unsigned long)area->addr,
   2.144 -		      get_buffer.buf_maddr >> PAGE_SHIFT,
   2.145 -		      npages * PAGE_SIZE, __pgprot(_KERNPG_TABLE), DOMID_SELF)) ) {
   2.146 -		vunmap(area->addr);
   2.147 -		return ret;
   2.148 -	}
   2.149 -
   2.150 -	shared_buffer = area->addr;
   2.151  	for (i=0; i< nbuf; i++) {
   2.152  		buf = (struct xenoprof_buf*) 
   2.153 -			&shared_buffer[i * get_buffer.bufsize];
   2.154 +			&shared_buffer.buffer[i * get_buffer.bufsize];
   2.155  		BUG_ON(buf->vcpu_id >= MAX_VIRT_CPUS);
   2.156  		xenoprof_buf[buf->vcpu_id] = buf;
   2.157  	}
   2.158 @@ -285,7 +273,6 @@ static int map_xenoprof_buffer(int max_s
   2.159  static int xenoprof_setup(void)
   2.160  {
   2.161  	int ret;
   2.162 -	int i;
   2.163  
   2.164  	if ( (ret = map_xenoprof_buffer(MAX_XENOPROF_SAMPLES)) )
   2.165  		return ret;
   2.166 @@ -293,9 +280,7 @@ static int xenoprof_setup(void)
   2.167  	if ( (ret = bind_virq()) )
   2.168  		return ret;
   2.169  
   2.170 -	if (is_primary) {
   2.171 -		struct xenoprof_counter counter;
   2.172 -
   2.173 +	if (xenoprof_is_primary) {
   2.174  		/* Define dom0 as an active domain if not done yet */
   2.175  		if (!active_defined) {
   2.176  			domid_t domid;
   2.177 @@ -312,17 +297,7 @@ static int xenoprof_setup(void)
   2.178  		ret = HYPERVISOR_xenoprof_op(XENOPROF_reserve_counters, NULL);
   2.179  		if (ret)
   2.180  			goto err;
   2.181 -		for (i=0; i<num_events; i++) {
   2.182 -			counter.ind       = i;
   2.183 -			counter.count     = (uint64_t)counter_config[i].count;
   2.184 -			counter.enabled   = (uint32_t)counter_config[i].enabled;
   2.185 -			counter.event     = (uint32_t)counter_config[i].event;
   2.186 -			counter.kernel    = (uint32_t)counter_config[i].kernel;
   2.187 -			counter.user      = (uint32_t)counter_config[i].user;
   2.188 -			counter.unit_mask = (uint64_t)counter_config[i].unit_mask;
   2.189 -			HYPERVISOR_xenoprof_op(XENOPROF_counter, 
   2.190 -					       &counter);
   2.191 -		}
   2.192 +		xenoprof_arch_counter();
   2.193  		ret = HYPERVISOR_xenoprof_op(XENOPROF_setup_events, NULL);
   2.194  
   2.195  		if (ret)
   2.196 @@ -347,13 +322,16 @@ static void xenoprof_shutdown(void)
   2.197  
   2.198  	HYPERVISOR_xenoprof_op(XENOPROF_disable_virq, NULL);
   2.199  
   2.200 -	if (is_primary) {
   2.201 +	if (xenoprof_is_primary) {
   2.202  		HYPERVISOR_xenoprof_op(XENOPROF_release_counters, NULL);
   2.203  		active_defined = 0;
   2.204  	}
   2.205  
   2.206  	unbind_virq();
   2.207  
   2.208 +	xenoprof_arch_unmap_shared_buffer(&shared_buffer);
   2.209 +	if (xenoprof_is_primary)
   2.210 +		unmap_passive_list();
   2.211  }
   2.212  
   2.213  
   2.214 @@ -361,17 +339,19 @@ static int xenoprof_start(void)
   2.215  {
   2.216  	int ret = 0;
   2.217  
   2.218 -	if (is_primary)
   2.219 +	if (xenoprof_is_primary)
   2.220  		ret = HYPERVISOR_xenoprof_op(XENOPROF_start, NULL);
   2.221 -
   2.222 +	if (!ret)
   2.223 +		xenoprof_arch_start();
   2.224  	return ret;
   2.225  }
   2.226  
   2.227  
   2.228  static void xenoprof_stop(void)
   2.229  {
   2.230 -	if (is_primary)
   2.231 +	if (xenoprof_is_primary)
   2.232  		HYPERVISOR_xenoprof_op(XENOPROF_stop, NULL);
   2.233 +	xenoprof_arch_stop();
   2.234  }
   2.235  
   2.236  
   2.237 @@ -383,7 +363,7 @@ static int xenoprof_set_active(int * act
   2.238  	int set_dom0 = 0;
   2.239  	domid_t domid;
   2.240  
   2.241 -	if (!is_primary)
   2.242 +	if (!xenoprof_is_primary)
   2.243  		return 0;
   2.244  
   2.245  	if (adomains > MAX_OPROF_DOMAINS)
   2.246 @@ -423,12 +403,9 @@ static int xenoprof_set_passive(int * p_
   2.247  {
   2.248  	int ret;
   2.249  	int i, j;
   2.250 -	int npages;
   2.251  	struct xenoprof_buf *buf;
   2.252 -	struct vm_struct *area;
   2.253 -	pgprot_t prot = __pgprot(_KERNPG_TABLE);
   2.254  
   2.255 -	if (!is_primary)
   2.256 +	if (!xenoprof_is_primary)
   2.257          	return 0;
   2.258  
   2.259  	if (pdoms > MAX_OPROF_DOMAINS)
   2.260 @@ -437,57 +414,37 @@ static int xenoprof_set_passive(int * p_
   2.261  	ret = HYPERVISOR_xenoprof_op(XENOPROF_reset_passive_list, NULL);
   2.262  	if (ret)
   2.263  		return ret;
   2.264 +	unmap_passive_list();
   2.265  
   2.266  	for (i = 0; i < pdoms; i++) {
   2.267  		passive_domains[i].domain_id = p_domains[i];
   2.268  		passive_domains[i].max_samples = 2048;
   2.269 -		ret = HYPERVISOR_xenoprof_op(XENOPROF_set_passive,
   2.270 -					     &passive_domains[i]);
   2.271 +		ret = xenoprof_arch_set_passive(&passive_domains[i],
   2.272 +						&p_shared_buffer[i]);
   2.273  		if (ret)
   2.274  			goto out;
   2.275 -
   2.276 -		npages = (passive_domains[i].bufsize * passive_domains[i].nbuf - 1) / PAGE_SIZE + 1;
   2.277 -
   2.278 -		area = alloc_vm_area(npages * PAGE_SIZE);
   2.279 -		if (area == NULL) {
   2.280 -			ret = -ENOMEM;
   2.281 -			goto out;
   2.282 -		}
   2.283 -
   2.284 -		ret = direct_kernel_remap_pfn_range(
   2.285 -			(unsigned long)area->addr,
   2.286 -			passive_domains[i].buf_maddr >> PAGE_SHIFT,
   2.287 -			npages * PAGE_SIZE, prot, DOMID_SELF);
   2.288 -		if (ret) {
   2.289 -			vunmap(area->addr);
   2.290 -			goto out;
   2.291 -		}
   2.292 -
   2.293 -		p_shared_buffer[i] = area->addr;
   2.294 -
   2.295  		for (j = 0; j < passive_domains[i].nbuf; j++) {
   2.296  			buf = (struct xenoprof_buf *)
   2.297 -				&p_shared_buffer[i][j * passive_domains[i].bufsize];
   2.298 +				&p_shared_buffer[i].buffer[j * passive_domains[i].bufsize];
   2.299  			BUG_ON(buf->vcpu_id >= MAX_VIRT_CPUS);
   2.300  			p_xenoprof_buf[i][buf->vcpu_id] = buf;
   2.301  		}
   2.302 -
   2.303  	}
   2.304  
   2.305  	pdomains = pdoms;
   2.306  	return 0;
   2.307  
   2.308  out:
   2.309 -	for (j = 0; j < i; j++) {
   2.310 -		vunmap(p_shared_buffer[j]);
   2.311 -		p_shared_buffer[j] = NULL;
   2.312 -	}
   2.313 +	for (j = 0; j < i; j++)
   2.314 +		xenoprof_arch_unmap_shared_buffer(&p_shared_buffer[i]);
   2.315  
   2.316   	return ret;
   2.317  }
   2.318  
   2.319  struct oprofile_operations xenoprof_ops = {
   2.320 +#ifdef HAVE_XENOPROF_CREATE_FILES
   2.321  	.create_files 	= xenoprof_create_files,
   2.322 +#endif
   2.323  	.set_active	= xenoprof_set_active,
   2.324  	.set_passive    = xenoprof_set_passive,
   2.325  	.setup 		= xenoprof_setup,
   2.326 @@ -500,21 +457,15 @@ struct oprofile_operations xenoprof_ops 
   2.327  /* in order to get driverfs right */
   2.328  static int using_xenoprof;
   2.329  
   2.330 -int __init oprofile_arch_init(struct oprofile_operations * ops)
   2.331 +int __init xenoprofile_init(struct oprofile_operations * ops)
   2.332  {
   2.333  	struct xenoprof_init init;
   2.334  	int ret, i;
   2.335  
   2.336  	ret = HYPERVISOR_xenoprof_op(XENOPROF_init, &init);
   2.337 -
   2.338  	if (!ret) {
   2.339 -		num_events = init.num_events;
   2.340 -		is_primary = init.is_primary;
   2.341 -
   2.342 -		/* just in case - make sure we do not overflow event list 
   2.343 -		   (i.e. counter_config list) */
   2.344 -		if (num_events > OP_MAX_COUNTER)
   2.345 -			num_events = OP_MAX_COUNTER;
   2.346 +		xenoprof_arch_init_counter(&init);
   2.347 +		xenoprof_is_primary = init.is_primary;
   2.348  
   2.349  		/*  cpu_type is detected by Xen */
   2.350  		cpu_type[XENOPROF_CPU_TYPE_SIZE-1] = 0;
   2.351 @@ -530,30 +481,20 @@ int __init oprofile_arch_init(struct opr
   2.352  
   2.353  		active_defined = 0;
   2.354  	}
   2.355 -	printk(KERN_INFO "oprofile_arch_init: ret %d, events %d, "
   2.356 -	       "is_primary %d\n", ret, num_events, is_primary);
   2.357 +	printk(KERN_INFO "%s: ret %d, events %d, xenoprof_is_primary %d\n",
   2.358 +	       __func__, ret, init.num_events, xenoprof_is_primary);
   2.359  	return ret;
   2.360  }
   2.361  
   2.362  
   2.363 -void __exit oprofile_arch_exit(void)
   2.364 +void xenoprofile_exit(void)
   2.365  {
   2.366 -	int i;
   2.367 -
   2.368  	if (using_xenoprof)
   2.369  		exit_driverfs();
   2.370  
   2.371 -	if (shared_buffer) {
   2.372 -		vunmap(shared_buffer);
   2.373 -		shared_buffer = NULL;
   2.374 -	}
   2.375 -	if (is_primary) {
   2.376 -		for (i = 0; i < pdomains; i++)
   2.377 -			if (p_shared_buffer[i]) {
   2.378 -		                vunmap(p_shared_buffer[i]);
   2.379 -                		p_shared_buffer[i] = NULL;
   2.380 -			}
   2.381 +	xenoprof_arch_unmap_shared_buffer(&shared_buffer);
   2.382 +	if (xenoprof_is_primary) {
   2.383 +		unmap_passive_list();
   2.384  		HYPERVISOR_xenoprof_op(XENOPROF_shutdown, NULL);
   2.385          }
   2.386 -
   2.387  }
     3.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/xenoprof.h	Wed Nov 22 09:49:55 2006 +0000
     3.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/xenoprof.h	Wed Nov 22 09:50:37 2006 +0000
     3.3 @@ -21,11 +21,28 @@
     3.4   */
     3.5  #ifndef __ASM_XENOPROF_H__
     3.6  #define __ASM_XENOPROF_H__
     3.7 -#ifdef CONFIG_OPROFILE 
     3.8 +#ifdef CONFIG_OPROFILE
     3.9  
    3.10  struct super_block;
    3.11  struct dentry;
    3.12  int xenoprof_create_files(struct super_block * sb, struct dentry * root);
    3.13 +#define HAVE_XENOPROF_CREATE_FILES
    3.14 +
    3.15 +struct xenoprof_init;
    3.16 +void xenoprof_arch_init_counter(struct xenoprof_init *init);
    3.17 +void xenoprof_arch_counter(void);
    3.18 +void xenoprof_arch_start(void);
    3.19 +void xenoprof_arch_stop(void);
    3.20 +
    3.21 +struct xenoprof_arch_shared_buffer {
    3.22 +	/* nothing */
    3.23 +};
    3.24 +struct xenoprof_shared_buffer;
    3.25 +void xenoprof_arch_unmap_shared_buffer(struct xenoprof_shared_buffer* sbuf);
    3.26 +struct xenoprof_get_buffer;
    3.27 +int xenoprof_arch_map_shared_buffer(struct xenoprof_get_buffer* get_buffer, struct xenoprof_shared_buffer* sbuf);
    3.28 +struct xenoprof_passive;
    3.29 +int xenoprof_arch_set_passive(struct xenoprof_passive* pdomain, struct xenoprof_shared_buffer* sbuf);
    3.30  
    3.31  #endif /* CONFIG_OPROFILE */
    3.32  #endif /* __ASM_XENOPROF_H__ */
     4.1 --- a/linux-2.6-xen-sparse/include/xen/xenoprof.h	Wed Nov 22 09:49:55 2006 +0000
     4.2 +++ b/linux-2.6-xen-sparse/include/xen/xenoprof.h	Wed Nov 22 09:50:37 2006 +0000
     4.3 @@ -22,9 +22,24 @@
     4.4  
     4.5  #ifndef __XEN_XENOPROF_H__
     4.6  #define __XEN_XENOPROF_H__
     4.7 +
     4.8  #ifdef CONFIG_OPROFILE
     4.9 -
    4.10  #include <asm/xenoprof.h>
    4.11  
    4.12 +struct oprofile_operations;
    4.13 +int xenoprofile_init(struct oprofile_operations * ops);
    4.14 +void xenoprofile_exit(void);
    4.15 +
    4.16 +extern int xenoprof_is_primary;
    4.17 +#define is_xenoprof_primary()	(xenoprof_is_primary)
    4.18 +struct xenoprof_shared_buffer {
    4.19 +	char					*buffer;
    4.20 +	struct xenoprof_arch_shared_buffer	arch;
    4.21 +};
    4.22 +#else
    4.23 +#define xenoprofile_init(ops)	do { } while (0)
    4.24 +#define xenoprofile_exit()	do { } while (0)
    4.25 +#define is_xenoprof_primary()	(0)
    4.26  #endif /* CONFIG_OPROFILE */
    4.27 +
    4.28  #endif /* __XEN_XENOPROF_H__ */