linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Kanna Scarlet <knscarlet@gnuweeb.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Ard Biesheuvel <ardb@kernel.org>,
	Bill Metzenthen <billm@melbpc.org.au>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Joerg Roedel <jroedel@suse.de>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Michael Roth <michael.roth@amd.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Sean Christopherson <seanjc@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ammar Faizi <ammarfaizi2@gnuweeb.org>,
	GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] x86: Change mov $0, %reg with xor %reg, %reg
Date: Fri, 5 Aug 2022 11:54:09 +0200	[thread overview]
Message-ID: <YuzowUBt4pTLcMRc@zn.tnic> (raw)
In-Reply-To: <20220804180805.9077-1-knscarlet@gnuweeb.org>

On Thu, Aug 04, 2022 at 06:08:05PM +0000, Kanna Scarlet wrote:
> Hello sir Borislav,

Please, no "sir" - just Boris or Borislav,

> Thank you for your response. I tried to find out other advantages of
> xor reg,reg on Google and found this:
> https://stackoverflow.com/a/33668295/7275114
> 
>   "xor (being a recognized zeroing idiom, unlike mov reg, 0) has some
>   obvious and some subtle advantages:
> 
>   1. smaller code-size than mov reg,0. (All CPUs)
>   2. avoids partial-register penalties for later code.
>      (Intel P6-family and SnB-family).
>   3. doesn't use an execution unit, saving power and freeing up
>      execution resources. (Intel SnB-family)
>   4. smaller uop (no immediate data) leaves room in the uop cache-line
>      for nearby instructions to borrow if needed. (Intel SnB-family).
>   5. doesn't use up entries in the physical register file. (Intel
>      SnB-family (and P4) at least, possibly AMD as well since they use
>      a similar PRF design instead of keeping register state in the ROB
>      like Intel P6-family microarchitectures.)"
> 
> Should I add all in the explanation sir?

You should try to understand what this means and write the gist of it in
your own words. This is how you can learn something.

> We also find more files to patch with this command:
> 
>    grep -rE "mov.?\s+\\$\\0\s*," arch/x86
> 
> it shows many immediate zero moves to 64-bit register in file
> arch/x86/crypto/curve25519-x86_64.c, but the next instruction may depend
> on the previous %rflags value, we are afraid to change this because
> xor touches %rflags. We will try to change it to movl $0, %r32 to
> reduce the code size.

I don't think you need to do that - you can do this one patch in order
to go through the whole process of creating and submitting a patch but
you should not go on a "let's convert everything" spree just for the
sake of it.

Because maintainers barely have time to look at patches, you don't have
to send them more when they're not really needed.

Rather, I'd suggest you go and try to fix real bugs. This has some ideas
what to do:

https://www.linux.com/news/three-ways-beginners-contribute-linux-kernel/

Looking at the kernel bugzilla and trying to understand and reproduce a
bug from there would get you a long way. And you'll learn a lot.

Also, you should peruse

https://www.kernel.org/doc/html/latest/process/index.html

which has a lot of information about how this whole community thing
works.

I sincerely hope that helps.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  parent reply	other threads:[~2022-08-05  9:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 15:26 [PATCH 0/1] x86 change mov 0, %reg to xor %reg, %reg Kanna Scarlet
2022-08-04 15:26 ` [PATCH 1/1] x86: Change mov $0, %reg with " Kanna Scarlet
2022-08-04 15:53   ` Borislav Petkov
2022-08-04 18:08     ` Kanna Scarlet
2022-08-05  9:26       ` David Laight
2022-08-05  9:42         ` Joerg Roedel
2022-08-08 16:45           ` Kanna Scarlet
2022-08-08 18:59             ` H. Peter Anvin
2022-08-08 16:38         ` Kanna Scarlet
2022-08-08 18:59         ` H. Peter Anvin
2022-08-09  7:38           ` David Laight
2022-08-05  9:54       ` Borislav Petkov [this message]
2022-08-08 16:57         ` Kanna Scarlet

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=YuzowUBt4pTLcMRc@zn.tnic \
    --to=bp@alien8.de \
    --cc=ammarfaizi2@gnuweeb.org \
    --cc=ardb@kernel.org \
    --cc=billm@melbpc.org.au \
    --cc=brijesh.singh@amd.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=gwml@vger.gnuweeb.org \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@kernel.org \
    --cc=jroedel@suse.de \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=knscarlet@gnuweeb.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --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;
as well as URLs for NNTP newsgroup(s).