summaryrefslogtreecommitdiff
blob: fdcca5b3736ec8659f082154621f4d1cbfcb5678 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
Subject: Fix xen build.
From: jbeulich@novell.com

$subject says all.

---
 drivers/ide/ide-lib.c             |    9 +++++++++
 drivers/oprofile/buffer_sync.c    |   35 ++++++++++++++++++++++++-----------
 drivers/oprofile/cpu_buffer.c     |    6 ++++++
 drivers/oprofile/oprof.c          |    2 ++
 drivers/oprofile/oprofile_files.c |    6 ++++++
 include/linux/gfp.h               |    6 +-----
 include/linux/mm.h                |    2 ++
 include/linux/oprofile.h          |    6 ++++--
 include/linux/page-flags.h        |    3 +--
 kernel/timer.c                    |   14 ++++++++++----
 mm/memory.c                       |    4 ++++
 11 files changed, 69 insertions(+), 24 deletions(-)

--- a/drivers/ide/ide-lib.c	2007-08-27 14:01:24.000000000 -0400
+++ b/drivers/ide/ide-lib.c	2007-08-27 14:01:25.000000000 -0400
@@ -341,12 +341,21 @@ void ide_toggle_bounce(ide_drive_t *driv
 {
 	u64 addr = BLK_BOUNCE_HIGH;	/* dma64_addr_t */
 
+#ifndef CONFIG_XEN
+	if (!PCI_DMA_BUS_IS_PHYS) {
+		addr = BLK_BOUNCE_ANY;
+	} else if (on && drive->media == ide_disk) {
+		if (HWIF(drive)->pci_dev)
+			addr = HWIF(drive)->pci_dev->dma_mask;
+	}
+#else
 	if (on && drive->media == ide_disk) {
 		if (!PCI_DMA_BUS_IS_PHYS)
 			addr = BLK_BOUNCE_ANY;
 		else if (HWIF(drive)->pci_dev)
 			addr = HWIF(drive)->pci_dev->dma_mask;
 	}
+#endif
 
 	if (drive->queue)
 		blk_queue_bounce_limit(drive->queue, addr);
--- a/drivers/oprofile/buffer_sync.c	2007-08-27 14:01:24.000000000 -0400
+++ b/drivers/oprofile/buffer_sync.c	2007-08-27 14:01:25.000000000 -0400
@@ -43,7 +43,9 @@ static cpumask_t marked_cpus = CPU_MASK_
 static DEFINE_SPINLOCK(task_mortuary);
 static void process_task_mortuary(void);
 
+#ifdef CONFIG_XEN
 static int cpu_current_domain[NR_CPUS];
+#endif
 
 /* Take ownership of the task struct and place it on the
  * list for processing. Only after two full buffer syncs
@@ -152,11 +154,13 @@ static void end_sync(void)
 int sync_start(void)
 {
 	int err;
+#ifdef CONFIG_XEN
 	int i;
 
 	for (i = 0; i < NR_CPUS; i++) {
 		cpu_current_domain[i] = COORDINATOR_DOMAIN;
 	}
+#endif
 
 	start_cpu_work();
 
@@ -304,12 +308,14 @@ static void add_cpu_mode_switch(unsigned
 	}
 }
 
+#ifdef CONFIG_XEN
 static void add_domain_switch(unsigned long domain_id)
 {
 	add_event_entry(ESCAPE_CODE);
 	add_event_entry(DOMAIN_SWITCH_CODE);
 	add_event_entry(domain_id);
 }
+#endif
 
 static void
 add_user_ctx_switch(struct task_struct const * task, unsigned long cookie)
@@ -533,11 +539,14 @@ void sync_buffer(int cpu)
  
 	add_cpu_switch(cpu);
 
+#ifdef CONFIG_XEN
 	/* We need to assign the first samples in this CPU buffer to the
 	   same domain that we were processing at the last sync_buffer */
 	if (cpu_current_domain[cpu] != COORDINATOR_DOMAIN) {
 		add_domain_switch(cpu_current_domain[cpu]);
 	}
+#endif
+
 	/* Remember, only we can modify tail_pos */
 
 	available = get_slots(cpu_buf);
@@ -555,8 +564,10 @@ void sync_buffer(int cpu)
 			} else if (s->event == CPU_TRACE_BEGIN) {
 				state = sb_bt_start;
 				add_trace_begin();
+#ifdef CONFIG_XEN
 			} else if (s->event == CPU_DOMAIN_SWITCH) {
-					domain_switch = 1;				
+				domain_switch = 1;
+#endif
 			} else {
 				struct mm_struct * oldmm = mm;
 
@@ -570,21 +581,21 @@ void sync_buffer(int cpu)
 				add_user_ctx_switch(new, cookie);
 			}
 		} else {
+#ifdef CONFIG_XEN
 			if (domain_switch) {
 				cpu_current_domain[cpu] = s->eip;
 				add_domain_switch(s->eip);
 				domain_switch = 0;
-			} else {
-				if (cpu_current_domain[cpu] !=
+			} else if (cpu_current_domain[cpu] !=
 				    COORDINATOR_DOMAIN) {
-					add_sample_entry(s->eip, s->event);
-				}
-				else  if (state >= sb_bt_start &&
-				    !add_sample(mm, s, cpu_mode)) {
-					if (state == sb_bt_start) {
-						state = sb_bt_ignore;
-						atomic_inc(&oprofile_stats.bt_lost_no_mapping);
-					}
+				add_sample_entry(s->eip, s->event);
+			} else
+#endif
+			if (state >= sb_bt_start &&
+			    !add_sample(mm, s, cpu_mode)) {
+				if (state == sb_bt_start) {
+					state = sb_bt_ignore;
+					atomic_inc(&oprofile_stats.bt_lost_no_mapping);
 				}
 			}
 		}
@@ -593,10 +604,12 @@ void sync_buffer(int cpu)
 	}
 	release_mm(mm);
 
