Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2267525imd; Fri, 2 Nov 2018 08:34:12 -0700 (PDT) X-Google-Smtp-Source: AJdET5e9rzsp3AT2wr7noLCaAO5jjhVu7DutmdwoxIesY2+GGzZLUz4ZNJQIumTRium3gSs0+3IW X-Received: by 2002:a65:5347:: with SMTP id w7-v6mr11605300pgr.17.1541172852078; Fri, 02 Nov 2018 08:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541172852; cv=none; d=google.com; s=arc-20160816; b=LAK6g3+JJCwnlybNDG57lus6GwB2df2uZxBXQoHsSb8ffDLwpAjeP4LytxHXKtwGig NDOu7IPH2eQvACRI1WjvGjsHTPwZ9qIsMB/CdwcW4m8jSBJ9wZHFGIbf6eH49jgMVOLN e6ietQRGlgzqRGrPVG3SejzYNGWwTIXsP37iPlnBN02kk95ZObeJZv3JhIOX982Cn6yI oIEotXiy0mhp7Oj/nRBKs6xF6dy5T/1RS8meKkDLBYy7wQXWmYzlb55yzKIZh5uB79gy 1sTbvPsuMEe4Brw+TIQO23UyyDvh8vB0jH5bIF8o+T9mBokJbgkXAZaPlQqUa5SlOJGg X1OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=l2u2aEDIyckpCLSwkKofB5l1GyyNvORkoByDMOObBD8=; b=YySX0xaj9PZRzxabJ0mG/a8lsfjtDHh0ipy8dBFfeUh38uJTwAuMhUWKF8PfJ5LWy8 wOQg3GnbkdCt9h+b37wgQG59+PpA0q1rPxEmrXTpNbjS2JdaGMPM/fpLjoZzu9uIi3lr ltP9iApbePXbH+/MS7OWfnFWRieWQAU92EaMQAmjJRgamV5R/jJdV2x9Pgb1KlavrQ10 Wd1QzG8E2/90lG1GGsn5g4iSG6J+379g+RpZQ/yOW4UPQZwuaO+X/Qp1BAHNVJsL7OOT ppcxofvQ5z2HY1P5ppK8K4mZTb8WCylo0hOoH8WCxCxaDag0ni7GCF+AiK3qtQ8tnvh1 SgBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=RlhlTkPn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14-v6si12830107pga.422.2018.11.02.08.33.56; Fri, 02 Nov 2018 08:34:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=RlhlTkPn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727803AbeKCAko (ORCPT + 99 others); Fri, 2 Nov 2018 20:40:44 -0400 Received: from mail.efficios.com ([167.114.142.138]:54552 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbeKCAko (ORCPT ); Fri, 2 Nov 2018 20:40:44 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 60F63238983; Fri, 2 Nov 2018 11:33:15 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id lSSCUvp35teg; Fri, 2 Nov 2018 11:33:14 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id C4604238980; Fri, 2 Nov 2018 11:33:14 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com C4604238980 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1541172794; bh=l2u2aEDIyckpCLSwkKofB5l1GyyNvORkoByDMOObBD8=; h=Date:From:To:Message-ID:MIME-Version; b=RlhlTkPnO/UHE/ZWJ5l2HWl13z/Kv9zTS5rhbjJPA/IWorhiYoRsgw8OC3r5ayU0p 0t9CnAkwLzu2t/bPnxWis8cLn70/2gSiaubO0Op2/yoWallG8kO6xK1Hadz/tPJ1mQ v4FsAznivWHLzUmNdTSxt4bhX18eF75/qJFfTVOEafI5HpDOTEs/6iGxGTLdM/QrCy PI0l/EhNs2BwJIfCowqFllo0Io5a0i/8CnuWhjSZ9YNZP34eTqJAlEkvWwKB5GdwHj RUYkTC3IKtdosIand6zoKkCFpwsAYHZv1HI9pwZrqpmGgHyCN5kFyjCvIViG25AM04 ZUfH6ZAKnEx8g== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id fXq2aTEBbNYM; Fri, 2 Nov 2018 11:33:14 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id A52B6238972; Fri, 2 Nov 2018 11:33:14 -0400 (EDT) Date: Fri, 2 Nov 2018 11:33:14 -0400 (EDT) From: Mathieu Desnoyers To: Andy Lutomirski Cc: libc-alpha , carlos , Florian Weimer , Joseph Myers , Szabolcs Nagy , Thomas Gleixner , Ben Maurer , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Will Deacon , Dave Watson , Paul Turner , linux-kernel , linux-api Message-ID: <1563326093.34.1541172794537.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20181102115259.11383-1-mathieu.desnoyers@efficios.com> Subject: Re: [RFC PATCH 1/2] glibc: Perform rseq(2) registration at nptl init and thread creation (v3) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.10_GA_3047 (ZimbraWebClient - FF52 (Linux)/8.8.10_GA_3041) Thread-Topic: glibc: Perform rseq(2) registration at nptl init and thread creation (v3) Thread-Index: cuSXnMD5lxR2dOHBtiUiNw7Wk9xNFA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Nov 2, 2018, at 4:20 PM, Andy Lutomirski luto@amacapital.net wrote: > On Fri, Nov 2, 2018 at 4:53 AM Mathieu Desnoyers > wrote: >> >> Here is a third round of prototype registering rseq(2) TLS for each >> thread (including main), and unregistering for each thread (excluding >> main). "rseq" stands for Restartable Sequences. >> >> Remaining open questions: >> >> - How early do we want to register rseq and how late do we want to >> unregister it ? It's important to consider if we expect rseq to >> be used by the memory allocator and within destructor callbacks. >> However, we want to be sure the TLS (__thread) area is properly >> allocated across its entire use by rseq. >> >> - We do not need an atomic increment/decrement for the refcount per >> se. Just being atomic with respect to the current thread (and nested >> signals) would be enough. What is the proper API to use there ? >> >> See the rseq(2) man page proposed here: >> https://lkml.org/lkml/2018/9/19/647 >> > > Merely having rseq registered carries some small but nonzero overhead, > right? There is indeed a small overhead at thread creation/exit (total of 2 system calls) and one system call in nptl init. Once registered, there is very small, infrequent, a hard to measure overhead at thread preemption and signal delivery. > Should this perhaps live in a librseq.so or similar (possibly > built as part of libc) to avoid the overhead for programs that don't > use it? My second patch modifies sched_getcpu() to use rseq. Another use-case glibc guys want is to use rseq for malloc(). Once that is done, there will be pretty much no program left using glibc facilities that won't use rseq when available. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com