public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC: 2.6 patch] build kernel/profile.o only when requested
@ 2008-05-19 21:53 Adrian Bunk
  2008-05-20  9:01 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Adrian Bunk @ 2008-05-19 21:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton

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>

---

 include/linux/profile.h |   56 +++++++++++++++++++++++++++-------------
 kernel/Makefile         |    3 +-
 kernel/profile.c        |    4 --
 3 files changed, 41 insertions(+), 22 deletions(-)

182e01e59fe8cb1a93e1fb2589007ab938312626 diff --git a/include/linux/profile.h b/include/linux/profile.h
index 05c1cc7..4081fa3 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -8,8 +8,6 @@
 
 #include <asm/errno.h>
 
-extern int prof_on __read_mostly;
-
 #define CPU_PROFILING	1
 #define SCHED_PROFILING	2
 #define SLEEP_PROFILING	3
@@ -19,14 +17,29 @@ struct proc_dir_entry;
 struct pt_regs;
 struct notifier_block;
 
+#if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
+void create_prof_cpu_mask(struct proc_dir_entry *);
+#else
+#define create_prof_cpu_mask(x)			do { (void)(x); } while (0)
+#endif
+
+enum profile_type {
+	PROFILE_TASK_EXIT,
+	PROFILE_MUNMAP
+};
+
+#ifdef CONFIG_PROFILING
+
+extern int prof_on __read_mostly;
+
 /* init basic kernel profiler */
 void __init profile_init(void);
-void profile_tick(int);
+void profile_tick(int type);
 
 /*
  * Add multiple profiler hits to a given address:
  */
-void profile_hits(int, void *ip, unsigned int nr_hits);
+void profile_hits(int type, void *ip, unsigned int nr_hits);
 
 /*
  * Single profiler hit:
@@ -40,19 +53,6 @@ static inline void profile_hit(int type, void *ip)
 		profile_hits(type, ip, 1);
 }
 
-#ifdef CONFIG_PROC_FS
-void create_prof_cpu_mask(struct proc_dir_entry *);
-#else
-#define create_prof_cpu_mask(x)			do { (void)(x); } while (0)
-#endif
-
-enum profile_type {
-	PROFILE_TASK_EXIT,
-	PROFILE_MUNMAP
-};
-
-#ifdef CONFIG_PROFILING
-
 struct task_struct;
 struct mm_struct;
 
@@ -80,6 +80,28 @@ struct pt_regs;
 
 #else
 
+#define prof_on 0
+
+static inline void profile_init(void)
+{
+	return;
+}
+
+static inline void profile_tick(int type)
+{
+	return;
+}
+
+static inline void profile_hits(int type, void *ip, unsigned int nr_hits)
+{
+	return;
+}
+
+static inline void profile_hit(int type, void *ip)
+{
+	return;
+}
+
 static inline int task_handoff_register(struct notifier_block * n)
 {
 	return -ENOSYS;
diff --git a/kernel/Makefile b/kernel/Makefile
index 1c9938a..05ea52b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
+obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
@@ -11,6 +11,7 @@ obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
 	    hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
 	    notifier.o ksysfs.o pm_qos_params.o sched_clock.o
 
+obj-$(CONFIG_PROFILING) += profile.o
 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
 obj-$(CONFIG_STACKTRACE) += stacktrace.o
 obj-y += time/
diff --git a/kernel/profile.c b/kernel/profile.c
index ae7ead8..4f53f09 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -112,8 +112,6 @@ void __init profile_init(void)
 
 /* Profile event notifications */
 
-#ifdef CONFIG_PROFILING
-
 static BLOCKING_NOTIFIER_HEAD(task_exit_notifier);
 static ATOMIC_NOTIFIER_HEAD(task_free_notifier);
 static BLOCKING_NOTIFIER_HEAD(munmap_notifier);
@@ -203,8 +201,6 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *))
 }
 EXPORT_SYMBOL_GPL(unregister_timer_hook);
 
