public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Rakib Mullick <rakib.mullick@gmail.com>, Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	markus.t.metzger@gmail.com
Subject: Re: [PATCH -mm] tracing: Fix section mismatch in trace_hw_branches.c
Date: Sat, 21 Feb 2009 16:22:52 +0100	[thread overview]
Message-ID: <20090221152251.GA6807@nowhere> (raw)
In-Reply-To: <b9df5fa10902131936p5e0997c6p57f659457a9cc356@mail.gmail.com>

On Sat, Feb 14, 2009 at 09:36:00AM +0600, Rakib Mullick wrote:
>   Impact: Fix section mismatch
> 
> The function bts_trace_init() references a variable
> bts_hotcpu_notifier which is marked
> as __cpuinitdata. Thus causes section mismatch. This patch fixes it.
> 
>   LD      kernel/trace/built-in.o
> WARNING: kernel/trace/built-in.o(.text+0xc90c): Section mismatch in
> reference from the function bts_trace_init() to the variable
> .cpuinit.data:bts_hotcpu_notifier
> The function bts_trace_init() references
> the variable __cpuinitdata bts_hotcpu_notifier.
> This is often because bts_trace_init lacks a __cpuinitdata
> annotation or the annotation of bts_hotcpu_notifier is wrong.
> 
> WARNING: kernel/trace/built-in.o(.text+0xc92a): Section mismatch in
> reference from the function bts_trace_reset() to the variable
> .cpuinit.data:bts_hotcpu_notifier
> The function bts_trace_reset() references
> the variable __cpuinitdata bts_hotcpu_notifier.
> This is often because bts_trace_reset lacks a __cpuinitdata
> annotation or the annotation of bts_hotcpu_notifier is wrong.
> 
> Thanks.
> 
> ---
> Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
> 
> --- linus/kernel/trace/trace_hw_branches.c	2009-02-13 11:23:55.000000000 +0600
> +++ rakib/kernel/trace/trace_hw_branches.c	2009-02-13 22:12:30.000000000 +0600
> @@ -127,7 +127,7 @@ static struct notifier_block bts_hotcpu_
>  	.notifier_call = bts_hotcpu_handler
>  };
> 
> -static int bts_trace_init(struct trace_array *tr)
> +static int __cpuinit bts_trace_init(struct trace_array *tr)
>  {
>  	hw_branch_trace = tr;
> 
> @@ -137,7 +137,7 @@ static int bts_trace_init(struct trace_a
>  	return 0;
>  }
> 
> -static void bts_trace_reset(struct trace_array *tr)
> +static void __cpuinit bts_trace_reset(struct trace_array *tr)
>  {
>  	bts_trace_stop(tr);
>  	unregister_hotcpu_notifier(&bts_hotcpu_notifier);


Hi,

When I saw this patch, I searched the real purpose of __cpuinit and its
real impact.
But I didn't find any comments about it inside the kernel.

But today, by looking at the discussion around latest git pull for x86
to mainline, I discover that __cpuinit becomes __init on UP.

So, unless I missed something, this patch seems to me very dangerous.
The init and reset callbacks of a tracer can be called at any time, not only
on initcalls time (__init functions are freed from memory after the middle stage
of the boot).
With this patch, on UP we will dereference freed memory while activating this tracer.

The old code was fine because register_hotplug_cpu does nothing on UP.
Unfortunately the warning still existed though this was a kind of false positive.
This is a section mismatch, but harmless.

So instead I would suggest to:

- call register_hotcpu_notifier(&bts_hotcpu_notifier) from init_bts_trace() which
  is called only one time on boot.

- never unregister this notifier

- inside bts_hotcpu_handler(), only call bts_trace_{start,stop}_cpu() on the given
  cpu if trace_hw_branches_enabled == 1
  Ok, now the handler will be called on each cpu hotplug event but this is fine since
  this is a rare path.

Hm?


> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


  parent reply	other threads:[~2009-02-21 15:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-14  3:36 [PATCH -mm] tracing: Fix section mismatch in trace_hw_branches.c Rakib Mullick
2009-02-15 19:41 ` Ingo Molnar
2009-02-21 15:22 ` Frederic Weisbecker [this message]
2009-02-22 13:33   ` Rakib Mullick
2009-02-22 16:22     ` Frederic Weisbecker
2009-02-23 10:21       ` Markus Metzger
2009-02-22 16:15   ` KOSAKI Motohiro
2009-02-22 16:23     ` Frederic Weisbecker
2009-02-22 19:29     ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090221152251.GA6807@nowhere \
    --to=fweisbec@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.t.metzger@gmail.com \
    --cc=mingo@elte.hu \
    --cc=rakib.mullick@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox