All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@linux.intel.com>
To: Robert Richter <robert.richter@amd.com>
Cc: Ingo Molnar <mingo@elte.hu>, Eric Dumazet <dada1@cosmosbay.com>,
	linux kernel <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] oprofile: fix CPU unplug panic in ppro_stop()
Date: Wed, 03 Dec 2008 15:08:34 +0100	[thread overview]
Message-ID: <493692E2.9050302@linux.intel.com> (raw)
In-Reply-To: <20081203115954.GH11656@erda.amd.com>

Robert Richter wrote:
> On 02.12.08 09:17:29, Ingo Molnar wrote:
>> * Eric Dumazet <dada1@cosmosbay.com> wrote:
>>
>>> If oprofile statically compiled in kernel, a cpu unplug triggers
>>> a panic in ppro_stop(), because a NULL pointer is dereferenced.
>>>
>>> Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
>>> ---
>>> arch/x86/oprofile/op_model_ppro.c |    4 ++++
>>> 1 files changed, 4 insertions(+)
>>> diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
>>> index 716d26f..e9f80c7 100644
>>> --- a/arch/x86/oprofile/op_model_ppro.c
>>> +++ b/arch/x86/oprofile/op_model_ppro.c
>>> @@ -156,6 +156,8 @@ static void ppro_start(struct op_msrs const * const msrs)
>>>  	unsigned int low, high;
>>>  	int i;
>>>  
>>> +	if (!reset_value)
>>> +		return;
>>>
>>> 	for (i = 0; i < num_counters; ++i) {
>>>  		if (reset_value[i]) {
>>>  			CTRL_READ(low, high, msrs, i);
> 
> The patch fixes the null pointer access and this ok. But the root
> cause seems to be in the cpu hotplug and initialization
> code. xxx_start() should not be called before xxx_setup_ctrs() or
> after xxx_shutdown(). 

Yes, it would be better to fix that. At least it would make
the code cleaner than the add checks for this backdoor everywhere.

> Also, running only xxx_start() and xxx_stop() in
> the cpu notifier functions is not sufficient. There is at least some
> on_each_cpu code in nmi_setup() that should be called also in the cpu
> notifier functions. I have to review that code.

AFAIK cpu hotplug has more problems in oprofile anyways. That is why
I didn't test that case.

> 
> [...]
> 
>> It was absolutely unnecessary to add kmalloc to this rarely executed 
>> codepath - and the way it was added was absolutely horrible as well, it 
>> was tacked on in the middle of an existing codepath, instead of factoring 
>> it out nicely. Perfmon will eventually replace PMC management anyway, so 
>> there was no "this way it's cleaner" argument either. So this code should 
>> have been changed minimally, instead of slapping in a full kmalloc for a 
>> simple array extension from 2 to 4 entries ...
> 
> Ingo, you are right that using kmalloc is unnecessary for
> reset_value. So, Andi, maybe you could make this code easier?

The reason I added the kmalloc is that there's also a varying number
of separate fixed function counters (although that's not currently
submitted).

Also I would prefer to not have a hard coded number for future
CPUs. Contrary to other people's opinion architectural perfmon is
not for Nehalem only.

-Andi

  reply	other threads:[~2008-12-03 14:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-02  6:21 [PATCH] oprofile: fix CPU unplug panic in ppro_stop() Eric Dumazet
2008-12-02  8:17 ` Ingo Molnar
2008-12-03 11:59   ` Robert Richter
2008-12-03 14:08     ` Andi Kleen [this message]
2008-12-04  0:04 ` Robert Richter

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=493692E2.9050302@linux.intel.com \
    --to=ak@linux.intel.com \
    --cc=dada1@cosmosbay.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=robert.richter@amd.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.