From: Jason Baron <jasonbaron0@gmail.com>
To: Borislav Petkov <bp@alien8.de>, Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@amacapital.net>,
Thomas Gleixner <tglx@linutronix.de>,
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>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: Kernel broken on processors without performance counters
Date: Tue, 21 Jul 2015 14:50:25 -0400 [thread overview]
Message-ID: <55AE9471.1000601@gmail.com> (raw)
In-Reply-To: <20150721181553.GA3378@nazgul.tnic>
On 07/21/2015 02:15 PM, Borislav Petkov wrote:
> On Tue, Jul 21, 2015 at 06:12:15PM +0200, Peter Zijlstra wrote:
>> Yes, if you start out false, you must be unlikely. If you start out
>> true, you must be likely.
>>
>> We could maybe try and untangle that if there really is a good use case,
>> but this is the current state.
>>
>> The whole reason this happened is because 'false' is like:
>>
>>
>> ...
>> <nop>
>> 1:
>> ...
>>
>>
>>
>> label:
>> <unlikely code>
>> jmp 1b
>>
>>
>> Where the code if out-of-line by default. The enable will rewrite the
>> <nop> with a jmp label.
> Btw, native_sched_clock() is kinda botched because of that, see below.
>
> I'd want that RDTSC to come first with a NOP preceding it which can
> become a JMP in case some idiotic CPU can't do RDTSC and needs to use
> jiffies. Instead, we *unconditionally* jump to RDTSC which is WTF?! We
> can just as well do a normal unlikely() without the static_key:
hmmm...so this is a case where need to the default the branch
to the out-of-line branch at boot. That is, we can't just enable
the out-of-line branch at boot time, b/c it might be too late at
that point? IE native_sched_clock() gets called very early?
Thanks,
-Jason
>
> .globl native_sched_clock
> .type native_sched_clock, @function
> native_sched_clock:
> pushq %rbp #
> movq %rsp, %rbp #,
> #APP
> # 21 "./arch/x86/include/asm/jump_label.h" 1
> 1:.byte 0x0f,0x1f,0x44,0x00,0
> .pushsection __jump_table, "aw"
> .balign 8
> .quad 1b, .L122, __use_tsc #,
> .popsection
>
> # 0 "" 2
> #NO_APP
> movabsq $-4294667296000000, %rax #, tmp118
> popq %rbp #
> imulq $1000000, jiffies_64(%rip), %rdx #, jiffies_64, D.28443
> addq %rdx, %rax # D.28443, D.28443
> ret
> .L122:
> #APP
> # 118 "./arch/x86/include/asm/msr.h" 1
> rdtsc
> # 0 "" 2
>
next prev parent reply other threads:[~2015-07-21 18:50 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
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 [this message]
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=55AE9471.1000601@gmail.com \
--to=jasonbaron0@gmail.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=aarcange@redhat.com \
--cc=acme@kernel.org \
--cc=bp@alien8.de \
--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=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).