linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nadav Amit <namit@vmware.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: "keescook@chromium.org" <keescook@chromium.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"hpa@zytor.com" <hpa@zytor.com>
Subject: Re: [RFC 5/8] x86: refcount: prevent gcc distortions
Date: Wed, 16 May 2018 16:44:00 +0000	[thread overview]
Message-ID: <8B7DE95F-5E57-44F0-90E0-CCBA35F98A07@vmware.com> (raw)
In-Reply-To: <5AFBDA6302000078001C31AC@prv1-mh.provo.novell.com>

Jan Beulich <JBeulich@suse.com> wrote:

>>>> On 15.05.18 at 16:11, <namit@vmware.com> wrote:
>> --- a/arch/x86/include/asm/refcount.h
>> +++ b/arch/x86/include/asm/refcount.h
>> @@ -14,34 +14,43 @@
>>  * central refcount exception. The fixup address for the exception points
>>  * back to the regular execution flow in .text.
>>  */
>> -#define _REFCOUNT_EXCEPTION				\
>> -	".pushsection .text..refcount\n"		\
>> -	"111:\tlea %[counter], %%" _ASM_CX "\n"		\
>> -	"112:\t" ASM_UD2 "\n"				\
>> -	ASM_UNREACHABLE					\
>> -	".popsection\n"					\
>> -	"113:\n"					\
>> +
>> +asm ("\n"
>> +	".macro __REFCOUNT_EXCEPTION counter:vararg\n\t"
>> +	".pushsection .text..refcount\n"
>> +	"111:\tlea \\counter, %" _ASM_CX "\n"
>> +	"112:\t" ASM_UD2 "\n\t"
>> +	ASM_UNREACHABLE
>> +	".popsection\n\t"
>> +	"113:\n"
>> 	_ASM_EXTABLE_REFCOUNT(112b, 113b)
>> +	".endm");
> 
> A few comments on assembly code formatting - while gas at present is
> relatively lax in this regard, I wouldn't exclude that there might be a
> more strict mode in the future, and that such a mode might eventually
> become the default. Furthermore these formatting aspects affect
> readability of the assembly produced, should anyone ever find a need
> to look at it (perhaps because of some breakage) - I certainly do every
> once in a while.
> 
> Labels should be placed without any indentation (but of course there
> may be more than one on a line, in which case subsequent ones may
> of course be arbitrarily indented). Instructions and directives, otoh,
> should be placed with at least a single tab or space of indentation
> (unless preceded by a label, in which case the extra white space still
> helps readability).

Writing these patches, I looked at the generated assembly, and there did not
appear to be a standard. IIRC, .pushsection directives were not always
inlined. I will fix it according to your comments.

> I'm also not sure about the purpose of the leading plain newline here.
> gcc annotates code resulting from inline assembly anyway iirc, so
> proper visual separation should already be available.

Right. It was only to get the macro directive not tabulated, but as you
said, it should be tabulated, so I will remove it.

> 
> If I was the maintainer of this code, I would also object to the
> mis-alignment your file scope asm()-s have ("asm (" is 5 characters,
> which doesn't equal a tab's width).

I tried many formats (including the one you propose), and eventually went
with the one that made checkpatch not yell at me. I will revert to the one
you propose, which makes most sense, and ignore checkpatch warnings.

Thanks,
Nadav

  reply	other threads:[~2018-05-16 16:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 14:11 [RFC 0/8] Improving compiler inlining decisions Nadav Amit
2018-05-15 14:11 ` [RFC 1/8] x86: objtool: use asm macro for better compiler decisions Nadav Amit
2018-05-15 21:37   ` Josh Triplett
2018-05-15 21:53     ` Nadav Amit
2018-05-15 21:55       ` Josh Triplett
2018-05-15 14:11 ` [RFC 2/8] x86: bug: prevent gcc distortions Nadav Amit
2018-05-15 14:11 ` [RFC 3/8] x86: alternative: macrofy locks for better inlining Nadav Amit
2018-05-15 14:11 ` [RFC 4/8] x86: prevent inline distortion by paravirt ops Nadav Amit
2018-05-15 14:11 ` [RFC 5/8] x86: refcount: prevent gcc distortions Nadav Amit
2018-05-16 13:59   ` Kees Cook
2018-05-16 16:37     ` Nadav Amit
2018-05-15 14:11 ` [RFC 6/8] x86: removing unneeded new-lines Nadav Amit
2018-05-15 14:11 ` [RFC 7/8] ilog2: preventing compiler distortion due to big condition Nadav Amit
2018-05-15 14:11 ` [RFC 8/8] bitops: prevent compiler inline decision distortion Nadav Amit
2018-05-15 14:11 ` [RFC 0/8] Improving compiler inlining decisions Nadav Amit
2018-05-15 14:11 ` [RFC 1/8] x86: objtool: use asm macro for better compiler decisions Nadav Amit
2018-05-15 14:11 ` [RFC 2/8] x86: bug: prevent gcc distortions Nadav Amit
2018-05-15 14:11 ` [RFC 3/8] x86: alternative: macrofy locks for better inlining Nadav Amit
2018-05-15 14:11 ` [RFC 4/8] x86: prevent inline distortion by paravirt ops Nadav Amit
2018-05-15 14:11 ` [RFC 5/8] x86: refcount: prevent gcc distortions Nadav Amit
2018-05-16  7:14   ` Jan Beulich
2018-05-16 16:44     ` Nadav Amit [this message]
2018-05-17  7:18       ` Jan Beulich
2018-05-15 14:11 ` [RFC 6/8] x86: removing unneeded new-lines Nadav Amit
2018-05-15 14:11 ` [RFC 7/8] ilog2: preventing compiler distortion due to big condition Nadav Amit
2018-05-15 14:11 ` [RFC 8/8] bitops: prevent compiler inline decision distortion Nadav Amit
2018-05-16 14:09   ` Kees Cook
2018-05-15 22:14 ` [RFC 0/8] Improving compiler inlining decisions Nadav Amit
2018-05-16  3:48 ` Josh Poimboeuf
2018-05-16  4:30   ` Nadav Amit

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=8B7DE95F-5E57-44F0-90E0-CCBA35F98A07@vmware.com \
    --to=namit@vmware.com \
    --cc=JBeulich@suse.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.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).