Received: by 10.192.165.148 with SMTP id m20csp1072412imm; Wed, 2 May 2018 13:37:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqJuIlN75P4R82dDQ2PqEtNFbZh6JkbwYASCDaNUnpICpQfYJOtqrT3tdQ9IIkkwYPD/74W X-Received: by 2002:a63:a60a:: with SMTP id t10-v6mr17491481pge.357.1525293472290; Wed, 02 May 2018 13:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525293472; cv=none; d=google.com; s=arc-20160816; b=GWofw1OnXdRJ0XH5siuU/AjqkVSL+VHln8eQOc8nz5XILDOpCDxNc9t6p6XxYPlU4X aL9uPAC7Xuzne/W2Zusx3i3+DVZfyAi8EeEmeAZVModiIcXHLoY1IAjJ2YOX5ooUA1o4 hMldhP9Y9TLMQmWKzxROqJOA9gACbJ95CWDr/XNh66calah1BOY9lzb4VKd5wZJ8ra6t xWUfANbqpzpySetODuJje74oXzSQm6u/oUQis73J3BAH0FVjZqv0ep2U/Av+Mg4sxsEh oBlhaJ03McKRuki+0BWMrvScs6k10h1q9rp2/xIAeRbDZ6VkCenMwUV0SYpPSdFfLBNV Cg8w== 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=TWtnw8s1uVb1+dK+QsDQuwKIRKe1mdGD9BXtPaQZaV4=; b=KbzBVu05AI2hpIVGn1hokVCmyshJG3eK6siNxsjVzUuOMHwx9igOFpjvOVnkvz62Mv PNp/zEVqwBoOVvK6roWwEzKMe/me5oMz+FU+bBmT/F39U5CAvn9dGzclbSB+qOw6MXyP 9XrHEeO/f4c3CgkODTAbRXJwPbrEh5aGmjLOGfyXvxBWgIP1NQpfmMMpyZiZPoJGrQq7 JQxTLdEfpWTyVu0EB5I7/+/o+pbFhBH0YehL1waRv0wNXLwj1Y81+KLTrlzMs7NHXnYp 9UK50Uv2NZZqnL0STFCjV29rYudx6Yuv6+HWu1jLTWQaZr56zosBvHHqkuu5cXuomEs4 K12Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YklaQuKO; 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 w12-v6si2523407pgp.252.2018.05.02.13.37.36; Wed, 02 May 2018 13:37:52 -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=YklaQuKO; 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 S1751234AbeEBUh1 (ORCPT + 99 others); Wed, 2 May 2018 16:37:27 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:52162 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750939AbeEBUhY (ORCPT ); Wed, 2 May 2018 16:37:24 -0400 Received: by mail-it0-f65.google.com with SMTP id n202-v6so18543192ita.1 for ; Wed, 02 May 2018 13:37:24 -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=TWtnw8s1uVb1+dK+QsDQuwKIRKe1mdGD9BXtPaQZaV4=; b=YklaQuKOqfvOErQA8sjDM0kV7AGgOVflhGNxTIguGVHRNjiGSuaB2IuGu2oLS/YAzc ZDxaGgL6RlUkWwhC+gEEo1I3Lt5psirw1iFO4S5KoqHiNLHnwQdO7yVOtFQUGZKQYAKA qJGp2iUt5S1wSmt5w03UgWPWTIMFu8NYQPfhbktfkSiPdg9wmGq/P6WlCuFfSORDADU2 v9TQekxw77LjDMwsCDjru2uHhQ+z0tu0kbUZ+HLE1CcApj3d53vB2uEg86alljDnGK60 ZlZiNNGyvPsU0K96YalIW8pvx1RcxEs0hdbc2qIuKwGbIok0Xb1A7Bo4FcKVZTxGwjkA NrlQ== 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=TWtnw8s1uVb1+dK+QsDQuwKIRKe1mdGD9BXtPaQZaV4=; b=aAFCBnN0/1/cInCMu34rfk4N3Nq0P+FhEovu1wlUMymvPLoivGnqprRp5QgOFt13Fi pLjpg4Kaa7ZETWcEjyPjj0Eyp4BxkJqiv8Q1fCyF1t8TooznWOL0DAcEfv0ezR6i7/tV k4sfQoj1DhVB/6z3gmyR+tmfpPtyiKDzGLWGwkS40f3JTYqeuwqBSl9dda+yQDBPjQZs yNrn48vvBY8jw3QO/mCq++AFpHqhXNGFPL0VtBUQm6Vu0hUmOSmD/CbpU9Gm7laHefuf O0viSnlsgfPXDrVuziFETdMi4GyWFuyTHzDpaTOO6faYqEhkAmi+owyk1jXGKbg1Rnkz eHtA== X-Gm-Message-State: ALQs6tCAb7ROCYD5LMjwd8gQyfWYWxU5IYigDKk2vcMsFyRcA03loG9l r+YNGiFtcFvT5T1MpVsN3hOIDujSn/5Rr2+pHQMruQ== X-Received: by 2002:a24:c006:: with SMTP id u6-v6mr3198181itf.149.1525293443778; Wed, 02 May 2018 13:37:23 -0700 (PDT) MIME-Version: 1.0 References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <20180502172218.GL12180@hirez.programming.kicks-ass.net> <20180502202233.GV12217@hirez.programming.kicks-ass.net> In-Reply-To: <20180502202233.GV12217@hirez.programming.kicks-ass.net> From: Daniel Colascione Date: Wed, 02 May 2018 20:37:13 +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 1:23 PM Peter Zijlstra wrote: > On Wed, May 02, 2018 at 06:27:22PM +0000, Daniel Colascione wrote: > > 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. > Recursive locks are teh most horrible crap ever. And having the tid in What happened to providing mechanism, not policy? You can't wish away recursive locking. It's baked into Java and the CLR, and it's enshrined in POSIX. It's not going away, and there's no reason not to support it efficiently. > the word allows things like kernel based optimistic spins and possibly > PI related things. Sure. A lot of people don't want PI though, or at least they want to opt into it. And we shouldn't require an entry into the kernel for what we can in principle do efficiently in userspace. > > > 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? > Yes, and once the hardware gets sorted, we'll be there again. I don't > think we should design interfaces for 'broken' hardware. It would be a mistake to design interfaces under the assumption that everyone has fast permission level transitions.