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 #include #include - +#ifdef CONFIG_XEN #include +#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);