qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki@gmail.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>,
	Christian Schoenebeck <qemu_oss@crudebyte.com>,
	qemu Developers <qemu-devel@nongnu.org>
Subject: Re: [PATCH 2/4] osdep: Un-inline qemu_thread_jit_execute/write
Date: Tue, 15 Feb 2022 22:09:17 +0900	[thread overview]
Message-ID: <CAMVc7JViZmmeMyXMvXqhtLJuvSku0goFHYgLUHMafbdR5viq3g@mail.gmail.com> (raw)
In-Reply-To: <20220215120625.64711-3-f4bug@amsat.org>

On Tue, Feb 15, 2022 at 9:06 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> qemu_thread_jit_execute() and qemu_thread_jit_write() call
> pthread_jit_write_protect_np() which is declared in "pthread.h".
> Since we don't want all C files to preprocess unused headers,
> avoid adding yet another header here and move the function
> definitions to osdep.c, un-inlining them.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/qemu/osdep.h | 17 ++---------------
>  util/osdep.c         | 20 ++++++++++++++++++++
>  2 files changed, 22 insertions(+), 15 deletions(-)
>
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 1e7a002339..785884728b 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -773,21 +773,8 @@ size_t qemu_get_host_physmem(void);
>   * Toggle write/execute on the pages marked MAP_JIT
>   * for the current thread.
>   */
> -#if defined(MAC_OS_VERSION_11_0) && \
> -    MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
> -static inline void qemu_thread_jit_execute(void)
> -{
> -    pthread_jit_write_protect_np(true);
> -}
> -
> -static inline void qemu_thread_jit_write(void)
> -{
> -    pthread_jit_write_protect_np(false);
> -}
> -#else
> -static inline void qemu_thread_jit_write(void) {}
> -static inline void qemu_thread_jit_execute(void) {}
> -#endif
> +void qemu_thread_jit_execute(void);
> +void qemu_thread_jit_write(void);
>
>  /**
>   * Platforms which do not support system() return ENOSYS
> diff --git a/util/osdep.c b/util/osdep.c
> index 42a0a4986a..b228a53612 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -124,6 +124,26 @@ int qemu_mprotect_none(void *addr, size_t size)
>  #endif
>  }
>
> +static void qemu_pthread_jit_write_protect(bool enabled)
> +{
> +#if defined(MAC_OS_VERSION_11_0) \
> +        && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
> +    if (__builtin_available(macOS 11.0, *)) {
> +        pthread_jit_write_protect_np(enabled);
> +    }
> +#endif
> +}
> +
> +void qemu_thread_jit_execute(void)
> +{
> +    qemu_pthread_jit_write_protect(true);
> +}
> +
> +void qemu_thread_jit_write(void)
> +{
> +    qemu_pthread_jit_write_protect(false);
> +}
> +
>  #ifndef _WIN32
>
>  static int fcntl_op_setlk = -1;
> --
> 2.34.1
>

Is this for compile-time reduction? If so, it would be nice if you
provide some numbers. It should have some explanation of the advantage
otherwise.


  reply	other threads:[~2022-02-15 13:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 12:06 [RFC PATCH 0/4] buildsys: More fixes to use GCC on macOS Philippe Mathieu-Daudé via
2022-02-15 12:06 ` [RFC PATCH 1/4] osdep: Avoid using Clang-specific __builtin_available() Philippe Mathieu-Daudé via
2022-02-15 12:06 ` [PATCH 2/4] osdep: Un-inline qemu_thread_jit_execute/write Philippe Mathieu-Daudé via
2022-02-15 13:09   ` Akihiko Odaki [this message]
2022-02-15 13:29     ` Philippe Mathieu-Daudé via
2022-02-15 12:06 ` [RFC PATCH 3/4] audio: Rename coreaudio extension to use Objective-C compiler Philippe Mathieu-Daudé via
2022-02-15 13:37   ` Christian Schoenebeck
2022-02-15 12:06 ` [RFC PATCH 4/4] ui/cocoa: Ignore 'initializer overrides' warnings Philippe Mathieu-Daudé via
2022-02-15 12:34   ` Peter Maydell
2022-02-15 13:19     ` Akihiko Odaki
2022-02-15 13:23       ` Philippe Mathieu-Daudé via
2022-02-15 13:18   ` Christian Schoenebeck
2022-02-15 13:45     ` Peter Maydell
2022-02-15 14:06       ` Philippe Mathieu-Daudé via
2022-02-15 14:11       ` Christian Schoenebeck
2022-02-15 14:17         ` Peter Maydell
2022-02-15 13:06 ` [RFC PATCH 0/4] buildsys: More fixes to use GCC on macOS Akihiko Odaki
2022-02-15 13:25   ` Philippe Mathieu-Daudé via
2022-02-16  2:28     ` Akihiko Odaki

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=CAMVc7JViZmmeMyXMvXqhtLJuvSku0goFHYgLUHMafbdR5viq3g@mail.gmail.com \
    --to=akihiko.odaki@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=r.bolshakov@yadro.com \
    /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).