mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Peter Zijlstra' <peterz@infradead.org>,
	"x86@kernel.org" <x86@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [RFC][PATCH] x86/alternatives: Optimize optimize_nops()
Date: Mon, 15 Mar 2021 16:45:30 +0000	[thread overview]
Message-ID: <90126210af5441c1830b1325ef996e77@AcuMS.aculab.com> (raw)
In-Reply-To: <YE+BFIil8wj+q8Qi@hirez.programming.kicks-ass.net>

From: Peter Zijlstra
> Sent: 15 March 2021 15:45
> 
> Currently optimize_nops() scans to see if the alternative starts with
> NOPs. However, the emit pattern is:
> 
>   141:	\oldinstr
>   142:	.skip (len-(142b-141b)), 0x90
> 
> That is, when oldinstr is short, we pad the tail with NOPs. This case
> never gets optimized.
> 
> Rewrite optimize_nops() to replace any string of NOPs inside the
> alternative to larger NOPs. Also run it irrespective of patching,
> replacing NOPs in both the original and replaced code.

This should even speed up old 64bit cpu.
Although the nopl instruction has to go through the 'big decoder'
(so only one per clock) it is much bigger than the 0x90 'nop'
instructions currently used.
So although (probably) 3 'nop' can be decoded each clock
that is less bytes of padding per clock.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


      parent reply	other threads:[~2021-03-15 16:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 15:45 Peter Zijlstra
2021-03-15 16:23 ` Peter Zijlstra
2021-03-15 16:45 ` David Laight [this message]

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=90126210af5441c1830b1325ef996e77@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --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®