Received: by 10.192.165.148 with SMTP id m20csp1281736imm; Wed, 2 May 2018 18:16:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrVw5ypYYxTOCPwyEIgRZ37gf6F2K+P5tkkxY6Au+n2XlkRL/MsrzvxfD3PMRlFapB9YbH9 X-Received: by 2002:a63:864a:: with SMTP id x71-v6mr5100909pgd.175.1525310174531; Wed, 02 May 2018 18:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525310174; cv=none; d=google.com; s=arc-20160816; b=bjG0Nxs6Uvpzi+SBGBbmPP+lZKFyfDsWGTDp2vHWX9SeIVDFUcA0zxNS8gYd64rKUT IAZzUB4UZgEoqQWLLAKokdjCL6Hskj7ffablv016D/bgleJLE2zCAI+KUx60JGITBBh5 i/gMPZS/3+cP0dSXxmjFpIi3mIUYWu158bEfroX9Z/5fg6QB8C8Cm+Fplg2lLgcGGxLJ wf2sw2K6LFYsfQnmyNP1Y+WrZFwc4BEWQmDlgoXLrdCD1SXXsCLoUkgqyLbVj/cgHHgP oNOBCHzhnXtWNPI1y75Qn6XzkN5FKFezwo9cr9Ex9mR7YVAm6fuZoZiJrNXY06WoV5t6 yYtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=46yn0tdqEuvBz3z2b6F4B9pS6bCCQ6dgCCs1DIm0QjQ=; b=KHnOZ8lhwVut7C9w8FZYCtUpGxGaVFFfkpOwVtWLygv4GJ+9swNeJ6IUtOO+UZo+9S 9e1i7koHHJiSTXQJIKHBY5YmnzB0eILGnNHSJ6WWWNQIVbESd5JXQFgBuRg+7CoucmrS QJGrx58MdpyaAeuk69lD0zgGLD4JcRH/m1EoeoJhZS8NNSM/MCbGlDsYzNc5hzYErn+h IZEedNvHIQ8k6/OrEhY/aYeZrpi7xG9pH98kyD73MxX5CcFzBm9Qt5eMJhSBXcmdHaeS lH/Yjkbf7IuA9xaqQhq/eOTDWSDsxzBOtjy0KSynkbtludr7kaXHdF0ImynhvSqw0GaD i+MA== ARC-Authentication-Results: i=1; mx.google.com; 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 f4-v6si12092513plr.111.2018.05.02.18.15.59; Wed, 02 May 2018 18:16:14 -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; 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 S1751874AbeECBPn (ORCPT + 99 others); Wed, 2 May 2018 21:15:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:43136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751745AbeECBPk (ORCPT ); Wed, 2 May 2018 21:15:40 -0400 Received: from vmware.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA28821716; Thu, 3 May 2018 01:15:37 +0000 (UTC) Date: Wed, 2 May 2018 21:15:36 -0400 From: Steven Rostedt To: Daniel Colascione Cc: Peter Zijlstra , 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, josh@joshtriplett.org, torvalds@linux-foundation.org, catalin.marinas@arm.com, will.deacon@arm.com, Michael Kerrisk-manpages , Joel Fernandes , Robert Haas Subject: Re: [RFC PATCH for 4.18 00/14] Restartable Sequences Message-ID: <20180502211536.44b560c7@vmware.local.home> In-Reply-To: References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <20180502172218.GL12180@hirez.programming.kicks-ass.net> <20180502202233.GV12217@hirez.programming.kicks-ass.net> X-Mailer: Claws Mail 3.15.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 02 May 2018 20:37:13 +0000 Daniel Colascione wrote: > 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. What about exit? > > > > > > 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. Note, Robert Haas told me a few years ago at a plumbers conference that postgresql implements their own user space spin locks because anything that goes into the kernel has killed the performance. And they tried to use futex but that still didn't beat out plain userspace locks. -- Steve