From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96953 invoked by alias); 14 Jun 2018 13:38:20 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 96688 invoked by uid 89); 14 Jun 2018 13:38:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,SPF_PASS autolearn=ham version=3.3.2 spammy=stress X-HELO: mail.efficios.com DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 5B80F22AC81 Date: Thu, 14 Jun 2018 13:38:00 -0000 From: Mathieu Desnoyers To: Pavel Machek Cc: Florian Weimer , carlos , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Thomas Gleixner , linux-kernel , libc-alpha Message-ID: <956816108.13001.1528983496098.JavaMail.zimbra@efficios.com> In-Reply-To: <20180614132557.GA15201@amd> References: <1084280721.10859.1528746558696.JavaMail.zimbra@efficios.com> <31fc101a-295b-067b-1a82-7e9e509fc92f@redhat.com> <305409897.10888.1528747473727.JavaMail.zimbra@efficios.com> <091061df-3482-8762-30e4-feaf3417be11@redhat.com> <417742741.11550.1528821084084.JavaMail.zimbra@efficios.com> <20180614122759.GB8798@amd> <894222691.12973.1528981314012.JavaMail.zimbra@efficios.com> <20180614132557.GA15201@amd> Subject: Re: Restartable Sequences system call merged into Linux MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-06/txt/msg00403.txt.bz2 ----- On Jun 14, 2018, at 9:25 AM, Pavel Machek pavel@ucw.cz wrote: > Hi! > >> >> >>>> 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, > > Yes, this is not likely to be noticeable. > > But the proposal wanted to add a syscall to thread creation, right? > And I believe that may be noticeable. Fair point! Do we have a standard benchmark that would stress this ? If it ends up being noticeable overhead, I wonder whether we could extend clone() with a new CLONE_RSEQ flag so glibc could pass a pointer to the rseq TLS area through an extra argument to the clone system call rather than do an extra syscall on thread creation ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com