+#ifdef CONFIG_XEN
 	/* We reset domain to COORDINATOR at each CPU switch */
 	if (cpu_current_domain[cpu] != COORDINATOR_DOMAIN) {
 		add_domain_switch(COORDINATOR_DOMAIN);
 	}
+#endif
 
 	mark_done(cpu);
 
--- a/drivers/oprofile/cpu_buffer.c	2007-08-27 14:01:24.000000000 -0400
+++ b/drivers/oprofile/cpu_buffer.c	2007-08-27 14:01:25.000000000 -0400
@@ -38,7 +38,11 @@ static void wq_sync_buffer(struct work_s
 #define DEFAULT_TIMER_EXPIRE (HZ / 10)
 static int work_enabled;
 
+#ifndef CONFIG_XEN
+#define current_domain COORDINATOR_DOMAIN
+#else
 static int32_t current_domain = COORDINATOR_DOMAIN;
+#endif
 
 void free_cpu_buffers(void)
 {
@@ -281,6 +285,7 @@ void oprofile_add_trace(unsigned long pc
 	add_sample(cpu_buf, pc, 0);
 }
 
+#ifdef CONFIG_XEN
 int oprofile_add_domain_switch(int32_t domain_id)
 {
 	struct oprofile_cpu_buffer * cpu_buf = &cpu_buffer[smp_processor_id()];
@@ -299,6 +304,7 @@ int oprofile_add_domain_switch(int32_t d
 
 	return 1;
 }
+#endif
 
 /*
  * This serves to avoid cpu buffer overflow, and makes sure
--- a/drivers/oprofile/oprof.c	2007-08-27 14:01:24.000000000 -0400
+++ b/drivers/oprofile/oprof.c	2007-08-27 14:01:25.000000000 -0400
@@ -37,6 +37,7 @@ static DEFINE_MUTEX(start_mutex);
  */
 static int timer = 0;
 
+#ifdef CONFIG_XEN
 int oprofile_set_active(int active_domains[], unsigned int adomains)
 {
 	int err;
@@ -62,6 +63,7 @@ int oprofile_set_passive(int passive_dom
        mutex_unlock(&start_mutex);
 	return err;
 }
+#endif
 
 int oprofile_setup(void)
 {
--- a/drivers/oprofile/oprofile_files.c	2007-08-27 14:01:24.000000000 -0400
+++ b/drivers/oprofile/oprofile_files.c	2007-08-27 14:01:25.000000000 -0400
@@ -124,6 +124,8 @@ static const struct file_operations dump
 	.write		= dump_write,
 };
 
+#ifdef CONFIG_XEN
+
 #define TMPBUFSIZE 512
 
 static unsigned int adomains = 0;
@@ -313,12 +315,16 @@ static struct file_operations passive_do
 	.write		= pdomain_write,
 };
 
+#endif /* CONFIG_XEN */
+
 void oprofile_create_files(struct super_block * sb, struct dentry * root)
 {
 	oprofilefs_create_file(sb, root, "enable", &enable_fops);
 	oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666);
+#ifdef CONFIG_XEN
 	oprofilefs_create_file(sb, root, "active_domains", &active_domain_ops);
 	oprofilefs_create_file(sb, root, "passive_domains", &passive_domain_ops);
+#endif
 	oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);
 	oprofilefs_create_ulong(sb, root, "buffer_size", &fs_buffer_size);
 	oprofilefs_create_ulong(sb, root, "buffer_watershed", &fs_buffer_watershed);
--- a/include/linux/gfp.h	2007-08-27 14:01:25.000000000 -0400
+++ b/include/linux/gfp.h	2007-08-27 14:01:25.000000000 -0400
@@ -115,11 +115,7 @@ static inline enum zone_type gfp_zone(gf
  */
 
 #ifndef HAVE_ARCH_FREE_PAGE
-/*
- * If arch_free_page returns non-zero then the generic free_page code can
- * immediately bail: the arch-specific function has done all the work.
- */
-static inline int arch_free_page(struct page *page, int order) { return 0; }
+static inline void arch_free_page(struct page *page, int order) { }
 #endif
 #ifndef HAVE_ARCH_ALLOC_PAGE
 static inline void arch_alloc_page(struct page *page, int order) { }
--- a/include/linux/mm.h	2007-08-27 14:01:25.000000000 -0400
+++ b/include/linux/mm.h	2007-08-27 14:01:25.000000000 -0400
@@ -211,10 +211,12 @@ struct vm_operations_struct {
 	/* notification that a previously read-only page is about to become
 	 * writable, if an error is returned it will cause a SIGBUS */
 	int (*page_mkwrite)(struct vm_area_struct *vma, struct page *page);
+#ifdef CONFIG_XEN
 	/* Area-specific function for clearing the PTE at @ptep. Returns the
 	 * original value of @ptep. */
 	pte_t (*zap_pte)(struct vm_area_struct *vma, 
 			 unsigned long addr, pte_t *ptep, int is_fullmm);
+#endif
 #ifdef CONFIG_NUMA
 	int (*set_policy)(struct vm_area_struct *vma, struct mempolicy *new);
 	struct mempolicy *(*get_policy)(struct vm_area_struct *vma,
--- a/include/linux/oprofile.h	2007-08-27 14:01:24.000000000 -0400
+++ b/include/linux/oprofile.h	2007-08-27 14:01:25.000000000 -0400
@@ -16,8 +16,9 @@
 #include <linux/types.h>
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
-
+#ifdef CONFIG_XEN
 #include <xen/interface/xenoprof.h>
+#endif
  
 struct super_block;
 struct dentry;
@@ -29,11 +30,12 @@ struct oprofile_operations {
 	/* create any necessary configuration files in the oprofile fs.
 	 * Optional. */
 	int (*create_files)(struct super_block * sb, struct dentry * root);
+#ifdef CONFIG_XEN
 	/* setup active domains with Xen */
 	int (*set_active)(int *active_domains, unsigned int adomains);
         /* setup passive domains with Xen */
         int (*set_passive)(int *passive_domains, unsigned int pdomains);
-	
+#endif
 	/* Do any necessary interrupt setup. Optional. */
 	int (*setup)(void);
 	/* Do any necessary interrupt shutdown. Optional. */
--- a/include/linux/page-flags.h	2007-08-27 14:01:25.000000000 -0400
+++ b/include/linux/page-flags.h	2007-08-27 14:01:25.000000000 -0400
@@ -88,6 +88,7 @@
 
 #define PG_mappedtodisk		16	/* Has blocks allocated on-disk */
 #define PG_reclaim		17	/* To be reclaimed asap */
+#define PG_foreign		18	/* Page is owned by foreign allocator. */
 #define PG_buddy		19	/* Page is free, on buddy lists */
 
 /* PG_owner_priv_1 users should have descriptive aliases */
@@ -104,8 +105,6 @@
 #define PG_uncached		31	/* Page has been mapped as uncached */
 #endif
 
-#define PG_foreign		20	/* Page is owned by foreign allocator. */
-
 /*
  * Manipulation of page state flags
  */
--- a/kernel/timer.c	2007-08-27 14:01:24.000000000 -0400
+++ b/kernel/timer.c	2007-08-27 14:01:25.000000000 -0400
@@ -781,7 +781,7 @@ static unsigned long cmp_next_hrtimer_ev
 unsigned long get_next_timer_interrupt(unsigned long now)
 {
 	tvec_base_t *base = __get_cpu_var(tvec_bases);
-	unsigned long expires, sl_next;
+	unsigned long expires;
 
 	spin_lock(&base->lock);
 	expires = __next_timer_interrupt(base);
@@ -790,11 +790,17 @@ unsigned long get_next_timer_interrupt(u
 	if (time_before_eq(expires, now))
 		return now;
 
+#ifndef CONFIG_XEN
+	return cmp_next_hrtimer_event(now, expires);
+#else
 	expires = cmp_next_hrtimer_event(now, expires);
-	sl_next = softlockup_get_next_event();
+	{
+		unsigned long sl_next = softlockup_get_next_event();
 
-	return expires <= now || expires - now < sl_next
-	       ? expires : now + sl_next;
+		return expires <= now || expires - now < sl_next
+		       ? expires : now + sl_next;
+	}
+#endif
 }
 
 #ifdef CONFIG_NO_IDLE_HZ
--- a/mm/memory.c	2007-08-27 14:01:25.000000000 -0400
+++ b/mm/memory.c	2007-08-27 14:01:25.000000000 -0400
@@ -404,7 +404,9 @@ struct page *vm_normal_page(struct vm_ar
 	 * and that the resulting page looks ok.
 	 */
 	if (unlikely(!pfn_valid(pfn))) {
+#ifdef CONFIG_XEN
 		if (!(vma->vm_flags & VM_RESERVED))
+#endif
 			print_bad_pte(vma, pte, addr);
 		return NULL;
 	}
@@ -663,10 +665,12 @@ static unsigned long zap_pte_range(struc
 				     page->index > details->last_index))
 					continue;
 			}
+#ifdef CONFIG_XEN
 			if (unlikely(vma->vm_ops && vma->vm_ops->zap_pte))
 				ptent = vma->vm_ops->zap_pte(vma, addr, pte,
 							     tlb->fullmm);
 			else
+#endif
 				ptent = ptep_get_and_clear_full(mm, addr, pte,
 								tlb->fullmm);
 			tlb_remove_tlb_entry(tlb, pte, addr);