[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] xenoprof: cleanup



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1329378726 -3600
# Node ID 98c00677dacbbcf1419eb08036077e63c4fd26d4
# Parent  dc034d0ccdd857503de483012bea9c8e549daa76
xenoprof: cleanup

- frame Xen-specific additions with CONFIG_XEN conditionals
- use per-CPU data
- fix indentation

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r dc034d0ccdd8 -r 98c00677dacb drivers/oprofile/buffer_sync.c
--- a/drivers/oprofile/buffer_sync.c    Wed Feb 15 12:09:02 2012 +0100
+++ b/drivers/oprofile/buffer_sync.c    Thu Feb 16 08:52:06 2012 +0100
@@ -42,7 +42,10 @@
 static DEFINE_SPINLOCK(task_mortuary);
 static void process_task_mortuary(void);
 
-static int cpu_current_domain[NR_CPUS];
+#ifdef CONFIG_XEN
+#include <linux/percpu.h>
+static DEFINE_PER_CPU(int, current_domain) = COORDINATOR_DOMAIN;
+#endif
 
 /* Take ownership of the task struct and place it on the
  * list for processing. Only after two full buffer syncs
@@ -151,11 +154,12 @@
 int sync_start(void)
 {
        int err;
-       int i;
+#ifdef CONFIG_XEN
+       unsigned int cpu;
 
-       for (i = 0; i < NR_CPUS; i++) {
-               cpu_current_domain[i] = COORDINATOR_DOMAIN;
-       }
+       for_each_online_cpu(cpu)
+               per_cpu(current_domain, cpu) = COORDINATOR_DOMAIN;
+#endif
 
        start_cpu_work();
 
@@ -303,12 +307,14 @@
        }
 }
 
+#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)
@@ -498,6 +504,7 @@
        cpus_clear(marked_cpus);
 }
 
+#ifdef CONFIG_XEN
 /* Add IBS samples into event buffer */
 #define IBS_FETCH_SIZE 8
 #define IBS_OP_SIZE            14
@@ -559,6 +566,9 @@
 
        return size;
 }
+#else
+#define add_ibs_data(cpu, mm, cpu_mode) 0
+#endif
 
 /* FIXME: this is not sufficient if we implement syscall barrier backtrace
  * traversal, the code switch to sb_sample_start at first kernel enter/exit
@@ -594,11 +604,12 @@
  
        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]);
-       }
+       if (per_cpu(current_domain, cpu) != COORDINATOR_DOMAIN)
+               add_domain_switch(per_cpu(current_domain, cpu));
+#endif
        /* Remember, only we can modify tail_pos */
 
        available = get_slots(cpu_buf);
@@ -616,8 +627,10 @@
                        } 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;
 
@@ -633,21 +646,23 @@
                        is_ibs_sample = add_ibs_data(cpu, mm, cpu_mode);
 
                } else {
+#ifdef CONFIG_XEN
                        if (domain_switch) {
-                               cpu_current_domain[cpu] = s->eip;
+                               per_cpu(current_domain, cpu) = s->eip;
                                add_domain_switch(s->eip);
                                domain_switch = 0;
-                       } else if (!is_ibs_sample) {
-                               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);
-                                       }
+                       } else if (is_ibs_sample)
+                               ;
+                       else if (per_cpu(current_domain, cpu) !=
+                                COORDINATOR_DOMAIN) {
+                               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);
                                }
                        }
                }
@@ -656,10 +671,11 @@
        }
        release_mm(mm);
 
+#ifdef CONFIG_XEN
        /* We reset domain to COORDINATOR at each CPU switch */
-       if (cpu_current_domain[cpu] != COORDINATOR_DOMAIN) {
+       if (per_cpu(current_domain, cpu) != COORDINATOR_DOMAIN)
                add_domain_switch(COORDINATOR_DOMAIN);
-       }
+#endif
 
        mark_done(cpu);
 
diff -r dc034d0ccdd8 -r 98c00677dacb drivers/oprofile/cpu_buffer.c
--- a/drivers/oprofile/cpu_buffer.c     Wed Feb 15 12:09:02 2012 +0100
+++ b/drivers/oprofile/cpu_buffer.c     Thu Feb 16 08:52:06 2012 +0100
@@ -38,7 +38,11 @@
 #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)
 {
@@ -202,8 +206,10 @@
                add_code(cpu_buf, (unsigned long)task);
        }
 
+#ifdef CONFIG_XEN
        if (pc == IBS_FETCH_CODE || pc == IBS_OP_CODE)
                add_code(cpu_buf, cpu_mode);
+#endif
 
        add_sample(cpu_buf, pc, event);
        return 1;
@@ -284,6 +290,7 @@
        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()];
@@ -302,6 +309,7 @@
 
        return 1;
 }
+#endif
 
 /*
  * This serves to avoid cpu buffer overflow, and makes sure
diff -r dc034d0ccdd8 -r 98c00677dacb drivers/oprofile/oprof.c
--- a/drivers/oprofile/oprof.c  Wed Feb 15 12:09:02 2012 +0100
+++ b/drivers/oprofile/oprof.c  Thu Feb 16 08:52:06 2012 +0100
@@ -37,6 +37,7 @@
  */
 static int timer = 0;
 
+#ifdef CONFIG_XEN
 int oprofile_set_active(int active_domains[], unsigned int adomains)
 {
        int err;
@@ -62,6 +63,7 @@
        mutex_unlock(&start_mutex);
        return err;
 }
+#endif
 
 int oprofile_setup(void)
 {
diff -r dc034d0ccdd8 -r 98c00677dacb drivers/oprofile/oprofile_files.c
--- a/drivers/oprofile/oprofile_files.c Wed Feb 15 12:09:02 2012 +0100
+++ b/drivers/oprofile/oprofile_files.c Thu Feb 16 08:52:06 2012 +0100
@@ -21,7 +21,11 @@
 #include "oprof.h"
 
 unsigned long fs_buffer_size = 131072;
-unsigned long fs_cpu_buffer_size = 131072;
+#ifndef CONFIG_XEN
+unsigned long fs_cpu_buffer_size = 8192;
+#else
+unsigned long fs_cpu_buffer_size = 32768;
+#endif
 unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
 
 static ssize_t depth_read(struct file * file, char __user * buf, size_t count, 
loff_t * offset)
@@ -124,6 +128,8 @@
        .write          = dump_write,
 };
 
+#ifdef CONFIG_XEN
+
 #define TMPBUFSIZE 512
 
 struct domain_data {
@@ -228,8 +234,8 @@
 
 static int adomain_open(struct inode *inode, struct file *filp)
 {
-    filp->private_data = &active_domains;
-    return 0;
+       filp->private_data = &active_domains;
+       return 0;
 }
 
 static const struct file_operations active_domain_ops = {
@@ -242,8 +248,8 @@
 
 static int pdomain_open(struct inode *inode, struct file *filp)
 {
-    filp->private_data = &passive_domains;
-    return 0;
+       filp->private_data = &passive_domains;
+       return 0;
 }
 
 static const struct file_operations passive_domain_ops = {
@@ -252,12 +258,16 @@
        .write          = domain_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);
diff -r dc034d0ccdd8 -r 98c00677dacb include/linux/oprofile.h
--- a/include/linux/oprofile.h  Wed Feb 15 12:09:02 2012 +0100
+++ b/include/linux/oprofile.h  Thu Feb 16 08:52:06 2012 +0100
@@ -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 @@
        /* 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);
-       
+       /* 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. */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.