Received: by 10.192.165.148 with SMTP id m20csp953648imm; Wed, 2 May 2018 11:27:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrkaqyamnAO5R9MX/XOkGdzl9WFqsNFf93y+izbeI8DOV9wO8vBST9kqYKdA1NMY3LP5m1l X-Received: by 10.98.231.16 with SMTP id s16mr20393355pfh.227.1525285679054; Wed, 02 May 2018 11:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525285679; cv=none; d=google.com; s=arc-20160816; b=tczhU0ju2VkNWa02DoF9gTz4DqSrnwEYz5A7Ar+xfpNmdMNR4zv2Qcl5h0C5mVreOm lWTvBjAqWUtUPwyv2RCzqJwGrfuFtIzEV4grio6bXeWtwdYUSSr3hgWgTG+pTUk1Ek/0 pMb9zimZSQu71YJB9YeSYU10adbK4pa0EDikm06YbJE8A0gUWHtUg8er5Ha5nxgnmSaF 15IUK3NnNx3aY1XTIqEX+ow9l5gf4mhIpYNLwhH2fjFLQrSRldjehNY9rhv3xsOdyJgq 4al7gBFOA8flYFKp6WtFUKhBiL90Zkd3iJ6H6EnE6QyZA5rCtEJ4cUDqU14Aw2C7nE/U RhNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=JmRPLHEp9s+e9jCfJoFmuvjBgSdf3XKacZcCrInYhKs=; b=uhQpeZi8QDiBb/ChgjpKuBeOBy297awzmm0XNVj1ucPkq3qXww4JHK7KRpB3c3VAGe 8BTrUNI87cEZb21y+gfJampynS4vsBDvGb27t1Ez4IgiPOKOiiOR8utLptmUvU3kj+7R FiJag0ifP8A68jnO6GksxhSbaoO8S2WViz8rFGkAQu4vOvJS8GnngQrIM5Pf+oig4TM8 PjtCEQBv8VKdfrCc0scGvPKNqUlIGPzwvMhJhCJmxVbjNpCJSDlxfRNovbdSdSb37kIb 20rjgk2f9Fua6jqA1uGrcGOWNAHQxgrBHbpJ9gCa9Nf2B/Jki2tiIF6nrvoE8VYwVTB2 0Xfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BI3xbDv9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14-v6si10026656pgo.286.2018.05.02.11.27.43; Wed, 02 May 2018 11:27:59 -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=@google.com header.s=20161025 header.b=BI3xbDv9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017AbeEBS1h (ORCPT + 99 others); Wed, 2 May 2018 14:27:37 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:45573 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751986AbeEBS1e (ORCPT ); Wed, 2 May 2018 14:27:34 -0400 Received: by mail-io0-f194.google.com with SMTP id c9-v6so12265455iob.12 for ; Wed, 02 May 2018 11:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JmRPLHEp9s+e9jCfJoFmuvjBgSdf3XKacZcCrInYhKs=; b=BI3xbDv9Wzzk+S1pWPSg/9RbROSv9BrpgIQMGzrqR8hMLcVAdCwk99VDBzzT8s7Um2 6EWQjff49NpYnO5mdFAj78sgLEEicDbHjxNz5jWc36AkTIzELdJKn1GAELjcRhJpL3dG POMsDxqO7eY879QfEtWuxG1ZW8haXCGLQQ9v53Wc7cQX2Mc+a0fcrlMxE0+vswEPSwb6 TMbIT/SsFR2ia9OJ+Ryp0u/Xii6v8zwJ0vRlno4rm8X87i5AjX7ENUsLDe3S7I+q5mTh O3SpuR0deZgUUc6dtWD9i3QIwrU0Fxy+OeigJuRBnPUho4JEfY+0i6kj/9sjwibUYmtt c0rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JmRPLHEp9s+e9jCfJoFmuvjBgSdf3XKacZcCrInYhKs=; b=e7u4D5qooFEhtTwcuOVxK0GrznuUuuvoXlKZYNPJ7h0MlOJRKVljK01DsRkijN1HGh rzguJop2t2YgVNWbMd3dWYqy+SHnNeMC1BHf8rqRZOjKVvV2/A9BARATKZZaZclOs4gy ARFMxvfyGtrcaNXl75WchcBt6DimrJWcyINH4hhV6tl0LG5Iy+P9GMSHYedFanpjYcii gUk894rOF6OJFxf8Bq6m8l7rSpWkFLk4G/WL3wiaW6DpJv54dETM4rBrJh9xb2rluC/B MVqUaAY02Roj4ufQZKPLgR92sKz4ubBlQhfaLqSeSJyHCOi/QRgsy0H/ksE6Bs+n3EEh noVA== X-Gm-Message-State: ALQs6tDfLNZffXEip59RLWib+xJbTqjQGhphkVGXzDmYZ6hHV9c1pmW5 CRmC9hY2q5HRJcjc7yc7GckBfYBGwH5R4GYNZD0qzQ== X-Received: by 2002:a6b:27d5:: with SMTP id n204-v6mr21709954ion.206.1525285653278; Wed, 02 May 2018 11:27:33 -0700 (PDT) MIME-Version: 1.0 References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <20180502172218.GL12180@hirez.programming.kicks-ass.net> In-Reply-To: <20180502172218.GL12180@hirez.programming.kicks-ass.net> From: Daniel Colascione Date: Wed, 02 May 2018 18:27:22 +0000 Message-ID: Subject: Re: [RFC PATCH for 4.18 00/14] Restartable Sequences To: Peter Zijlstra Cc: Mathieu Desnoyers , Paul McKenney , boqun.feng@gmail.com, luto@amacapital.net, davejwatson@fb.com, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Paul Turner , Andrew Morton , linux@arm.linux.org.uk, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, Andrew Hunter , andi@firstfloor.org, cl@linux.com, bmaurer@fb.com, rostedt@goodmis.org, josh@joshtriplett.org, torvalds@linux-foundation.org, catalin.marinas@arm.com, will.deacon@arm.com, Michael Kerrisk-manpages , Joel Fernandes Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 2, 2018 at 10:22 AM Peter Zijlstra wrote: >> On Wed, May 02, 2018 at 03:53:47AM +0000, Daniel Colascione wrote: > > Suppose we make a userspace mutex implemented with a lock word having three > > bits: acquired, sleep_mode, and wait_pending, with the rest of the word not > > being relevant at the moment. > So ideally we'd kill FUTEX_WAIT/FUTEX_WAKE for mutexes entirely, and go > with FUTEX_LOCK/FUTEX_UNLOCK that have the same semantics as the > existing FUTEX_LOCK_PI/FUTEX_UNLOCK_PI, namely, the word contains the > owner TID. That doesn't work if you want to use the rest of the word for something else, like a recursion count. With FUTEX_WAIT and FUTEX_WAKE, you can make a lock with two bits. > As brought up in the last time we talked about spin loops, why do we > care if the spin loop is in userspace or not? Aside from the whole PTI > thing, the syscall cost was around 150 cycle or so, while a LOCK CMPXCHG > is around 20 cycles. So ~7 spins gets you the cost of entry. That's pre-KPTI, isn't it?