Skip to content

Commit b03f648

Browse files
AdrianBunktorvalds
authored andcommitted
build kernel/profile.o only when requested
Build kernel/profile.o only if CONFIG_PROFILING is enabled. This makes CONFIG_PROFILING=n kernels smaller. As a bonus, some profile_tick() calls and one branch from schedule() are now eliminated with CONFIG_PROFILING=n (but I doubt these are measurable effects). This patch changes the effects of CONFIG_PROFILING=n, but I don't think having more than two choices would be the better choice. This patch also adds the name of the first parameter to the prototypes of profile_{hits,tick}() since I anyway had to add them for the dummy functions. Signed-off-by: Adrian Bunk <bunk@kernel.org> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 696adfe commit b03f648

3 files changed

Lines changed: 41 additions & 22 deletions

File tree

‎include/linux/profile.h‎

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#include <asm/errno.h>
1010

11-
extern int prof_on __read_mostly;
12-
1311
#define CPU_PROFILING 1
1412
#define SCHED_PROFILING 2
1513
#define SLEEP_PROFILING 3
@@ -19,14 +17,29 @@ struct proc_dir_entry;
1917
struct pt_regs;
2018
struct notifier_block;
2119

20+
#if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
21+
void create_prof_cpu_mask(struct proc_dir_entry *);
22+
#else
23+
#define create_prof_cpu_mask(x) do { (void)(x); } while (0)
24+
#endif
25+
26+
enum profile_type {
27+
PROFILE_TASK_EXIT,
28+
PROFILE_MUNMAP
29+
};
30+
31+
#ifdef CONFIG_PROFILING
32+
33+
extern int prof_on __read_mostly;
34+
2235
/* init basic kernel profiler */
2336
void __init profile_init(void);
24-
void profile_tick(int);
37+
void profile_tick(int type);
2538

2639
/*
2740
* Add multiple profiler hits to a given address:
2841
*/
29-
void profile_hits(int, void *ip, unsigned int nr_hits);
42+
void profile_hits(int type, void *ip, unsigned int nr_hits);
3043

3144
/*
3245
* Single profiler hit:
@@ -40,19 +53,6 @@ static inline void profile_hit(int type, void *ip)
4053
profile_hits(type, ip, 1);
4154
}
4255

43-
#ifdef CONFIG_PROC_FS
44-
void create_prof_cpu_mask(struct proc_dir_entry *);
45-
#else
46-
#define create_prof_cpu_mask(x) do { (void)(x); } while (0)
47-
#endif
48-
49-
enum profile_type {
50-
PROFILE_TASK_EXIT,
51-
PROFILE_MUNMAP
52-
};
53-
54-
#ifdef CONFIG_PROFILING
55-
5656
struct task_struct;
5757
struct mm_struct;
5858

@@ -80,6 +80,28 @@ struct pt_regs;
8080

8181
#else
8282

83+
#define prof_on 0
84+
85+
static inline void profile_init(void)
86+
{
87+
return;
88+
}
89+
90+
static inline void profile_tick(int type)
91+
{
92+
return;
93+
}
94+
95+
static inline void profile_hits(int type, void *ip, unsigned int nr_hits)
96+
{
97+
return;
98+
}
99+
100+
static inline void profile_hit(int type, void *ip)
101+
{
102+
return;
103+
}
104+
83105
static inline int task_handoff_register(struct notifier_block * n)
84106
{
85107
return -ENOSYS;

‎kernel/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Makefile for the linux kernel.
33
#
44

5-
obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
5+
obj-y = sched.o fork.o exec_domain.o panic.o printk.o \
66
cpu.o exit.o itimer.o time.o softirq.o resource.o \
77
sysctl.o capability.o ptrace.o timer.o user.o \
88
signal.o sys.o kmod.o workqueue.o pid.o \
@@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
2424
CFLAGS_REMOVE_sched.o = -mno-spe -pg
2525
endif
2626

27+
obj-$(CONFIG_PROFILING) += profile.o
2728
obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
2829
obj-$(CONFIG_STACKTRACE) += stacktrace.o
2930
obj-y += time/

‎kernel/profile.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ void __init profile_init(void)
112112

113113
/* Profile event notifications */
114114

115-
#ifdef CONFIG_PROFILING
116-
117115
static BLOCKING_NOTIFIER_HEAD(task_exit_notifier);
118116
static ATOMIC_NOTIFIER_HEAD(task_free_notifier);
119117
static BLOCKING_NOTIFIER_HEAD(munmap_notifier);
@@ -203,8 +201,6 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *))
203201
}
204202
EXPORT_SYMBOL_GPL(unregister_timer_hook);
205203

206-
#endif /* CONFIG_PROFILING */
207-
208204

209205
#ifdef CONFIG_SMP
210206
/*

0 commit comments

Comments
 (0)