From: Andi Kleen <ak@muc.de>

Check first before calling profile_pc() and doing other complicated checks
if profiling is enabled.  This saves a few cycles in the profile tick and
protects the average user against potential bugs in profile_pc.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/kernel/profile.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff -puN kernel/profile.c~optimize-profile-path-slightly kernel/profile.c
--- 25/kernel/profile.c~optimize-profile-path-slightly	Tue Oct  5 16:15:07 2004
+++ 25-akpm/kernel/profile.c	Tue Oct  5 16:15:07 2004
@@ -381,12 +381,10 @@ static int __devinit profile_cpu_callbac
 #define profile_flip_buffers()		do { } while (0)
 #define profile_discard_flip_buffers()	do { } while (0)
 
-void profile_hit(int type, void *__pc)
+inline void profile_hit(int type, void *__pc)
 {
 	unsigned long pc;
 
-	if (prof_on != type || !prof_buffer)
-		return;
 	pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
 	atomic_inc(&prof_buffer[min(pc, prof_len - 1)]);
 }
@@ -396,6 +394,8 @@ void profile_tick(int type, struct pt_re
 {
 	if (type == CPU_PROFILING)
 		profile_hook(regs);
+	if (prof_on != type || !prof_buffer)
+		return;
 	if (!user_mode(regs) && cpu_isset(smp_processor_id(), prof_cpu_mask))
 		profile_hit(type, (void *)profile_pc(regs));
 }
_