-#endif /* CONFIG_PROFILING */
-
 
 #ifdef CONFIG_SMP
 /*


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC: 2.6 patch] build kernel/profile.o only when requested
  2008-05-19 21:53 [RFC: 2.6 patch] build kernel/profile.o only when requested Adrian Bunk
@ 2008-05-20  9:01 ` Andrew Morton
  2008-05-20 10:21   ` Adrian Bunk
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2008-05-20  9:01 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-kernel

On Tue, 20 May 2008 00:53:06 +0300 Adrian Bunk <bunk@kernel.org> wrote:

> 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.
> 

Little nits:

> index 05c1cc7..4081fa3 100644
> --- a/include/linux/profile.h
> +++ b/include/linux/profile.h
> @@ -8,8 +8,6 @@
>  
>  #include <asm/errno.h>
>  
> -extern int prof_on __read_mostly;
> -
>  #define CPU_PROFILING	1
>  #define SCHED_PROFILING	2
>  #define SLEEP_PROFILING	3
> @@ -19,14 +17,29 @@ struct proc_dir_entry;
>  struct pt_regs;
>  struct notifier_block;
>  
> +#if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
> +void create_prof_cpu_mask(struct proc_dir_entry *);

This omits the argument's name, whereas elsewhere you have taken care
to introduce the name where it was missing.

> +#else
> +#define create_prof_cpu_mask(x)			do { (void)(x); } while (0)

I think this could be a static inline, which is neater.

I wonder why create_prof_cpu_mask() is called only by s390.  I suppose
I should I should get the historical-git tree onto this machine and
find out.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC: 2.6 patch] build kernel/profile.o only when requested
  2008-05-20  9:01 ` Andrew Morton
@ 2008-05-20 10:21   ` Adrian Bunk
  2008-05-20 10:34     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Adrian Bunk @ 2008-05-20 10:21 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On Tue, May 20, 2008 at 02:01:21AM -0700, Andrew Morton wrote:
> On Tue, 20 May 2008 00:53:06 +0300 Adrian Bunk <bunk@kernel.org> wrote:
> 
> > 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.
> > 
> 
> Little nits:
> 
> > index 05c1cc7..4081fa3 100644
> > --- a/include/linux/profile.h
> > +++ b/include/linux/profile.h
> > @@ -8,8 +8,6 @@
> >  
> >  #include <asm/errno.h>
> >  
> > -extern int prof_on __read_mostly;
> > -
> >  #define CPU_PROFILING	1
> >  #define SCHED_PROFILING	2
> >  #define SLEEP_PROFILING	3
> > @@ -19,14 +17,29 @@ struct proc_dir_entry;
> >  struct pt_regs;
> >  struct notifier_block;
> >  
> > +#if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
> > +void create_prof_cpu_mask(struct proc_dir_entry *);
> 
> This omits the argument's name, whereas elsewhere you have taken care
> to introduce the name where it was missing.
> 
> > +#else
> > +#define create_prof_cpu_mask(x)			do { (void)(x); } while (0)
> 
> I think this could be a static inline, which is neater.
>...

In these two cases I only moved code.

And I actually moved the other code and git just decided to move the 
code that stayed instead since it creates less changed lines...

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC: 2.6 patch] build kernel/profile.o only when requested
  2008-05-20 10:21   ` Adrian Bunk
@ 2008-05-20 10:34     ` Andrew Morton
  2008-05-20 10:42       ` Adrian Bunk
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2008-05-20 10:34 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-kernel

On Tue, 20 May 2008 13:21:50 +0300 Adrian Bunk <bunk@kernel.org> wrote:

> On Tue, May 20, 2008 at 02:01:21AM -0700, Andrew Morton wrote:
> > On Tue, 20 May 2008 00:53:06 +0300 Adrian Bunk <bunk@kernel.org> wrote:
> > 
> > > 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.
> > > 
> > 
> > Little nits:
> > 
> > > index 05c1cc7..4081fa3 100644
> > > --- a/include/linux/profile.h
> > > +++ b/include/linux/profile.h
> > > @@ -8,8 +8,6 @@
> > >  
> > >  #include <asm/errno.h>
> > >  
> > > -extern int prof_on __read_mostly;
> > > -
> > >  #define CPU_PROFILING	1
> > >  #define SCHED_PROFILING	2
> > >  #define SLEEP_PROFILING	3
> > > @@ -19,14 +17,29 @@ struct proc_dir_entry;
> > >  struct pt_regs;
> > >  struct notifier_block;
> > >  
> > > +#if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
> > > +void create_prof_cpu_mask(struct proc_dir_entry *);
> > 
> > This omits the argument's name, whereas elsewhere you have taken care
> > to introduce the name where it was missing.
> > 
> > > +#else
> > > +#define create_prof_cpu_mask(x)			do { (void)(x); } while (0)
> > 
> > I think this could be a static inline, which is neater.
> >...
> 
> In these two cases I only moved code.
> 
> And I actually moved the other code and git just decided to move the 
> code that stayed instead since it creates less changed lines...

umm, you also changed the declarations of profile_tick() and
profile_hits() but not of create_prof_cpu_mask().

Oh well, I'll do it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC: 2.6 patch] build kernel/profile.o only when requested
  2008-05-20 10:34     ` Andrew Morton
@ 2008-05-20 10:42       ` Adrian Bunk
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Bunk @ 2008-05-20 10:42 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On Tue, May 20, 2008 at 03:34:44AM -0700, Andrew Morton wrote:
> On Tue, 20 May 2008 13:21:50 +0300 Adrian Bunk <bunk@kernel.org> wrote:
> 
> > On Tue, May 20, 2008 at 02:01:21AM -0700, Andrew Morton wrote:
> > > On Tue, 20 May 2008 00:53:06 +0300 Adrian Bunk <bunk@kernel.org> wrote:
> > > 
> > > > 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.
> > > > 
> > > 
> > > Little nits:
> > > 
> > > > index 05c1cc7..4081fa3 100644
> > > > --- a/include/linux/profile.h
> > > > +++ b/include/linux/profile.h
> > > > @@ -8,8 +8,6 @@
> > > >  
> > > >  #include <asm/errno.h>
> > > >  
> > > > -extern int prof_on __read_mostly;
> > > > -
> > > >  #define CPU_PROFILING	1
> > > >  #define SCHED_PROFILING	2
> > > >  #define SLEEP_PROFILING	3
> > > > @@ -19,14 +17,29 @@ struct proc_dir_entry;
> > > >  struct pt_regs;
> > > >  struct notifier_block;
> > > >  
> > > > +#if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
> > > > +void create_prof_cpu_mask(struct proc_dir_entry *);
> > > 
> > > This omits the argument's name, whereas elsewhere you have taken care
> > > to introduce the name where it was missing.
> > > 
> > > > +#else
> > > > +#define create_prof_cpu_mask(x)			do { (void)(x); } while (0)
> > > 
> > > I think this could be a static inline, which is neater.
> > >...
> > 
> > In these two cases I only moved code.
> > 
> > And I actually moved the other code and git just decided to move the 
> > code that stayed instead since it creates less changed lines...
> 
> umm, you also changed the declarations of profile_tick() and
> profile_hits() but not of create_prof_cpu_mask().
>...

For profile_{hits,tick}() I added dummies.

But I didn't touch create_prof_cpu_mask() at all.

I'm very unsure how many cleanups I should stuff into such patches, and 
I'd actually rather expected someone telling I shouldn't have touched 
the existing profile_{hits,tick}() prototypes...

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-05-20 10:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-19 21:53 [RFC: 2.6 patch] build kernel/profile.o only when requested Adrian Bunk
2008-05-20  9:01 ` Andrew Morton
2008-05-20 10:21   ` Adrian Bunk
2008-05-20 10:34     ` Andrew Morton
2008-05-20 10:42       ` Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox