From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Florian Weimer <fweimer@redhat.com>, carlos <carlos@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Boqun Feng <boqun.feng@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel <linux-kernel@vger.kernel.org>,
libc-alpha <libc-alpha@sourceware.org>
Subject: Re: Restartable Sequences system call merged into Linux
Date: Thu, 14 Jun 2018 09:01:54 -0400 (EDT) [thread overview]
Message-ID: <894222691.12973.1528981314012.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20180614122759.GB8798@amd>
----- On Jun 14, 2018, at 8:27 AM, Pavel Machek pavel@ucw.cz wrote:
> On Tue 2018-06-12 12:31:24, Mathieu Desnoyers wrote:
>> ----- On Jun 12, 2018, at 9:11 AM, Florian Weimer fweimer@redhat.com wrote:
>>
>> > On 06/11/2018 10:04 PM, Mathieu Desnoyers wrote:
>> >> ----- On Jun 11, 2018, at 3:55 PM, Florian Weimer fweimer@redhat.com wrote:
>> >>
>> >>> On 06/11/2018 09:49 PM, Mathieu Desnoyers wrote:
>> >>>> It should be noted that there can be only one rseq TLS area registered per
>> >>>> thread,
>> >>>> which can then be used by many libraries and by the executable, so this is a
>> >>>> process-wide (per-thread) resource that we need to manage carefully.
>> >>>
>> >>> Is it possible to resize the area after thread creation, perhaps even
>> >>> from other threads?
>> >>
>> >> I'm not sure why we would want to resize it. The per-thread area is fixed-size.
>> >> Its layout is here: include/uapi/linux/rseq.h: struct rseq
>> >
>> > Looks I was mistaken and this is very similar to the robust mutex list.
>> >
>> > Should we treat it the same way? Always allocate it for each new thread
>> > and register it with the kernel?
>>
>> That would be an efficient way to do it, indeed. There is very little
>> performance overhead to have rseq registered for all threads, whether or
>> not they intend to run rseq critical sections.
>
> People with slow / low memory machines would prefer not to see
> overhead they don't need...
In terms of memory usage, if people don't want the extra few bytes of memory
used by rseq in the kernel, they should use CONFIG_RSEQ=n.
In terms of overhead, let's have a closer look at what it means: when a thread
is registered to rseq, but does not enter rseq critical sections, only this
extra work is done by the kernel:
- rseq_preempt(): on preemption, the scheduler sets the TIF_NOTIFY_RESUME thread
flag, so rseq_handle_notify_resume() can check whether it's in a rseq critical
section when returning to user-space,
- rseq_signal_deliver(): on signal delivery, rseq_handle_notify_resume() checks
whether it's in a rseq critical section,
- rseq_migrate: on migration, the scheduler sets TIF_NOTIFY_RESUME as well,
>
>> I have a few possible approaches in mind (feel free to suggest other
>> options):
>>
>> A) glibc exposes a strong __rseq_abi TLS symbol:
>>
>> - should ideally *not* be global-dynamic for performance reasons,
>> - registration to kernel can either be handled explicitly by requiring
>> application or libraries to call an API, or implicitly at thread
>> creation,
>
> ...so I'd prefer explicit API call.
I have use-cases where a library wants to link against librseq and have rseq
critical sections, without requiring the application to explicitly add rseq
registration calls on thread creation/destruction. Is there a way to register
callbacks to glibc which could be invoked on thread creation/destruction ?
Then if we include dynamic loading of libraries (dlopen/dlclose) in the
picture, this gets even worse, as we'd need to be able to iterate on all
existing threads to invoke registration/unregistration callbacks.
One alternative approach would be to let the user library lazily register rseq
when needed, and use a pthread_key for unregistration. However, this does not
allow dlclose of the user library without figuring a way to iterate on all
threads.
Another alternative would be to somehow let glibc handle the registration,
perhaps only doing it for applications expressing their interest for rseq.
Thoughts ?
Thanks,
Mathieu
>
>> B) librseq.so exposes a strong __rseq_abi symbol:
>
> Works for me.
> Pavel
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures)
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2018-06-14 13:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-11 19:49 Restartable Sequences system call merged into Linux Mathieu Desnoyers
2018-06-11 19:55 ` Florian Weimer
2018-06-11 20:04 ` Mathieu Desnoyers
2018-06-12 13:11 ` Florian Weimer
2018-06-12 16:31 ` Mathieu Desnoyers
2018-06-13 8:21 ` Florian Weimer
2018-06-14 12:27 ` Pavel Machek
2018-06-14 13:01 ` Mathieu Desnoyers [this message]
2018-06-14 13:25 ` Pavel Machek
2018-06-14 13:32 ` Florian Weimer
2018-06-14 13:46 ` Mathieu Desnoyers
2018-06-15 5:10 ` Florian Weimer
2018-06-15 17:44 ` Mathieu Desnoyers
2018-06-14 13:38 ` Mathieu Desnoyers
2018-06-14 13:49 ` Pavel Machek
2018-06-14 14:00 ` Florian Weimer
2018-06-14 14:36 ` Mathieu Desnoyers
2018-06-14 14:41 ` Florian Weimer
2018-06-14 15:09 ` Mathieu Desnoyers
2018-06-15 5:09 ` Florian Weimer
2018-06-15 17:50 ` Mathieu Desnoyers
2018-06-15 5:07 ` Florian Weimer
2018-06-13 11:48 ` Heiko Carstens
2018-06-13 16:14 ` Mathieu Desnoyers
2018-06-13 19:53 ` Mathieu Desnoyers
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=894222691.12973.1528981314012.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=boqun.feng@gmail.com \
--cc=carlos@redhat.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pavel@ucw.cz \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.