public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] kernel/profile.c: fix warnings
@ 2008-07-29 19:00 Alexander Beregalov
  2008-07-31 11:43 ` Alexander Beregalov
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Beregalov @ 2008-07-29 19:00 UTC (permalink / raw)
  To: mingo, kernel-janitors, linux-kernel

Hi

Moved these three functions under ifdef CONFIG_PROC_FS, separated
profile_hits. Perhaps it would be better to join two ifdef-CONFIG_PROC_FS
blocks. 
This patch is on top of 2.6.27-rc1.

From: Alexander Beregalov <a.beregalov@gmail.com>

kernel/profile.c: fix warnings:

kernel/profile.c:245: warning: 'profile_flip_buffers' defined but not
used
kernel/profile.c:268: warning: 'profile_discard_flip_buffers' defined
but not used
kernel/profile.c:335: warning: 'profile_cpu_callback' defined but not
used

Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>

---

 kernel/profile.c |  107 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 56 insertions(+), 51 deletions(-)

diff --git a/kernel/profile.c b/kernel/profile.c
index cd26bed..0f377d9 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -202,6 +202,7 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *))
 EXPORT_SYMBOL_GPL(unregister_timer_hook);
 
 
+#ifdef CONFIG_PROC_FS
 #ifdef CONFIG_SMP
 /*
  * Each cpu has a pair of open-addressed hashtables for pending
@@ -279,57 +280,6 @@ static void profile_discard_flip_buffers(void)
 	mutex_unlock(&profile_flip_mutex);
 }
 
-void profile_hits(int type, void *__pc, unsigned int nr_hits)
-{
-	unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
-	int i, j, cpu;
-	struct profile_hit *hits;
-
-	if (prof_on != type || !prof_buffer)
-		return;
-	pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
-	i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
-	secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
-	cpu = get_cpu();
-	hits = per_cpu(cpu_profile_hits, cpu)[per_cpu(cpu_profile_flip, cpu)];
-	if (!hits) {
-		put_cpu();
-		return;
-	}
-	/*
-	 * We buffer the global profiler buffer into a per-CPU
-	 * queue and thus reduce the number of global (and possibly
-	 * NUMA-alien) accesses. The write-queue is self-coalescing:
-	 */
-	local_irq_save(flags);
-	do {
-		for (j = 0; j < PROFILE_GRPSZ; ++j) {
-			if (hits[i + j].pc == pc) {
-				hits[i + j].hits += nr_hits;
-				goto out;
-			} else if (!hits[i + j].hits) {
-				hits[i + j].pc = pc;
-				hits[i + j].hits = nr_hits;
-				goto out;
-			}
-		}
-		i = (i + secondary) & (NR_PROFILE_HIT - 1);
-	} while (i != primary);
-
-	/*
-	 * Add the current hit(s) and flush the write-queue out
-	 * to the global buffer:
-	 */
-	atomic_add(nr_hits, &prof_buffer[pc]);
-	for (i = 0; i < NR_PROFILE_HIT; ++i) {
-		atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
-		hits[i].pc = hits[i].hits = 0;
-	}
-out:
-	local_irq_restore(flags);
-	put_cpu();
-}
-
 static int __devinit profile_cpu_callback(struct notifier_block *info,
 					unsigned long action, void *__cpu)
 {
@@ -390,7 +340,62 @@ out_free:
 #define profile_flip_buffers()		do { } while (0)
 #define profile_discard_flip_buffers()	do { } while (0)
 #define profile_cpu_callback		NULL
+#endif
+#endif /* CONFIG_PROC_FS */
 
+#ifdef CONFIG_SMP
+void profile_hits(int type, void *__pc, unsigned int nr_hits)
+{
+	unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
+	int i, j, cpu;
+	struct profile_hit *hits;
+
+	if (prof_on != type || !prof_buffer)
+		return;
+	pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
+	i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
+	secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
+	cpu = get_cpu();
+	hits = per_cpu(cpu_profile_hits, cpu)[per_cpu(cpu_profile_flip, cpu)];
+	if (!hits) {
+		put_cpu();
+		return;
+	}
+	/*
+	 * We buffer the global profiler buffer into a per-CPU
+	 * queue and thus reduce the number of global (and possibly
+	 * NUMA-alien) accesses. The write-queue is self-coalescing:
+	 */
+	local_irq_save(flags);
+	do {
+		for (j = 0; j < PROFILE_GRPSZ; ++j) {
+			if (hits[i + j].pc == pc) {
+				hits[i + j].hits += nr_hits;
+				goto out;
+			} else if (!hits[i + j].hits) {
+				hits[i + j].pc = pc;
+				hits[i + j].hits = nr_hits;
+				goto out;
+			}
+		}
+		i = (i + secondary) & (NR_PROFILE_HIT - 1);
+	} while (i != primary);
+
+	/*
+	 * Add the current hit(s) and flush the write-queue out
+	 * to the global buffer:
+	 */
+	atomic_add(nr_hits, &prof_buffer[pc]);
+	for (i = 0; i < NR_PROFILE_HIT; ++i) {
+		atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
+		hits[i].pc = hits[i].hits = 0;
+	}
+out:
+	local_irq_restore(flags);
+	put_cpu();
+}
+
+#else /* !CONFIG_SMP */
 void profile_hits(int type, void *__pc, unsigned int nr_hits)
 {
 	unsigned long pc;

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

* Re: [RFC][PATCH] kernel/profile.c: fix warnings
  2008-07-29 19:00 [RFC][PATCH] kernel/profile.c: fix warnings Alexander Beregalov
@ 2008-07-31 11:43 ` Alexander Beregalov
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Beregalov @ 2008-07-31 11:43 UTC (permalink / raw)
  To: Andrew Morton, mingo, kernel-janitors, linux-kernel

