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

[Xen-devel] [PATCH] oprofile: don't pass around redundant, easily derived arguments


  • To: "xen-devel" <xen-devel@xxxxxxxxxxxxx>
  • From: "Jan Beulich" <JBeulich@xxxxxxxx>
  • Date: Tue, 06 Mar 2012 15:47:42 +0000
  • Delivery-date: Tue, 06 Mar 2012 15:48:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

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@xxxxxxxx>

--- a/xen/arch/ia64/xen/oprofile/xenoprof.c
+++ b/xen/arch/ia64/xen/oprofile/xenoprof.c
@@ -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;
 
--- a/xen/arch/x86/oprofile/backtrace.c
+++ b/xen/arch/x86/oprofile/backtrace.c
@@ -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 v
 #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, s
             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, s
  * 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
 }
 #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);
 }
--- a/xen/arch/x86/oprofile/xenoprof.c
+++ b/xen/arch/x86/oprofile/xenoprof.c
@@ -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_
 }
 #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;
--- a/xen/common/xenoprof.c
+++ b/xen/common/xenoprof.c
@@ -511,24 +511,23 @@ static int xenoprof_add_sample(struct do
     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 *vcp
         }
     }
 
-    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 *vcp
     }
 
     if ( backtrace_depth > 0 )
-        xenoprof_backtrace(d, vcpu, regs, backtrace_depth, mode);
+        xenoprof_backtrace(vcpu, regs, backtrace_depth, mode);
 }
 
 
--- a/xen/include/asm-ia64/xenoprof.h
+++ b/xen/include/asm-ia64/xenoprof.h
@@ -45,14 +45,13 @@ static inline int xenoprof_arch_ibs_coun
 
 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;
--- a/xen/include/asm-x86/xenoprof.h
+++ b/xen/include/asm-x86/xenoprof.h
@@ -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 {                                                            \
--- a/xen/include/xen/xenoprof.h
+++ b/xen/include/xen/xenoprof.h
@@ -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,
 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__ */


Attachment: oprof-add-trace-no-domain.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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