All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Borislav Petkov <bp@suse.de>
Cc: "Huang, Ying" <ying.huang@intel.com>,
	"Denys Vlasenko" <dvlasenk@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Brian Gerst" <brgerst@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"Andy Lutomirski" <luto@amacapital.net>,
	lkp@01.org, "Thomas Gleixner" <tglx@linutronix.de>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Ingo Molnar" <mingo@kernel.org>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>
Subject: Re: [LKP] [lkp] [x86/hweight] 65ea11ec6a: will-it-scale.per_process_ops 9.3% improvement
Date: Thu, 25 Aug 2016 03:05:19 -0700	[thread overview]
Message-ID: <D6903D5A-D2CA-4FAB-8D3E-5885B8F79AED@zytor.com> (raw)
In-Reply-To: <20160825092214.GA4643@nazgul.tnic>

On August 25, 2016 2:22:14 AM PDT, Borislav Petkov <bp@suse.de> wrote:
>On Thu, Aug 18, 2016 at 06:11:39AM +0200, Borislav Petkov wrote:
>> So if there's no bug, alternatives should replace all "call
>> __sw_hweightXX" calls with POPCNT. So you shouldn't be even calling
>> these functions and hitting that path.
>> 
>> Can you boot the kernel with "debug-alternative" and put that dmesg
>> somewhere along with vmlinux for me to stare at? Privately is fine
>too.
>> 
>> I'd like to make sure the alternatives application actually happens.
>
>Ok, Huang sent me the files I asked for privately (Thanks!). And I
>still can't
>see how that commit can even influence anything as the code doesn't get
>executed after alternatives:
>
>ffffffff81007f35:       e8 36 66 47 00          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff81007f35: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff81008021:       e8 4a 65 47 00          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff81008021: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff8100bd63:       e8 08 28 47 00          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff8100bd63: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff81171a05:       e8 66 cb 30 00          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff81171a05: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff81171a66:       e8 05 cb 30 00          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff81171a66: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff8145c3e5:       e8 86 21 02 00          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff8145c3e5: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff8145c40c:       e8 5f 21 02 00          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff8145c40c: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff8174768d:       e8 de 6e d3 ff          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff8174768d: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff817c43da:       e8 91 a1 cb ff          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff817c43da: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff817f4e6a:       e8 01 97 c8 ff          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff817f4e6a: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff81ffae4b:       e8 20 37 48 ff          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff81ffae4b: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>ffffffff82011bd1:       e8 9a c9 46 ff          callq  ffffffff8147e570
><__sw_hweight64>
>ffffffff82011bd1: final_insn: f3 48 0f b8 c7 (popcnt %rdi,%rax)
>
>__sw_hweight64 is at 0xffffffff8147e570 and all those locations which
>call 0xffffffff8147e570 get replaced with POPCNT (final_insn in dmesg).
>
>Also, I did this to a guest kernel:
>
>---
>diff --git a/arch/x86/lib/hweight.S b/arch/x86/lib/hweight.S
>index 8a602a1e404a..7f18f59eadd5 100644
>--- a/arch/x86/lib/hweight.S
>+++ b/arch/x86/lib/hweight.S
>@@ -34,6 +34,7 @@ ENTRY(__sw_hweight32)
> ENDPROC(__sw_hweight32)
> 
> ENTRY(__sw_hweight64)
>+	call dump_stack
> #ifdef CONFIG_X86_64
> 	pushq   %rdi
> 	pushq   %rdx
>---
>
>and got 23 invocations before alternatives get applied:
>
>$ grep dump_stack ~/kvm/test-x86_64-1235.log | uniq -c
>     23 [<ffffffff81336955>] dump_stack+0x67/0x92
>
>just to make sure that __sw_hweight64 *actually* *really* gets
>replaced.
>
>Then I ran the job.yaml thing as suggested in the initial mail and no
>more __sw_hweight64 calls.
>
>So either I'm still missing something or that's the wrong commit or ...
>
>/me haz no idea :-\

I'm wondering if one of those 23 invocations sets up some kind of corrupt data that continues to get used.
-- 
Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.

  reply	other threads:[~2016-08-25 10:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16 14:26 [lkp] [x86/hweight] 65ea11ec6a: will-it-scale.per_process_ops 9.3% improvement kernel test robot
2016-08-16 14:26 ` kernel test robot
2016-08-16 16:59 ` [lkp] " H. Peter Anvin
2016-08-16 17:16   ` Borislav Petkov
2016-08-16 17:16     ` Borislav Petkov
2016-08-16 23:09     ` [lkp] " H. Peter Anvin
2016-08-17  5:46       ` Borislav Petkov
2016-08-17  5:46         ` Borislav Petkov
2016-08-17 22:29         ` [LKP] [lkp] " Huang, Ying
2016-08-17 22:29           ` Huang, Ying
2016-08-18  3:45           ` [LKP] [lkp] " Borislav Petkov
2016-08-18  3:45             ` Borislav Petkov
2016-08-18  3:54             ` [LKP] [lkp] " Huang, Ying
2016-08-18  3:54               ` Huang, Ying
2016-08-18  4:11               ` [LKP] [lkp] " Borislav Petkov
2016-08-18  4:11                 ` Borislav Petkov
2016-08-25  9:22                 ` [LKP] [lkp] " Borislav Petkov
2016-08-25  9:22                   ` Borislav Petkov
2016-08-25 10:05                   ` H. Peter Anvin [this message]
2016-08-25 11:45                     ` [LKP] [lkp] " Borislav Petkov
2016-08-25 11:45                       ` Borislav Petkov
2016-08-25 20:07                       ` [LKP] [lkp] " H. Peter Anvin
2016-08-18  3:57             ` H. Peter Anvin
2016-08-17  6:48       ` Peter Zijlstra
2016-08-17  6:48         ` Peter Zijlstra

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=D6903D5A-D2CA-4FAB-8D3E-5885B8F79AED@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=ville.syrjala@linux.intel.com \
    --cc=ying.huang@intel.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 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.