oprofile: don't pass around redundant, easily derived arguments
authorJan Beulich <jbeulich@suse.com>
Thu, 8 Mar 2012 16:02:57 +0000 (17:02 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 8 Mar 2012 16:02:57 +0000 (17:02 +0100)
Passing both a struct vcpu pointer and the corresponding struct domain
one is simply pointless, especially when intermediate functions just
forward it without themselves making use of the already obtained value.

Also constify a few function parameters.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen/arch/ia64/xen/oprofile/xenoprof.c
xen/arch/x86/oprofile/backtrace.c
xen/arch/x86/oprofile/xenoprof.c
xen/common/xenoprof.c
xen/include/asm-ia64/xenoprof.h
xen/include/asm-x86/xenoprof.h
xen/include/xen/xenoprof.h

index fdabc28ef15965e1cdeebc42b6d8350430c0010f..8635c7e676175af53e809c1f8b874e845e1758bb 100644 (file)
@@ -27,7 +27,7 @@
 #include <asm/vmx.h>    /* for vmx_user_mode() */
 
 int
-xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs)
+xenoprofile_get_mode(const struct vcpu *v, const struct cpu_user_regs *regs)
 {
     int mode;
 
index dcb38230f6c8b59341c0207015d36cff45188a23..33fd14274f37d9234831869f4e97d87372b3b93e 100644 (file)
@@ -32,10 +32,10 @@ DEFINE_COMPAT_HANDLE(frame_head32_t);
 #endif
 
 static struct frame_head *
-dump_hypervisor_backtrace(struct domain *d, struct vcpu *vcpu, 
-                         struct frame_head * head, int mode)
+dump_hypervisor_backtrace(struct vcpu *vcpu, const struct frame_head *head,
+                          int mode)
 {
-    if (!xenoprof_add_trace(d, vcpu, head->ret, mode))
+    if (!xenoprof_add_trace(vcpu, head->ret, mode))
         return 0;
     
     /* frame pointers should strictly progress back up the stack
@@ -57,8 +57,8 @@ static inline int is_32bit_vcpu(struct vcpu *vcpu)
 #endif
 
 static struct frame_head *
-dump_guest_backtrace(struct domain *d, struct vcpu *vcpu, 
-                    const struct frame_head *head, int mode)
+dump_guest_backtrace(struct vcpu *vcpu, const struct frame_head *head,
+                     int mode)
 {
     frame_head_t bufhead;
 
@@ -90,7 +90,7 @@ dump_guest_backtrace(struct domain *d, struct vcpu *vcpu,
             return 0;
     }
     
-    if (!xenoprof_add_trace(d, vcpu, bufhead.ret, mode))
+    if (!xenoprof_add_trace(vcpu, bufhead.ret, mode))
         return 0;
     
     /* frame pointers should strictly progress back up the stack
@@ -132,8 +132,8 @@ dump_guest_backtrace(struct domain *d, struct vcpu *vcpu,
  * in the kernel mode.
  */
 #if defined(CONFIG_FRAME_POINTER)
-static int valid_hypervisor_stack(struct frame_head * head, 
-                                 struct cpu_user_regs * regs)
+static int valid_hypervisor_stack(const struct frame_head *head,
+                                 const struct cpu_user_regs *regs)
 {
     unsigned long headaddr = (unsigned long)head;
 #ifdef CONFIG_X86_64
@@ -147,27 +147,24 @@ static int valid_hypervisor_stack(struct frame_head * head,
 }
 #else
 /* without fp, it's just junk */
-static int valid_hypervisor_stack(struct frame_head * head, 
-                                 struct cpu_user_regs * regs)
+static int valid_hypervisor_stack(const struct frame_head *head,
+                                 const struct cpu_user_regs *regs)
 {
     return 0;
 }
 #endif
 
-void xenoprof_backtrace(struct domain *d, struct vcpu *vcpu, 
-                       struct cpu_user_regs * const regs,
+void xenoprof_backtrace(struct vcpu *vcpu, const struct cpu_user_regs *regs,
                        unsigned long depth, int mode)
 {
-    struct frame_head *head;
-
-    head = (struct frame_head *)regs->ebp;
+    const struct frame_head *head = (void *)regs->ebp;
 
     if (mode > 1) {
         while (depth-- && valid_hypervisor_stack(head, regs))
-            head = dump_hypervisor_backtrace(d, vcpu, head, mode);
+            head = dump_hypervisor_backtrace(vcpu, head, mode);
         return;
     }
 
     while (depth-- && head)
-        head = dump_guest_backtrace(d, vcpu, head, mode);
+        head = dump_guest_backtrace(vcpu, head, mode);
 }
index 0c1c7ab031b7e689cec3bc0bd9a881e3739a59ef..71f00ef7daeef1cce4a160c3c43109f3337f771f 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <xen/guest_access.h>
 #include <xen/sched.h>
+#include <xen/xenoprof.h>
 #include <public/xenoprof.h>
 #ifdef CONFIG_COMPAT
 #include <compat/xenoprof.h>
@@ -77,7 +78,8 @@ int compat_oprof_arch_counter(XEN_GUEST_HANDLE(void) arg)
 }
 #endif
 
-int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs)
+int xenoprofile_get_mode(const struct vcpu *v,
+                         const struct cpu_user_regs *regs)
 {
     if ( !guest_mode(regs) )
         return 2;
index a99d3432bb382a4f2f6fca9a7af6f9370569477c..e571fea82995c89f73eb7c054ff7d14aee6cdc6c 100644 (file)
@@ -511,24 +511,23 @@ static int xenoprof_add_sample(struct domain *d, xenoprof_buf_t *buf,
     return 1;
 }
 
-int xenoprof_add_trace(struct domain *d, struct vcpu *vcpu,
-                       uint64_t eip, int mode)
+int xenoprof_add_trace(struct vcpu *vcpu, uint64_t pc, int mode)
 {
+    struct domain *d = vcpu->domain;
     xenoprof_buf_t *buf = d->xenoprof->vcpu[vcpu->vcpu_id].buffer;
 
     /* Do not accidentally write an escape code due to a broken frame. */
-    if ( eip == XENOPROF_ESCAPE_CODE )
+    if ( pc == XENOPROF_ESCAPE_CODE )
     {
         invalid_buffer_samples++;
         return 0;
     }
 
-    return xenoprof_add_sample(d, buf, eip, mode, 0);
+    return xenoprof_add_sample(d, buf, pc, mode, 0);
 }
 
-void xenoprof_log_event(struct vcpu *vcpu, 
-                        struct cpu_user_regs * regs, uint64_t eip, 
-                        int mode, int event)
+void xenoprof_log_event(struct vcpu *vcpu, const struct cpu_user_regs *regs,
+                        uint64_t pc, int mode, int event)
 {
     struct domain *d = vcpu->domain;
     struct xenoprof_vcpu *v;
@@ -565,7 +564,7 @@ void xenoprof_log_event(struct vcpu *vcpu,
         }
     }
 
-    if ( xenoprof_add_sample(d, buf, eip, mode, event) )
+    if ( xenoprof_add_sample(d, buf, pc, mode, event) )
     {
         if ( is_active(vcpu->domain) )
             active_samples++;
@@ -581,7 +580,7 @@ void xenoprof_log_event(struct vcpu *vcpu,
     }
 
     if ( backtrace_depth > 0 )
-        xenoprof_backtrace(d, vcpu, regs, backtrace_depth, mode);
+        xenoprof_backtrace(vcpu, regs, backtrace_depth, mode);
 }
 
 
index 3fc166410dc4af3edddea3589d76528a0a37d934..daf2ffa9e3c1254fa4898e69e40f8650c5770e2c 100644 (file)
@@ -45,14 +45,13 @@ static inline int xenoprof_arch_ibs_counter(XEN_GUEST_HANDLE(void) arg)
 
 struct vcpu;
 struct cpu_user_regs;
-int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs);
+int xenoprofile_get_mode(const struct vcpu *, const struct cpu_user_regs *);
 static inline int xenoprof_backtrace_supported(void)
 {
     return 0;
 }
-static inline void xenoprof_backtrace(
-    struct domain *d, struct vcpu *vcpu, 
-    struct pt_regs *const regs, unsigned long depth, int mode)
+static inline void xenoprof_backtrace(struct vcpu *vcpu,
+    const struct pt_regs *regs, unsigned long depth, int mode)
 {
     /* To be implemented */
     return;
index f98b76e3781b469e01f7a8cbf4659cd3ffc1aaaa..c03f8c8bf0db2fceb8e225aa49d9bb0b059b9725 100644 (file)
@@ -56,16 +56,15 @@ static inline void ibs_init(void) {}
 #define ibs_caps 0
 #endif
 
-int xenoprofile_get_mode(struct vcpu *v, struct cpu_user_regs * const regs);
+int xenoprofile_get_mode(const struct vcpu *, const struct cpu_user_regs *);
 
 static inline int xenoprof_backtrace_supported(void)
 {
     return 1;
 }
 
-void xenoprof_backtrace(
-    struct domain *d, struct vcpu *vcpu, 
-    struct cpu_user_regs *const regs, unsigned long depth, int mode);
+void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *,
+                        unsigned long depth, int mode);
 
 #define xenoprof_shared_gmfn(d, gmaddr, maddr)                      \
     do {                                                            \
index e34ad20ab3ed5311fa930fb05d0e600b248ace90..7804e69329c2e017a43689c2be381c43bcc475b3 100644 (file)
@@ -68,8 +68,7 @@ int is_active(struct domain *d);
 int is_passive(struct domain *d);
 void free_xenoprof_pages(struct domain *d);
 
-int xenoprof_add_trace(struct domain *d, struct vcpu *v, 
-                       uint64_t eip, int mode);
+int xenoprof_add_trace(struct vcpu *, uint64_t pc, int mode);
 
 #define PMU_OWNER_NONE          0
 #define PMU_OWNER_XENOPROF      1
@@ -77,8 +76,7 @@ int xenoprof_add_trace(struct domain *d, struct vcpu *v,
 int acquire_pmu_ownship(int pmu_ownership);
 void release_pmu_ownship(int pmu_ownership);
 
-void xenoprof_log_event(struct vcpu *vcpu,
-                        struct cpu_user_regs * regs, uint64_t eip,
-                        int mode, int event);
+void xenoprof_log_event(struct vcpu *, const struct cpu_user_regs *,
+                        uint64_t pc, int mode, int event);
 
 #endif  /* __XEN__XENOPROF_H__ */