public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Leonardo Bras" <leobras@redhat.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>,
	"Oleg Nesterov" <oleg@redhat.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Teo Couprie Diaz" <teo.coupriediaz@arm.com>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Guo Hui" <guohui@uniontech.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v1 1/1] arm64: add compile-time test into is_compat_task()
Date: Thu, 04 Jan 2024 21:43:56 +0100	[thread overview]
Message-ID: <8412ce8a-7016-4f65-99d3-ce472a75d8cd@app.fastmail.com> (raw)
In-Reply-To: <20240104192433.109983-2-leobras@redhat.com>

On Thu, Jan 4, 2024, at 20:24, Leonardo Bras wrote:
> Currently some parts of the codebase will test for CONFIG_COMPAT before
> testing is_compat_task(), probably in order to avoid a run-time test into
> the task structure, while other parts of codebase will just test even when
> the option is not compiled in.
>
> Since is_compat_task() is an inlined function, it would be helpful to add a
> !CONFIG_COMPAT version of the helper, allowing compile-time optimization.
>
> With this, the compiler is able to understand in build-time that
> is_compat_task() will always return 0, and optimize-out some of the extra
> code introduced by the option.
>
> This allows optimizing-out code when the option is not selected, and
> otherwise removing a lot #ifdefs that were introduced, making the code
> more clean.
>
> Signed-off-by: Leonardo Bras <leobras@redhat.com>

This looks like a useful cleanup to me, with one change:

> ---
>  arch/arm64/include/asm/compat.h | 5 +++++
>  arch/arm64/kernel/ptrace.c      | 6 ++----
>  arch/arm64/kernel/syscall.c     | 5 +----
>  3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
> index ae904a1ad5293..3cc61cbbb9062 100644
> --- a/arch/arm64/include/asm/compat.h
> +++ b/arch/arm64/include/asm/compat.h
> @@ -100,6 +100,11 @@ long compat_arm_syscall(struct pt_regs *regs, int scno);
> 
>  #else /* !CONFIG_COMPAT */
> 
> +static inline int is_compat_task(void)
> +{
> +	return 0;
> +}
> +

I think this bit is not even needed as long as users
include linux/compat.h rather than asm/compat.h, as there
is already a macro definition in the common file:

 #define is_compat_task() (0)


    Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-01-04 20:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04 19:24 [RFC PATCH v1 1/1] arm64: add compile-time test into is_compat_task() Leonardo Bras
2024-01-04 20:43 ` Arnd Bergmann [this message]
2024-01-05  1:16   ` Leonardo Bras

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=8412ce8a-7016-4f65-99d3-ce472a75d8cd@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=ardb@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=guohui@uniontech.com \
    --cc=leobras@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=oleg@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=teo.coupriediaz@arm.com \
    --cc=will@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