mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Jaswinder Singh Rajput <jaswinder@kernel.org>
Cc: John Levon <levon@movementarian.org>, Ingo Molnar <mingo@elte.hu>,
	x86 maintainers <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: fix BUG: using smp_processor_id() in preemptible [00000000] code: oprofiled/3319
Date: Sun, 5 Apr 2009 12:51:11 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.0904051243310.4023@localhost.localdomain> (raw)
In-Reply-To: <1238958725.3522.1.camel@ht.satnam>



On Mon, 6 Apr 2009, Jaswinder Singh Rajput wrote:
>
> Fixed this bug on P4 HT machine:

I don't think this really is correct.

Anything that does that "get_stagger()" thing should already either be 
tied to a specific CPU (because it's going to actually touch the variables 
for "that CPU"), or it should likely set up the data structures for _all_ 
cases.

Just as an example, look at something like "p4_setup_ctrs()": it will use 
that stagger to determine what MSR to read. But if we are preemptable, the 
CPU we actually do the MSR read on may be a _different_ CPU than the CPU 
that we did the "get_stagger()" on!

So I really think that protecting against preemption inside of 
"get_stagger()" is fundamentally buggy. Because if you need it, then by 
the time you return the value from the function, the value has now lost 
all meaning because you might have preempted to another CPU after doing 
the put_cpu().

So I think the "get_cpu()/put_cpu()" should be done around the whole 
sequence (ie from before "get_stagger()" to after the stagger has been 
used to initialize some data structures or do wrmsr/rdmsr calls.

Of course, this is all ancient code, so whatever. But I really think this 
patch is actively bad - it just hides the issue rather than fixing 
anything.

		Linus

  reply	other threads:[~2009-04-05 19:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-05 19:12 Jaswinder Singh Rajput
2009-04-05 19:51 ` Linus Torvalds [this message]
2009-04-05 20:14   ` Jaswinder Singh Rajput
2009-04-05 21:02     ` Thomas Gleixner
2009-04-05 21:38     ` [RFC PATCH] x86, oprofile: fix P4 oprofile CPU setup bug Ingo Molnar
2009-04-05 21:59       ` Ingo Molnar
2009-04-06  4:11         ` Jaswinder Singh Rajput
2009-04-06  4:10       ` Jaswinder Singh Rajput

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=alpine.LFD.2.00.0904051243310.4023@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=jaswinder@kernel.org \
    --cc=levon@movementarian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®