2008/7/29 Alexander Beregalov <a.beregalov@gmail.com>:
> Hi
>
> Moved these three functions under ifdef CONFIG_PROC_FS, separated
> profile_hits. Perhaps it would be better to join two ifdef-CONFIG_PROC_FS
> blocks.
> This patch is on top of 2.6.27-rc1.
>
> From: Alexander Beregalov <a.beregalov@gmail.com>
>
> kernel/profile.c: fix warnings:
>
> kernel/profile.c:245: warning: 'profile_flip_buffers' defined but not
> used
> kernel/profile.c:268: warning: 'profile_discard_flip_buffers' defined
> but not used
> kernel/profile.c:335: warning: 'profile_cpu_callback' defined but not
> used
>
> Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
>
> ---
>
>  kernel/profile.c |  107 ++++++++++++++++++++++++++++--------------------------
>  1 files changed, 56 insertions(+), 51 deletions(-)
>
> diff --git a/kernel/profile.c b/kernel/profile.c
> index cd26bed..0f377d9 100644
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -202,6 +202,7 @@ void unregister_timer_hook(int (*hook)(struct pt_regs *))
>  EXPORT_SYMBOL_GPL(unregister_timer_hook);
>
>
> +#ifdef CONFIG_PROC_FS
>  #ifdef CONFIG_SMP
>  /*
>  * Each cpu has a pair of open-addressed hashtables for pending
> @@ -279,57 +280,6 @@ static void profile_discard_flip_buffers(void)
>        mutex_unlock(&profile_flip_mutex);
>  }
>
> -void profile_hits(int type, void *__pc, unsigned int nr_hits)
> -{
> -       unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
> -       int i, j, cpu;
> -       struct profile_hit *hits;
> -
> -       if (prof_on != type || !prof_buffer)
> -               return;
> -       pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
> -       i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
> -       secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
> -       cpu = get_cpu();
> -       hits = per_cpu(cpu_profile_hits, cpu)[per_cpu(cpu_profile_flip, cpu)];
> -       if (!hits) {
> -               put_cpu();
> -               return;
> -       }
> -       /*
> -        * We buffer the global profiler buffer into a per-CPU
> -        * queue and thus reduce the number of global (and possibly
> -        * NUMA-alien) accesses. The write-queue is self-coalescing:
> -        */
> -       local_irq_save(flags);
> -       do {
> -               for (j = 0; j < PROFILE_GRPSZ; ++j) {
> -                       if (hits[i + j].pc == pc) {
> -                               hits[i + j].hits += nr_hits;
> -                               goto out;
> -                       } else if (!hits[i + j].hits) {
> -                               hits[i + j].pc = pc;
> -                               hits[i + j].hits = nr_hits;
> -                               goto out;
> -                       }
> -               }
> -               i = (i + secondary) & (NR_PROFILE_HIT - 1);
> -       } while (i != primary);
> -
> -       /*
> -        * Add the current hit(s) and flush the write-queue out
> -        * to the global buffer:
> -        */
> -       atomic_add(nr_hits, &prof_buffer[pc]);
> -       for (i = 0; i < NR_PROFILE_HIT; ++i) {
> -               atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
> -               hits[i].pc = hits[i].hits = 0;
> -       }
> -out:
> -       local_irq_restore(flags);
> -       put_cpu();
> -}
> -
>  static int __devinit profile_cpu_callback(struct notifier_block *info,
>                                        unsigned long action, void *__cpu)
>  {
> @@ -390,7 +340,62 @@ out_free:
>  #define profile_flip_buffers()         do { } while (0)
>  #define profile_discard_flip_buffers() do { } while (0)
>  #define profile_cpu_callback           NULL
> +#endif
> +#endif /* CONFIG_PROC_FS */
>
> +#ifdef CONFIG_SMP
> +void profile_hits(int type, void *__pc, unsigned int nr_hits)
> +{
> +       unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
> +       int i, j, cpu;
> +       struct profile_hit *hits;
> +
> +       if (prof_on != type || !prof_buffer)
> +               return;
> +       pc = min((pc - (unsigned long)_stext) >> prof_shift, prof_len - 1);
> +       i = primary = (pc & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
> +       secondary = (~(pc << 1) & (NR_PROFILE_GRP - 1)) << PROFILE_GRPSHIFT;
> +       cpu = get_cpu();
> +       hits = per_cpu(cpu_profile_hits, cpu)[per_cpu(cpu_profile_flip, cpu)];
> +       if (!hits) {
> +               put_cpu();
> +               return;
> +       }
> +       /*
> +        * We buffer the global profiler buffer into a per-CPU
> +        * queue and thus reduce the number of global (and possibly
> +        * NUMA-alien) accesses. The write-queue is self-coalescing:
> +        */
> +       local_irq_save(flags);
> +       do {
> +               for (j = 0; j < PROFILE_GRPSZ; ++j) {
> +                       if (hits[i + j].pc == pc) {
> +                               hits[i + j].hits += nr_hits;
> +                               goto out;
> +                       } else if (!hits[i + j].hits) {
> +                               hits[i + j].pc = pc;
> +                               hits[i + j].hits = nr_hits;
> +                               goto out;
> +                       }
> +               }
> +               i = (i + secondary) & (NR_PROFILE_HIT - 1);
> +       } while (i != primary);
> +
> +       /*
> +        * Add the current hit(s) and flush the write-queue out
> +        * to the global buffer:
> +        */
> +       atomic_add(nr_hits, &prof_buffer[pc]);
> +       for (i = 0; i < NR_PROFILE_HIT; ++i) {
> +               atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
> +               hits[i].pc = hits[i].hits = 0;
> +       }
> +out:
> +       local_irq_restore(flags);
> +       put_cpu();
> +}
> +
> +#else /* !CONFIG_SMP */
>  void profile_hits(int type, void *__pc, unsigned int nr_hits)
>  {
>        unsigned long pc;
>

Hi Andrew,
Can you also have a look at this?
Is there a better way to fix it?

Thanks

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

end of thread, other threads:[~2008-07-31 11:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-29 19:00 [RFC][PATCH] kernel/profile.c: fix warnings Alexander Beregalov
2008-07-31 11:43 ` Alexander Beregalov

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