Received: by 10.223.164.202 with SMTP id h10csp267875wrb; Tue, 14 Nov 2017 15:04:39 -0800 (PST) X-Google-Smtp-Source: AGs4zMYXVI8kU1V5cEViIsTcFLjIWBWVzyfRGliD6lhY1GHxLaR/8F0NNGJchS+KTbmfZKdy8S9x X-Received: by 10.99.178.77 with SMTP id t13mr13747952pgo.219.1510700678986; Tue, 14 Nov 2017 15:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510700678; cv=none; d=google.com; s=arc-20160816; b=SuyIgwcClalqenL1ERbVg6FXtqzQMsWH1yY0OAn+V+hycN9fNuznzVIghiv3F43do5 ra6nU6r4wYkCpAw7E+Ptwut0tLI/Enl3cbwAralvgPKXBJXCc9h/Z//ob36SMw2oCJqK sxGpDxZTy28Q9YaW5POFXNPPMV/jUXpoqGo+CROaV8UO352juZmO2SteMcrACBmvknWa 3XyaQvEyvze/BUUo3ZuSO85fZrBMBK4lYvOCdDyNPwdS0nDEJaKSvDqqDlkYDbsZmt6M w65DhiA3suaazQc90InCQziqzqaU61LBRbXyUerg4d6Q7i/ZWP62rdaX1r1mEFCfcKD3 y5aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-signature :arc-authentication-results; bh=NroF8Nyhbu1Z31voA2XPzpRoT0PhMFJ7L9A9/BxOwrg=; b=UIE3akVFVb895JdFVoBWcuWy18gteomyiIJl/YD5daT/w2fr6a7ciopAuGlPo6ErQG ug68o9WYUWdOr7T2SqMuLqEvFwiwHSnUaz6WKYGNaRSkf6jbUVsYeE46Vl3GX8bqwtx9 mQto/gOPeJcaFV3WWBq+RfG9hxL2s3qBXZUAyNDRRn/QvnrXcwQE7+OXW9jyXVS04kqh tjyTXYABVppnY/0PfaW4yj1XglAcd9Q6JKgu9qIzYsC8GVrJSobiCOIi0cHCi11SxBeL TRY/K0Puxn4b2y6SknT6HCpVVRQcp80V+xJFkFDI7y7WuNHXa1sfKaLJPgpgpD3ZUvp3 XeBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=aN6GEu5M; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=Lo8PfrB4; 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=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si17101612plm.80.2017.11.14.15.04.26; Tue, 14 Nov 2017 15:04:38 -0800 (PST) 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=@fb.com header.s=facebook header.b=aN6GEu5M; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=Lo8PfrB4; 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=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756681AbdKNUxi (ORCPT + 88 others); Tue, 14 Nov 2017 15:53:38 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:55806 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756630AbdKNUxc (ORCPT ); Tue, 14 Nov 2017 15:53:32 -0500 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAEKimUa011842; Tue, 14 Nov 2017 12:49:59 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=facebook; bh=NroF8Nyhbu1Z31voA2XPzpRoT0PhMFJ7L9A9/BxOwrg=; b=aN6GEu5MoIycUgc6mwtiNgIiT17jxpopLBuo9sLrqNsEpBIIKB/Sq8XITz65W5hDsCeQ HmlnryiZzPUu6hzLhwCXRAWIooX0jZ5IzEBDUtnQE59W8FJyC6D7GG6aaxNfXKRx05GN +BndSevReuVSFvl8aR/HVftxz/7wnguThBk= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2e84v5rq5k-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 14 Nov 2017 12:49:59 -0800 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.13) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 14 Nov 2017 12:49:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=NroF8Nyhbu1Z31voA2XPzpRoT0PhMFJ7L9A9/BxOwrg=; b=Lo8PfrB4LoIKNwiAIl6lECFCv9ANVxdSML+3VB5J4B9m269lzulhDOejZ8h1NsHYEAN/Vl5E0URvvtu4kojFDGp/z1Ilt3SchLPO25qRZ8aKDWlvsAvT1PPeMV75eO1Cu8sE8N/YYLec2pbwmosCOjBEKrLl90QiFx9iwz7yE+M= Received: from CY4PR15MB1688.namprd15.prod.outlook.com (10.175.121.17) by CY4SPR00MB057.namprd15.prod.outlook.com (10.173.60.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12; Tue, 14 Nov 2017 20:49:54 +0000 Received: from CY4PR15MB1688.namprd15.prod.outlook.com ([10.175.121.17]) by CY4PR15MB1688.namprd15.prod.outlook.com ([10.175.121.17]) with mapi id 15.20.0218.015; Tue, 14 Nov 2017 20:49:54 +0000 From: Ben Maurer To: Mathieu Desnoyers , Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson CC: "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Alexander Viro Subject: Re: [RFC PATCH v11 for 4.15 01/24] Restartable sequences system call Thread-Topic: [RFC PATCH v11 for 4.15 01/24] Restartable sequences system call Thread-Index: AQHTXYPhmIqd6HY5PUe1T5SV8sIkp6MUVpZlgAAB7cA= Date: Tue, 14 Nov 2017 20:49:54 +0000 Message-ID: References: <20171114200414.2188-1-mathieu.desnoyers@efficios.com>,<20171114200414.2188-2-mathieu.desnoyers@efficios.com>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2620:10d:c090:200::4:8b60] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4SPR00MB057;20:N0RgaQZEuIjVPPj89ujdfEq8OXzjnQAq8Cvbn1Pkx4rk9TQf1cdbTemOlR/YvWS0V5VghnMN5WfohsG5/hSgT+/6sCOu1kAI5b/31ZER9gh6Yv+Nj0iP70Vc94n86R42GuI+6SlZp/3YrmVw0peO38V8ByzsIhjVFtSKPsgmaDk= x-ms-office365-filtering-correlation-id: 1fea9f05-a8ce-49ba-0903-08d52ba14258 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199);SRVR:CY4SPR00MB057; x-ms-traffictypediagnostic: CY4SPR00MB057: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(11241501159)(6040450)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(3231022)(6041248)(20161123562025)(20161123560025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4SPR00MB057;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4SPR00MB057; x-forefront-prvs: 04916EA04C x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(376002)(346002)(199003)(189002)(53936002)(97736004)(54906003)(6506006)(6436002)(110136005)(39060400002)(99286004)(68736007)(54356999)(2950100002)(9686003)(229853002)(6116002)(25786009)(50986999)(4326008)(6246003)(14454004)(76176999)(316002)(55016002)(102836003)(7416002)(305945005)(7696004)(33656002)(8936002)(101416001)(105586002)(7736002)(77096006)(3660700001)(106356001)(3280700002)(8676002)(478600001)(74316002)(5660300001)(6636002)(81166006)(2906002)(86362001)(81156014)(2940100002)(189998001)(2900100001)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4SPR00MB057;H:CY4PR15MB1688.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 1fea9f05-a8ce-49ba-0903-08d52ba14258 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Nov 2017 20:49:54.2306 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4SPR00MB057 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-14_10:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (apologies for the duplicate email, the previous one bounced as it was acci= dentally using HTML formatting) If I understand correctly this is run on every context switch so we probabl= y want to make it really fast > +static int rseq_need_restart(struct task_struct *t, uint32_t cs_flags) > +{ > + bool need_restart =3D false; > + uint32_t flags; > + > + /* Get thread flags. */ > + if (__get_user(flags, &t->rseq->flags)) > + return -EFAULT; > + > + /* Take into account critical section flags. */ > + flags |=3D cs_flags; > + > + /* > + * Restart on signal can only be inhibited when restart on > + * preempt and restart on migrate are inhibited too. Otherwise, > + * a preempted signal handler could fail to restart the prior > + * execution context on sigreturn. > + */ > + if (flags & RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL) { > + if (!(flags & RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE)) > + return -EINVAL; > + if (!(flags & RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT)) > + return -EINVAL; > + } How does this error even get to userspace? Is it worth doing this switch on= every execution? > + if (t->rseq_migrate > + && !(flags & RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE)) > + need_restart =3D true; > + else if (t->rseq_preempt > + && !(flags & RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT)) > + need_restart =3D true; > + else if (t->rseq_signal > + && !(flags & RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL)) > + need_restart =3D true; This could potentially be sped up by having the rseq_* fields in t use a si= ngle bitmask with the same bit offsets as RSEQ_CS_FLAG_NO_* then using bit = operations to check the appropriate overlap.= From 1584079687118467427@xxx Tue Nov 14 21:48:32 +0000 2017 X-GM-THRID: 1584073814600987930 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread