Skip to content

Commit 6f7bd76

Browse files
rmullicktorvalds
authored andcommitted
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: Rakib Mullick <rakib.mullick@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d98808a commit 6f7bd76

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎kernel/profile.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,12 @@ static void profile_discard_flip_buffers(void)
303303
mutex_unlock(&profile_flip_mutex);
304304
}
305305

306-
void profile_hits(int type, void *__pc, unsigned int nr_hits)
306+
static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
307307
{
308308
unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
309309
int i, j, cpu;
310310
struct profile_hit *hits;
311311

312-
if (prof_on != type || !prof_buffer)
313-
return;
314312
pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
315313
i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
316314
secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
@@ -417,16 +415,20 @@ static int __cpuinit profile_cpu_callback(struct notifier_block *info,
417415
#define profile_discard_flip_buffers() do { } while (0)
418416
#define profile_cpu_callback NULL
419417

420-
void profile_hits(int type, void *__pc, unsigned int nr_hits)
418+
static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
421419
{
422420
unsigned long pc;
423-
424-
if (prof_on != type || !prof_buffer)
425-
return;
426421
pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
427422
atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
428423
}
429424
#endif /* !CONFIG_SMP */
425+
426+
void profile_hits(int type, void *__pc, unsigned int nr_hits)
427+
{
428+
if (prof_on != type || !prof_buffer)
429+
return;
430+
do_profile_hits(type, __pc, nr_hits);
431+
}
430432
EXPORT_SYMBOL_GPL(profile_hits);
431433

432434
void profile_tick(int type)

0 commit comments

Comments
 (0)