Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1960616imm; Thu, 14 Jun 2018 06:40:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ9TsiFhGmEBNA8H9Lsq8Xy7jp+klTyAG8k3fR46BuZYFt+MWKJnbboIKtZ8rlDtJ8pA66V X-Received: by 2002:a63:3e83:: with SMTP id l125-v6mr2412098pga.355.1528983640347; Thu, 14 Jun 2018 06:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528983640; cv=none; d=google.com; s=arc-20160816; b=s3YOdSh7/nXBvlR2zr3tzOmBqOaPsQ+Up1VO8D4f/FroMpHZLdyHjQRH0PKkXUPOu8 5iyYZH/ukpxI9Q8ehUDxO3KWZ88oKATdmC3ftyK4pMhbaXPgQH1DlqYtoFUC+KIUfstV SxzwAZZY5X9jOA+LCF+cB2bep19/6aWE4wXx+swpYBBnouffORqfkkzuUryjMpbt/xQy JBAd6CrKWM74Fq4BPPWLKPJveDZzhKNSrxbQ1gGsfTLhathOrB5GEedtzpn04MQyDren ED8PvOaHXFmhwbGcvRpL5s0PykcM57gvh2FCU5sIq4tgN8EQIrp5Y3kBYv0c0+ijab7N Ihcg== 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 :arc-authentication-results; bh=2WFIOTylXb5yE1NqibIT6AU0/0Gh7zgova97vb1rxsw=; b=pJ4XzELpHIYc8Pz6DbBioWyopGq2D2aQBGHhwju6PTvdMwqFyN/KQeroX3CtswFXd3 Y+4TremNnRPCQNTLsAHfezUzq1flx+UJzJjHBTVwNE4hLQzJL6TcdIK2lVwVOnAPRZcy Dxl3xv8rbVPBRWJKVgTZrdnYm+rld1MIS/oPFUVPXjO+dxrlIOudfx8q0g+z1WgM+xgl tKcPznRGkViOskZotpztss8NwoQQtcKRgN9GaDJ93rgVdlsoQHd/E3wJO0SxefEFteUh 3KL7V3+27A+DToyA7qxAV9sp8QuTD/EqefUC2b0V8uWX2arf/1eMOYO5L9nlaQ6GRRDV RLBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=STc7+x+Z; 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 x13-v6si5397912pln.62.2018.06.14.06.40.25; Thu, 14 Jun 2018 06:40:40 -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=STc7+x+Z; 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 S1755341AbeFNNi3 (ORCPT + 99 others); Thu, 14 Jun 2018 09:38:29 -0400 Received: from mail.efficios.com ([167.114.142.138]:42842 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755118AbeFNNiR (ORCPT ); Thu, 14 Jun 2018 09:38:17 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id E358322AC88; Thu, 14 Jun 2018 09:38:16 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 53WxAswG-EQO; Thu, 14 Jun 2018 09:38:16 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 5B80F22AC81; Thu, 14 Jun 2018 09:38:16 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 5B80F22AC81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1528983496; bh=2WFIOTylXb5yE1NqibIT6AU0/0Gh7zgova97vb1rxsw=; h=Date:From:To:Message-ID:MIME-Version; b=STc7+x+ZxbiOzq00KO7DE/xAmHkGe8i5KTjQsOiQBFmUzbo4ZriMTjwJVGem07uve Ayf0twwRoCCDFVQo8Dvdh9+0PvhwJknLb2rKUjILAE1V8id9sGd3WvBy3FBLBqY/OK bSUk311orIpyk48CUzzrwV/uajtITYTAV577Di4EtOhjnF5z+8SY1Kf39/tTO0/D5f pykhLqnSuzh3BRQaANg1dnkGxYlM9Z2mk63HDXrKVghx9Wos012wYoVqk25AbDsS86 K2SV4A5/kNFAutTF62qYMFaUPMGbjXzTcU/iRaO7LWag1cRIle19Cscmoy6WYclWh/ PYmY6mrVY5W1Q== 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 TJffIp0APlxC; Thu, 14 Jun 2018 09:38:16 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 4574622AC79; Thu, 14 Jun 2018 09:38:16 -0400 (EDT) Date: Thu, 14 Jun 2018 09:38:16 -0400 (EDT) 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-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.8_GA_2096 (ZimbraWebClient - FF52 (Linux)/8.8.8_GA_1703) Thread-Topic: Restartable Sequences system call merged into Linux Thread-Index: x2sRYZdO/gYUWkrSQC4dTHI8XgNdQQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- 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