tech-kern archive

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

dubious ADDUPROF macro definition



Hi,

The ADDUPROF macro definition looks dubious to me. In then following
code (copied from sys/sys/resourcevar.h) the argument `p' is unused,
and this macro was converted to use a LWP instead ...

/* add user profiling from AST XXXSMP */
#define ADDUPROF(p)                                                     \
        do {                                                            \
                struct proc *_p = l->l_proc;                            \
                addupc_task(l,                                          \
                    (_p)->p_stats->p_prof.pr_addr,                      \
                    (_p)->p_stats->p_prof.pr_ticks);                    \
                (_p)->p_stats->p_prof.pr_ticks = 0;                     \
        } while (/* CONSTCOND */ 0)

How about the attached patches, which fix the macro definition and
convert some remaining archs (arm, luna68k, powerpc, sh3) still using
a proc argument.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.
Index: sys/sys/resourcevar.h
===================================================================
RCS file: /cvsroot/src/sys/sys/resourcevar.h,v
retrieving revision 1.46
diff -u -p -r1.46 resourcevar.h
--- sys/sys/resourcevar.h       11 Oct 2008 13:40:58 -0000      1.46
+++ sys/sys/resourcevar.h       18 Dec 2008 01:05:33 -0000
@@ -83,13 +83,13 @@ struct plimit {
 };
 
 /* add user profiling from AST XXXSMP */
-#define        ADDUPROF(p)                                                     
\
+#define        ADDUPROF(l)                                                     
\
        do {                                                            \
-               struct proc *_p = l->l_proc;                            \
-               addupc_task(l,                                          \
-                   (_p)->p_stats->p_prof.pr_addr,                      \
-                   (_p)->p_stats->p_prof.pr_ticks);                    \
-               (_p)->p_stats->p_prof.pr_ticks = 0;                     \
+               struct proc *_p = (l)->l_proc;                          \
+               addupc_task((l),                                        \
+                   _p->p_stats->p_prof.pr_addr,                        \
+                   _p->p_stats->p_prof.pr_ticks);                      \
+               _p->p_stats->p_prof.pr_ticks = 0;                       \
        } while (/* CONSTCOND */ 0)
 
 #ifdef _KERNEL
Index: sys/arch/arm/arm/ast.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm/ast.c,v
retrieving revision 1.16
diff -u -p -r1.16 ast.c
--- sys/arch/arm/arm/ast.c      19 Nov 2008 06:29:48 -0000      1.16
+++ sys/arch/arm/arm/ast.c      18 Dec 2008 01:06:56 -0000
@@ -123,7 +123,7 @@ ast(struct trapframe *tf)
 
        if (l->l_pflag & LP_OWEUPC) {
                l->l_pflag &= ~LP_OWEUPC;
-               ADDUPROF(p);
+               ADDUPROF(l);
        }
 
        /* Allow a forced task switch. */
Index: sys/arch/luna68k/luna68k/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/luna68k/luna68k/trap.c,v
retrieving revision 1.53
diff -u -p -r1.53 trap.c
--- sys/arch/luna68k/luna68k/trap.c     15 Oct 2008 06:51:18 -0000      1.53
+++ sys/arch/luna68k/luna68k/trap.c     18 Dec 2008 01:06:57 -0000
@@ -511,7 +511,7 @@ trap(fp, type, code, v)
                spl0();
                if (l->l_pflag & LP_OWEUPC) {
                        l->l_pflag &= ~LP_OWEUPC;
-                       ADDUPROF(p);
+                       ADDUPROF(l);
                }
                if (curcpu()->ci_want_resched)
                        preempt();
Index: sys/arch/powerpc/powerpc/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/trap.c,v
retrieving revision 1.128
diff -u -p -r1.128 trap.c
--- sys/arch/powerpc/powerpc/trap.c     25 Oct 2008 09:10:07 -0000      1.128
+++ sys/arch/powerpc/powerpc/trap.c     18 Dec 2008 01:06:58 -0000
@@ -343,7 +343,7 @@ trap(struct trapframe *frame)
                uvmexp.softs++;
                if (l->l_pflag & LP_OWEUPC) {
                        l->l_flag &= ~LP_OWEUPC;
-                       ADDUPROF(p);
+                       ADDUPROF(l);
                }
                /* Check whether we are being preempted. */
                if (ci->ci_want_resched)
Index: sys/arch/sh3/sh3/exception.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sh3/sh3/exception.c,v
retrieving revision 1.52
diff -u -p -r1.52 exception.c
--- sys/arch/sh3/sh3/exception.c        21 Oct 2008 04:16:59 -0000      1.52
+++ sys/arch/sh3/sh3/exception.c        18 Dec 2008 01:06:58 -0000
@@ -459,7 +459,7 @@ ast(struct lwp *l, struct trapframe *tf)
 
                if (l->l_pflag & LP_OWEUPC) {
                        l->l_pflag &= ~LP_OWEUPC;
-                       ADDUPROF(p);
+                       ADDUPROF(l);
                }
 
                if (l->l_cpu->ci_want_resched) {


Home | Main Index | Thread Index | Old Index