[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v3 0/4] tls: add macros for coroutine-safe TLS variables
From: |
Peter Maydell |
Subject: |
Re: [RFC v3 0/4] tls: add macros for coroutine-safe TLS variables |
Date: |
Tue, 7 Dec 2021 13:55:34 +0000 |
On Tue, 7 Dec 2021 at 13:53, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> On Mon, Dec 06, 2021 at 02:34:45PM +0000, Peter Maydell wrote:
> > On Mon, 6 Dec 2021 at 14:33, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> > >
> > > v3:
> > > - Added __attribute__((weak)) to get_ptr_*() [Florian]
> >
> > Do we really need it *only* on get_ptr_*() ? If we need to
> > noinline the other two we probably also should use the same
> > attribute weak to force no optimizations at all.
>
> The weak attribute can't be used on static functions, so I think we need
> a different approach:
>
> In file included from ../util/async.c:35:
> /builds/stefanha/qemu/include/qemu/coroutine-tls.h:201:11: error: weak
> declaration of 'get_ptr_my_aiocontext' must be public
> type *get_ptr_##var(void)
> \
> ^~~~~~~~
> ../util/async.c:673:1: note: in expansion of macro 'QEMU_DEFINE_STATIC_CO_TLS'
> QEMU_DEFINE_STATIC_CO_TLS(AioContext *, my_aiocontext)
> ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> Adding asm volatile("") seems to work though:
> https://godbolt.org/z/3hn8Gh41d
You can see in the clang disassembly there that this isn't
sufficient. The compiler puts in both calls, but it ignores
the return results and always returns "true" from the function.
-- PMM
- [RFC v3 0/4] tls: add macros for coroutine-safe TLS variables, Stefan Hajnoczi, 2021/12/06
- [RFC v3 1/4] tls: add macros for coroutine-safe TLS variables, Stefan Hajnoczi, 2021/12/06
- [RFC v3 3/4] rcu: use coroutine TLS macros, Stefan Hajnoczi, 2021/12/06
- [RFC v3 2/4] util/async: replace __thread with QEMU TLS macros, Stefan Hajnoczi, 2021/12/06
- [RFC v3 4/4] cpus: use coroutine TLS macros for iothread_locked, Stefan Hajnoczi, 2021/12/06
- Re: [RFC v3 0/4] tls: add macros for coroutine-safe TLS variables, Peter Maydell, 2021/12/06