Received: by 10.192.165.148 with SMTP id m20csp1060614imm; Wed, 2 May 2018 13:24:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqPAyNXU+EVpzuvkuoPc39/KoZlt6cxBpzG0OpnpJZkRE+KQdIJxHIefx20lCn6pZK0Kn43 X-Received: by 2002:a63:77ce:: with SMTP id s197-v6mr16839506pgc.272.1525292653353; Wed, 02 May 2018 13:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525292653; cv=none; d=google.com; s=arc-20160816; b=LWXPiJlCNAgO5KJ+wGMej3Bi16dn4Im7/ClZFOml5BzoNnLPlnKXNF3Xret9+ENRor SwmC2Y9EbJDMk+JD+Cb6z4pYKfgz9o0fUayzQM1ZuVD0sBAHBtTaoZxWMyCaQ62zFnAz 7k2FHoJvR1EE9S4KTg9ilbTj3Dq7Evxo+4pt7V3X8EGhO+bDlnBDq1M5Sy8E8ccfvHbq 6VA/f5XPaKhPXrZoIdVZYZD1wQpwK9p3gvX9uWbh+BT+RSSANtSkEyVOyqkWGSA+WnIr 2YYYCIJGLRjqMjfYTDO1mSni7wq6niXyonQPvO8okLyxCTJy1q7AdwrhmxpNwIzLHFCU pHAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=OneNDJDibtQSkFERDrpBFDb3BnNmOG3/lu+tQA+6zeI=; b=LTvzcgztB84ixzEWKT2EeIrgfCJFbFYYFdKwl62xQk9hIaDIYHVxYDCDVbpBZW6LRT wfSTxA/Vfo27XH+74Byl6Vdr5bcEgnrrop8Yz7jKTLTj9Hkl/avqWh4ApgFj+jO0tTlY X+3fEoLNWOW1i1mvTyh/+GeKiMgqr5BIka2kOWk2zYSKc9ShSCC5nU2X/O80nY4dhhBK nma7Jdl2sIWqHGmMwU+zmQajXJIL2yO7iQfVv5SZy+SLWkf1ulMi4b5/qKagjK5/NNCA 8lPOyo1yg10DNtqLlf7UZOJhNfnggcL7EbEvQO4KMTKOEDl1rjRwQzOCeSVH7kkfCF1t V+Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=I/07liZk; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c30-v6si10248495pgn.56.2018.05.02.13.23.46; Wed, 02 May 2018 13:24:13 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=I/07liZk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751262AbeEBUXP (ORCPT + 99 others); Wed, 2 May 2018 16:23:15 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48616 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbeEBUXM (ORCPT ); Wed, 2 May 2018 16:23:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OneNDJDibtQSkFERDrpBFDb3BnNmOG3/lu+tQA+6zeI=; b=I/07liZk4kEtal1sE/pE6Ni0F 5HBRA1l4DAYkGl4crT7uW2nX74+b2l9ddnsRMYlRzW/QHOG4kFBb4+M+KhCKQrZcXGsGj5H9gvsh1 4vny9yAJWWFWWvgoC3YfILqeL+kQ7+wRSPuFGa9FNI3bmx0Bx8yRAHSMX3XBw3n8/8vhckAqEkQ9Y M1Tg0ht65b0fTrNMUzVaQDNQHx+DSZDXlya2FwmYlcxMKdlLAlFDE/Y6wXSTwhHABWvJA7owjEpgj 5MLjmZKM2kpcHw7kf3W8wCX7sONsC9SOLTNsjGpg9jAqNnDyIh7VQO55/5FvNnbefLE/1mRggZxy5 A5kmfEq5g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fDyGq-00041S-RR; Wed, 02 May 2018 20:22:37 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2E2DA2029FA14; Wed, 2 May 2018 22:22:33 +0200 (CEST) Date: Wed, 2 May 2018 22:22:33 +0200 From: Peter Zijlstra To: Daniel Colascione 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 Subject: Re: [RFC PATCH for 4.18 00/14] Restartable Sequences Message-ID: <20180502202233.GV12217@hirez.programming.kicks-ass.net> References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <20180502172218.GL12180@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 the word allows things like kernel based optimistic spins and possibly PI related things. > > 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.