linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Nadav Amit <namit@vmware.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Ingo Molnar <mingo@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	X86 ML <x86@kernel.org>, Sam Ravnborg <sam@ravnborg.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH v8 02/10] Makefile: Prepare for using macros for inline asm
Date: Tue, 2 Oct 2018 07:01:19 +0900	[thread overview]
Message-ID: <CAK7LNAT98KZrMLuypS0PZ4jUWC+uRWyYwHPiEJD6LYoYzndJhA@mail.gmail.com> (raw)
In-Reply-To: <307823F9-DCCF-4384-9FBE-28642FAD6B4E@vmware.com>

Hi.



2018年9月27日(木) 2:57 Nadav Amit <namit@vmware.com>:
>
> at 1:58 AM, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
>
> > On 2018-09-18 23:28, Nadav Amit wrote:
> >
> >> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> >> index 8f6e7eb8ae9f..944fa3bc9376 100644
> >> --- a/arch/x86/Makefile
> >> +++ b/arch/x86/Makefile
> >> @@ -214,8 +214,8 @@ ifdef CONFIG_X86_64
> >> KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
> >> endif
> >>
> >> -# Speed up the build
> >> -KBUILD_CFLAGS += -pipe
> >> +# We cannot use -pipe flag since we give an additional .s file to the compiler
> >> +#KBUILD_CFLAGS += -pipe
> >
> > Is this really necessary? The gas manual says that one can use -- to
> > name stdin, though that's probably a typo and should just be - . Doing
> >
> > gcc -pipe -Wa,foo.s -Wa,-
>
> Good idea. I didn’t think of it. Yes, this can do the trick. I’ll do it in
> v9.
>
> > does seem to work as expected (and would also make it possible to append
> > some .s file should that ever be required).
> >> +archmacros:
> >> +    $(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s
> >> +
> >> +ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
> >> +export ASM_MACRO_FLAGS
> >> +KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)
> > How does this affect what gets rebuilt when one of the asm/foo.h files
> > going into macros.s changes? Does that cause a global rebuild because
> > everything depends on macros.s, or do we still only rebuild the files
> > that actually include asm/foo.h?
>
> There will not be a global rebuild. Any source file that uses the header
> files that are included in macros.S will be rebuilt.
>
> But your question actually raises two issues:
>
> 1. If macros.S changes, there *should* be a global rebuild,


Looking at this series, I can see this rule:
"macros and inline functions that calls them are placed in the same header".


For example,
REFCOUNT_CHECK_LE_ZERO is defined in <asm/refcount.h>,
and REFCOUNT_CHECK_LE_ZERO is invoked via refcount_sub_and_test() etc.
in the same header.

Therefore, all users of REFCOUNT_CHECK_LE_ZERO must have included
<asm/refcount.h>

This means all C files using REFCOUNT_CHECK_LE_ZERO
will be appropriately recompiled as long as the rule above is observed.



> and currently
> there wouldn’t be one. Do you happen to know what would be the appropriate
> way to trigger one?
>
> 2. Someone might mistakenly use the macros through inline assembly without
> including the header file.

Right, it is possible to use REFCOUNT_CHECK_LE_ZERO directly.
If this happens, my assumption breaks.

It would be unlikely to happen, though...


> It would be better to detect such cases and fail
> the build. I may be able to create another asm macro in the C part of the
> header that would cause the build to fail. But let me know if you any
> better idea.
>
> Regards,
> Nadav
>


-- 
Best Regards
Masahiro Yamada

  parent reply	other threads:[~2018-10-01 22:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18 21:28 [PATCH v8 00/10] x86: macrofying inline asm for better compilation Nadav Amit
2018-09-18 21:28 ` [PATCH v8 01/10] xtensa: defining LINKER_SCRIPT for the linker script Nadav Amit
2018-09-18 21:28 ` [PATCH v8 02/10] Makefile: Prepare for using macros for inline asm Nadav Amit
2018-09-26  8:58   ` Rasmus Villemoes
2018-09-26 17:56     ` Nadav Amit
2018-09-27  7:52       ` Rasmus Villemoes
2018-10-01 22:01       ` Masahiro Yamada [this message]
2018-10-03 19:41         ` Nadav Amit
2018-10-02 10:59       ` Ingo Molnar
2018-10-03 19:43         ` hpa
2018-10-03 20:29           ` Nadav Amit
2018-09-18 21:28 ` [PATCH v8 03/10] x86: objtool: use asm macro for better compiler decisions Nadav Amit
2018-09-18 21:28 ` [PATCH v8 04/10] x86: refcount: prevent gcc distortions Nadav Amit
2018-09-18 21:28 ` [PATCH v8 05/10] x86: alternatives: macrofy locks for better inlining Nadav Amit
2018-09-18 21:28 ` [PATCH v8 06/10] x86: bug: prevent gcc distortions Nadav Amit
2018-09-18 21:28 ` [PATCH v8 07/10] x86: prevent inline distortion by paravirt ops Nadav Amit
2018-09-18 21:28 ` [PATCH v8 08/10] x86: extable: use macros instead of inline assembly Nadav Amit
2018-09-18 21:28 ` [PATCH v8 09/10] x86: cpufeature: " Nadav Amit
2018-09-18 21:28 ` [PATCH v8 10/10] x86: jump-labels: " Nadav Amit
2018-09-21 18:26 ` [PATCH v8 00/10] x86: macrofying inline asm for better compilation Kees Cook

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=CAK7LNAT98KZrMLuypS0PZ4jUWC+uRWyYwHPiEJD6LYoYzndJhA@mail.gmail.com \
    --to=yamada.masahiro@socionext.com \
    --cc=hpa@zytor.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=michal.lkml@markovi.net \
    --cc=mingo@redhat.com \
    --cc=namit@vmware.com \
    --cc=sam@ravnborg.org \
    --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).