All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Baron <jasonbaron0@gmail.com>
To: Andy Lutomirski <luto@amacapital.net>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Mikulas Patocka <mpatocka@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Vince Weaver <vince@deater.net>,
	"hillf.zj" <hillf.zj@alibaba-inc.com>,
	Valdis Kletnieks <Valdis.Kletnieks@vt.edu>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Kernel broken on processors without performance counters
Date: Wed, 08 Jul 2015 16:04:32 -0400	[thread overview]
Message-ID: <559D8250.8000707@gmail.com> (raw)
In-Reply-To: <CALCETrVqeG=3sKJv=pe9ZfaeRmx9uz+jNmXGmPu-7Hah4NvYDQ@mail.gmail.com>

On 07/08/2015 01:37 PM, Andy Lutomirski wrote:
> On Wed, Jul 8, 2015 at 9:07 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>> On Wed, Jul 08, 2015 at 11:17:38AM -0400, Mikulas Patocka wrote:
>>> Hi
>>>
>>> I found out that the patch a66734297f78707ce39d756b656bfae861d53f62 breaks
>>> the kernel on processors without performance counters, such as AMD K6-3.
>>> Reverting the patch fixes the problem.
>>>
>>> The static key rdpmc_always_available somehow gets set (I couldn't really
>>> find out what is setting it, the function set_attr_rdpmc is not executed),
>>> cr4_set_bits(X86_CR4_PCE) is executed and that results in a crash on boot
>>> when attempting to execute init, because the proecssor doesn't support
>>> that bit in CR4.
>> Urgh, the static key trainwreck bites again.
>>
>> One is not supposed to mix static_key_true() and STATIC_KEY_INIT_FALSE.
>>
>> Does this make it go again?
>>
>> ---
>>  arch/x86/include/asm/mmu_context.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
>> index 5e8daee7c5c9..804a3a6030ca 100644
>> --- a/arch/x86/include/asm/mmu_context.h
>> +++ b/arch/x86/include/asm/mmu_context.h
>> @@ -23,7 +23,7 @@ extern struct static_key rdpmc_always_available;
>>
>>  static inline void load_mm_cr4(struct mm_struct *mm)
>>  {
>> -       if (static_key_true(&rdpmc_always_available) ||
>> +       if (static_key_false(&rdpmc_always_available) ||
> In what universe is "static_key_false" a reasonable name for a
> function that returns true if a static key is true?
>
> Can we rename that function?  And could we maybe make static keys type
> safe?  I.e. there would be a type that starts out true and a type that
> starts out false.

So the 'static_key_false' is really branch is initially false. We had
a naming discussion before, but if ppl think its confusing,
'static_key_init_false', or 'static_key_default_false' might be better,
or other ideas.... I agree its confusing.

In terms of getting the type to match so we don't have these
mismatches, I think we could introduce 'struct static_key_false'
and 'struct static_key_true' with proper initializers. However,
'static_key_slow_inc()/dec()'  would also have to add the
true/false modifier. Or maybe we do:

struct static_key_false {
    struct static_key key;
} random_key;

and then the 'static_key_sloc_inc()/dec()' would just take
a &random_key.key....

If we were to change this, I don't think it would be too hard to
introduce the new API, convert subsystems over time and then
drop the old one.

Thanks,

-Jason



  reply	other threads:[~2015-07-08 20:04 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 15:17 Kernel broken on processors without performance counters Mikulas Patocka
2015-07-08 16:07 ` Peter Zijlstra
2015-07-08 16:54   ` Mikulas Patocka
2015-07-09 17:23     ` [PATCH] x86: Fix static_key in load_mm_cr4() Peter Zijlstra
2015-07-09 19:11       ` Mikulas Patocka
2015-07-10  8:27       ` [tip:perf/urgent] x86, perf: Fix static_key bug " tip-bot for Peter Zijlstra
2015-07-08 17:37   ` Kernel broken on processors without performance counters Andy Lutomirski
2015-07-08 20:04     ` Jason Baron [this message]
2015-07-09  0:36       ` Andy Lutomirski
2015-07-10 14:13         ` Peter Zijlstra
2015-07-10 15:29           ` Jason Baron
2015-07-21  8:21           ` Peter Zijlstra
2015-07-21 15:43             ` Thomas Gleixner
2015-07-21 15:49               ` Peter Zijlstra
2015-07-21 15:51                 ` Andy Lutomirski
2015-07-21 16:12                   ` Peter Zijlstra
2015-07-21 16:57                     ` Jason Baron
2015-07-23 14:54                       ` Steven Rostedt
2015-07-21 18:15                     ` Borislav Petkov
2015-07-21 18:50                       ` Jason Baron
2015-07-21 18:54                         ` Andy Lutomirski
2015-07-21 19:00                           ` Valdis.Kletnieks
2015-07-21 19:29                             ` Andy Lutomirski
2015-07-21 23:49                               ` Valdis.Kletnieks
2015-07-22  4:24                         ` Borislav Petkov
2015-07-22 17:06                           ` Jason Baron
2015-07-23 10:42                             ` Peter Zijlstra
2015-07-23 10:53                               ` Borislav Petkov
2015-07-23 14:19                               ` Jason Baron
2015-07-23 14:33                                 ` Peter Zijlstra
2015-07-23 14:49                                   ` Peter Zijlstra
2015-07-23 19:14                                     ` Jason Baron
2015-07-24 10:56                                       ` Peter Zijlstra
2015-07-24 12:36                                         ` Peter Zijlstra
2015-07-24 14:15                                           ` Jason Baron
2015-07-23 14:58                                 ` Peter Zijlstra
2015-07-23 15:34                               ` Steven Rostedt
2015-07-23 17:08                                 ` Peter Zijlstra
2015-07-23 17:18                                   ` Steven Rostedt
2015-07-23 17:33                                   ` Jason Baron
2015-07-23 18:12                                     ` Steven Rostedt
2015-07-23 19:02                                     ` Peter Zijlstra
2015-07-23 17:35                                   ` Andy Lutomirski
2015-07-23 17:54                                   ` Borislav Petkov
2015-07-23 19:02                                     ` Peter Zijlstra
2015-07-24  5:29                                       ` Borislav Petkov
2015-07-24 10:36                                         ` Peter Zijlstra
2015-07-22 20:43                           ` Mikulas Patocka
2015-07-21 15:53                 ` Thomas Gleixner
2015-07-21 15:54                 ` Peter Zijlstra
2015-07-09 17:11       ` Peter Zijlstra
2015-07-09 19:15         ` Jason Baron
2015-07-14  9:35 ` Borislav Petkov
2015-07-14 12:43   ` Mikulas Patocka

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=559D8250.8000707@gmail.com \
    --to=jasonbaron0@gmail.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=aarcange@redhat.com \
    --cc=acme@kernel.org \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mpatocka@redhat.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=vince@deater.net \
    /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.