Commit 6f7bd76f authored by Rakib Mullick's avatar Rakib Mullick Committed by Linus Torvalds

kernel/profile.c: remove some duplicate code from profile_hits()

profile_hits() has a common check for prof_on and prof_buffer regardless
of SMP or !SMP.  So, remove some duplicate code by splitting profile_hits
into two.

[akpm@linux-foundation.org: make do_profile_hits static]
Signed-off-by: default avatarRakib Mullick <rakib.mullick@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d98808a2
...@@ -303,14 +303,12 @@ static void profile_discard_flip_buffers(void) ...@@ -303,14 +303,12 @@ static void profile_discard_flip_buffers(void)
mutex_unlock(&profile_flip_mutex); mutex_unlock(&profile_flip_mutex);
} }
void profile_hits(int type, void *__pc, unsigned int nr_hits) static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
{ {
unsigned long primary, secondary, flags, pc = (unsigned long)__pc; unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
int i, j, cpu; int i, j, cpu;
struct profile_hit *hits; struct profile_hit *hits;
if (prof_on != type || !prof_buffer)
return;
pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1); pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT; i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT; secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
...@@ -417,16 +415,20 @@ static int __cpuinit profile_cpu_callback(struct notifier_block *info, ...@@ -417,16 +415,20 @@ static int __cpuinit profile_cpu_callback(struct notifier_block *info,
#define profile_discard_flip_buffers() do { } while (0) #define profile_discard_flip_buffers() do { } while (0)
#define profile_cpu_callback NULL #define profile_cpu_callback NULL
void profile_hits(int type, void *__pc, unsigned int nr_hits) static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
{ {
unsigned long pc; unsigned long pc;
if (prof_on != type || !prof_buffer)
return;
pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift; pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]); atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
} }
#endif /* !CONFIG_SMP */ #endif /* !CONFIG_SMP */
void profile_hits(int type, void *__pc, unsigned int nr_hits)
{
if (prof_on != type || !prof_buffer)
return;
do_profile_hits(type, __pc, nr_hits);
}
EXPORT_SYMBOL_GPL(profile_hits); EXPORT_SYMBOL_GPL(profile_hits);
void profile_tick(int type) void profile_tick(int type)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment