ia64/xen-unstable

changeset 12327:eea9247ad5a0

[XENOPROF] Oprofile user level samples for passive domains are being lost.
The number of of lost samples is most significant when dom0 is idle.

From: joserenato.santos@hp.com
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Nov 09 11:47:42 2006 +0000 (2006-11-09)
parents b8a2db59150a
children b1a68f065fbd
files patches/linux-2.6.16.29/xenoprof-generic.patch
line diff
     1.1 --- a/patches/linux-2.6.16.29/xenoprof-generic.patch	Wed Nov 08 18:29:16 2006 +0000
     1.2 +++ b/patches/linux-2.6.16.29/xenoprof-generic.patch	Thu Nov 09 11:47:42 2006 +0000
     1.3 @@ -1,6 +1,6 @@
     1.4  diff -pruN ../orig-linux-2.6.16.29/drivers/oprofile/buffer_sync.c ./drivers/oprofile/buffer_sync.c
     1.5 ---- ../orig-linux-2.6.16.29/drivers/oprofile/buffer_sync.c	2006-09-12 19:02:10.000000000 +0100
     1.6 -+++ ./drivers/oprofile/buffer_sync.c	2006-09-19 14:06:05.000000000 +0100
     1.7 +--- ../orig-linux-2.6.16.29/drivers/oprofile/buffer_sync.c	2006-11-06 14:46:52.000000000 -0800
     1.8 ++++ ./drivers/oprofile/buffer_sync.c	2006-11-06 15:16:52.000000000 -0800
     1.9  @@ -6,6 +6,10 @@
    1.10    *
    1.11    * @author John Levon <levon@movementarian.org>
    1.12 @@ -12,7 +12,27 @@ diff -pruN ../orig-linux-2.6.16.29/drive
    1.13    * This is the core of the buffer management. Each
    1.14    * CPU buffer is processed and entered into the
    1.15    * global event buffer. Such processing is necessary
    1.16 -@@ -275,15 +279,31 @@ static void add_cpu_switch(int i)
    1.17 +@@ -38,6 +42,7 @@ static cpumask_t marked_cpus = CPU_MASK_
    1.18 + static DEFINE_SPINLOCK(task_mortuary);
    1.19 + static void process_task_mortuary(void);
    1.20 + 
    1.21 ++static int cpu_current_domain[NR_CPUS];
    1.22 + 
    1.23 + /* Take ownership of the task struct and place it on the
    1.24 +  * list for processing. Only after two full buffer syncs
    1.25 +@@ -146,6 +151,11 @@ static void end_sync(void)
    1.26 + int sync_start(void)
    1.27 + {
    1.28 + 	int err;
    1.29 ++	int i;
    1.30 ++
    1.31 ++	for (i = 0; i < NR_CPUS; i++) {
    1.32 ++		cpu_current_domain[i] = COORDINATOR_DOMAIN;
    1.33 ++	}
    1.34 + 
    1.35 + 	start_cpu_work();
    1.36 + 
    1.37 +@@ -275,15 +285,31 @@ static void add_cpu_switch(int i)
    1.38   	last_cookie = INVALID_COOKIE;
    1.39   }
    1.40   
    1.41 @@ -50,7 +70,7 @@ diff -pruN ../orig-linux-2.6.16.29/drive
    1.42   static void
    1.43   add_user_ctx_switch(struct task_struct const * task, unsigned long cookie)
    1.44   {
    1.45 -@@ -348,9 +368,9 @@ static int add_us_sample(struct mm_struc
    1.46 +@@ -348,9 +374,9 @@ static int add_us_sample(struct mm_struc
    1.47    * for later lookup from userspace.
    1.48    */
    1.49   static int
    1.50 @@ -62,7 +82,7 @@ diff -pruN ../orig-linux-2.6.16.29/drive
    1.51   		add_sample_entry(s->eip, s->event);
    1.52   		return 1;
    1.53   	} else if (mm) {
    1.54 -@@ -496,10 +516,11 @@ void sync_buffer(int cpu)
    1.55 +@@ -496,15 +522,21 @@ void sync_buffer(int cpu)
    1.56   	struct mm_struct *mm = NULL;
    1.57   	struct task_struct * new;
    1.58   	unsigned long cookie = 0;
    1.59 @@ -75,7 +95,17 @@ diff -pruN ../orig-linux-2.6.16.29/drive
    1.60   
    1.61   	down(&buffer_sem);
    1.62    
    1.63 -@@ -512,16 +533,18 @@ void sync_buffer(int cpu)
    1.64 + 	add_cpu_switch(cpu);
    1.65 + 
    1.66 ++	/* We need to assign the first samples in this CPU buffer to the
    1.67 ++	   same domain that we were processing at the last sync_buffer */
    1.68 ++	if (cpu_current_domain[cpu] != COORDINATOR_DOMAIN) {
    1.69 ++		add_domain_switch(cpu_current_domain[cpu]);
    1.70 ++	}
    1.71 + 	/* Remember, only we can modify tail_pos */
    1.72 + 
    1.73 + 	available = get_slots(cpu_buf);
    1.74 +@@ -512,16 +544,18 @@ void sync_buffer(int cpu)
    1.75   	for (i = 0; i < available; ++i) {
    1.76   		struct op_sample * s = &cpu_buf->buffer[cpu_buf->tail_pos];
    1.77    
    1.78 @@ -99,7 +129,7 @@ diff -pruN ../orig-linux-2.6.16.29/drive
    1.79   			} else {
    1.80   				struct mm_struct * oldmm = mm;
    1.81   
    1.82 -@@ -535,11 +558,16 @@ void sync_buffer(int cpu)
    1.83 +@@ -535,11 +569,21 @@ void sync_buffer(int cpu)
    1.84   				add_user_ctx_switch(new, cookie);
    1.85   			}
    1.86   		} else {
    1.87 @@ -109,10 +139,15 @@ diff -pruN ../orig-linux-2.6.16.29/drive
    1.88  -					state = sb_bt_ignore;
    1.89  -					atomic_inc(&oprofile_stats.bt_lost_no_mapping);
    1.90  +			if (domain_switch) {
    1.91 ++				cpu_current_domain[cpu] = s->eip;
    1.92  +				add_domain_switch(s->eip);
    1.93  +				domain_switch = 0;
    1.94  +			} else {
    1.95 -+				if (state >= sb_bt_start &&
    1.96 ++				if (cpu_current_domain[cpu] !=
    1.97 ++				    COORDINATOR_DOMAIN) {
    1.98 ++					add_sample_entry(s->eip, s->event);
    1.99 ++				}
   1.100 ++				else  if (state >= sb_bt_start &&
   1.101  +				    !add_sample(mm, s, cpu_mode)) {
   1.102  +					if (state == sb_bt_start) {
   1.103  +						state = sb_bt_ignore;
   1.104 @@ -121,9 +156,21 @@ diff -pruN ../orig-linux-2.6.16.29/drive
   1.105   				}
   1.106   			}
   1.107   		}
   1.108 +@@ -548,6 +592,11 @@ void sync_buffer(int cpu)
   1.109 + 	}
   1.110 + 	release_mm(mm);
   1.111 + 
   1.112 ++	/* We reset domain to COORDINATOR at each CPU switch */
   1.113 ++	if (cpu_current_domain[cpu] != COORDINATOR_DOMAIN) {
   1.114 ++		add_domain_switch(COORDINATOR_DOMAIN);
   1.115 ++	}
   1.116 ++
   1.117 + 	mark_done(cpu);
   1.118 + 
   1.119 + 	up(&buffer_sem);
   1.120  diff -pruN ../orig-linux-2.6.16.29/drivers/oprofile/cpu_buffer.c ./drivers/oprofile/cpu_buffer.c
   1.121 ---- ../orig-linux-2.6.16.29/drivers/oprofile/cpu_buffer.c	2006-09-12 19:02:10.000000000 +0100
   1.122 -+++ ./drivers/oprofile/cpu_buffer.c	2006-09-19 14:06:05.000000000 +0100
   1.123 +--- ../orig-linux-2.6.16.29/drivers/oprofile/cpu_buffer.c	2006-11-06 14:46:52.000000000 -0800
   1.124 ++++ ./drivers/oprofile/cpu_buffer.c	2006-11-06 14:47:55.000000000 -0800
   1.125  @@ -6,6 +6,10 @@
   1.126    *
   1.127    * @author John Levon <levon@movementarian.org>
   1.128 @@ -233,8 +280,8 @@ diff -pruN ../orig-linux-2.6.16.29/drive
   1.129    * This serves to avoid cpu buffer overflow, and makes sure
   1.130    * the task mortuary progresses
   1.131  diff -pruN ../orig-linux-2.6.16.29/drivers/oprofile/cpu_buffer.h ./drivers/oprofile/cpu_buffer.h
   1.132 ---- ../orig-linux-2.6.16.29/drivers/oprofile/cpu_buffer.h	2006-09-12 19:02:10.000000000 +0100
   1.133 -+++ ./drivers/oprofile/cpu_buffer.h	2006-09-19 14:06:05.000000000 +0100
   1.134 +--- ../orig-linux-2.6.16.29/drivers/oprofile/cpu_buffer.h	2006-11-06 14:46:52.000000000 -0800
   1.135 ++++ ./drivers/oprofile/cpu_buffer.h	2006-11-06 14:47:55.000000000 -0800
   1.136  @@ -36,7 +36,7 @@ struct oprofile_cpu_buffer {
   1.137   	volatile unsigned long tail_pos;
   1.138   	unsigned long buffer_size;
   1.139 @@ -258,8 +305,8 @@ diff -pruN ../orig-linux-2.6.16.29/drive
   1.140   
   1.141   #endif /* OPROFILE_CPU_BUFFER_H */
   1.142  diff -pruN ../orig-linux-2.6.16.29/drivers/oprofile/event_buffer.h ./drivers/oprofile/event_buffer.h
   1.143 ---- ../orig-linux-2.6.16.29/drivers/oprofile/event_buffer.h	2006-09-12 19:02:10.000000000 +0100
   1.144 -+++ ./drivers/oprofile/event_buffer.h	2006-09-19 14:06:05.000000000 +0100
   1.145 +--- ../orig-linux-2.6.16.29/drivers/oprofile/event_buffer.h	2006-11-06 14:46:52.000000000 -0800
   1.146 ++++ ./drivers/oprofile/event_buffer.h	2006-11-06 14:47:55.000000000 -0800
   1.147  @@ -29,15 +29,20 @@ void wake_up_buffer_waiter(void);
   1.148   #define CPU_SWITCH_CODE 		2
   1.149   #define COOKIE_SWITCH_CODE 		3
   1.150 @@ -283,8 +330,8 @@ diff -pruN ../orig-linux-2.6.16.29/drive
   1.151   void add_event_entry(unsigned long data);
   1.152    
   1.153  diff -pruN ../orig-linux-2.6.16.29/drivers/oprofile/oprof.c ./drivers/oprofile/oprof.c
   1.154 ---- ../orig-linux-2.6.16.29/drivers/oprofile/oprof.c	2006-09-12 19:02:10.000000000 +0100
   1.155 -+++ ./drivers/oprofile/oprof.c	2006-09-19 14:06:05.000000000 +0100
   1.156 +--- ../orig-linux-2.6.16.29/drivers/oprofile/oprof.c	2006-11-06 14:46:52.000000000 -0800
   1.157 ++++ ./drivers/oprofile/oprof.c	2006-11-06 14:47:55.000000000 -0800
   1.158  @@ -5,6 +5,10 @@
   1.159    * @remark Read the file COPYING
   1.160    *
   1.161 @@ -339,8 +386,8 @@ diff -pruN ../orig-linux-2.6.16.29/drive
   1.162   {
   1.163   	int err;
   1.164  diff -pruN ../orig-linux-2.6.16.29/drivers/oprofile/oprof.h ./drivers/oprofile/oprof.h
   1.165 ---- ../orig-linux-2.6.16.29/drivers/oprofile/oprof.h	2006-09-12 19:02:10.000000000 +0100
   1.166 -+++ ./drivers/oprofile/oprof.h	2006-09-19 14:06:05.000000000 +0100
   1.167 +--- ../orig-linux-2.6.16.29/drivers/oprofile/oprof.h	2006-11-06 14:46:52.000000000 -0800
   1.168 ++++ ./drivers/oprofile/oprof.h	2006-11-06 14:47:55.000000000 -0800
   1.169  @@ -35,5 +35,8 @@ void oprofile_create_files(struct super_
   1.170   void oprofile_timer_init(struct oprofile_operations * ops);
   1.171   
   1.172 @@ -351,8 +398,8 @@ diff -pruN ../orig-linux-2.6.16.29/drive
   1.173    
   1.174   #endif /* OPROF_H */
   1.175  diff -pruN ../orig-linux-2.6.16.29/drivers/oprofile/oprofile_files.c ./drivers/oprofile/oprofile_files.c
   1.176 ---- ../orig-linux-2.6.16.29/drivers/oprofile/oprofile_files.c	2006-09-12 19:02:10.000000000 +0100
   1.177 -+++ ./drivers/oprofile/oprofile_files.c	2006-09-19 14:06:05.000000000 +0100
   1.178 +--- ../orig-linux-2.6.16.29/drivers/oprofile/oprofile_files.c	2006-11-06 14:46:52.000000000 -0800
   1.179 ++++ ./drivers/oprofile/oprofile_files.c	2006-11-06 14:47:55.000000000 -0800
   1.180  @@ -5,15 +5,21 @@
   1.181    * @remark Read the file COPYING
   1.182    *
   1.183 @@ -581,8 +628,8 @@ diff -pruN ../orig-linux-2.6.16.29/drive
   1.184   	oprofilefs_create_ulong(sb, root, "buffer_size", &fs_buffer_size);
   1.185   	oprofilefs_create_ulong(sb, root, "buffer_watershed", &fs_buffer_watershed);
   1.186  diff -pruN ../orig-linux-2.6.16.29/include/linux/oprofile.h ./include/linux/oprofile.h
   1.187 ---- ../orig-linux-2.6.16.29/include/linux/oprofile.h	2006-09-12 19:02:10.000000000 +0100
   1.188 -+++ ./include/linux/oprofile.h	2006-09-19 14:06:05.000000000 +0100
   1.189 +--- ../orig-linux-2.6.16.29/include/linux/oprofile.h	2006-11-06 14:46:42.000000000 -0800
   1.190 ++++ ./include/linux/oprofile.h	2006-11-06 14:47:55.000000000 -0800
   1.191  @@ -16,6 +16,8 @@
   1.192   #include <linux/types.h>
   1.193   #include <linux/spinlock.h>