Received: by 10.192.165.148 with SMTP id m20csp805149imm; Wed, 2 May 2018 09:03:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoepg7j4LtFH/j4L8juRcOGd7pMltOvKUKv+xNwcT+0icshLKjlci+2OGEI/UO6Mh7Z4iK8 X-Received: by 10.98.74.80 with SMTP id x77mr19937378pfa.142.1525277024186; Wed, 02 May 2018 09:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525277024; cv=none; d=google.com; s=arc-20160816; b=H4fn7pQ2aqq44JnrHPVbWB3uPogswbGbVWW31Cn3JERGG1loOemi5qHYqPuFMMr1RA DqelbV3Xve0AoJJvNYc9CY+jVi452s6jMTwxtTS0ExHa3BeS1E1o97pBwyaj1HOagb6+ DESeDOTL3F2wxAGO80CXtYrEsH2Y2POd1uBUfrbzH3usxThQRBC3WobTCzp6xMKbiVv2 XG8cxgzA/VjCl3z300BWIzzjYqsP2RLkOWQPS+R+jBO+PX0ub0DjESeNyXNc0FCAqyVY y7rhW9HdXo/mSBCOJQ1jNElX8VY6nhmYfBA6x1bYE9H4jCXJyrIZKL7PtrqYZlh881AG /lXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:arc-authentication-results; bh=5gZDspTO/wOa3Ix108Rb7Jmv1z5slC5gPQuNR1b2sZo=; b=BhoesQnpIyZtjy7XjfXW+Q4y4Xvww8M+4fVMGbihVys426+H4pg3hCPxer1MlffTpD WBjjXEyOqrZ4vUgCtDUN/mLvgEOuDX6MeHYGiAqLVpTfvaifYlf02K1Wh/K7H7gPODXc ns0B4cqNQqKX9LXQJ/TWXIp8WxU2vhilUuade2tnCV13icPKm5m40FU81QtGaLj5gO2k O0y1Yj51PxMynXIR04cxf7hKWpEx7ovAUZTbpFz+f/DYlBGLFH1XdoAGz4HyHOL2vClB 6R0s4v9p5wOhI5mVVWn79Bgr5bmS1k3okhyn01HDUCLQzXwsCOKKuIOij/Z5gh5Mc2H5 Zn/Q== 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 u1-v6si9457000pls.278.2018.05.02.09.03.29; Wed, 02 May 2018 09:03:44 -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 S1751549AbeEBQDM (ORCPT + 99 others); Wed, 2 May 2018 12:03:12 -0400 Received: from mail.efficios.com ([167.114.142.138]:52204 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeEBQDK (ORCPT ); Wed, 2 May 2018 12:03:10 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id CF0981BA1ED; Wed, 2 May 2018 12:03:09 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id v5TjKtBfaB6M; Wed, 2 May 2018 12:03:09 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 1A41C1BA1EA; Wed, 2 May 2018 12:03:09 -0400 (EDT) X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id bQkVUWcldqMp; Wed, 2 May 2018 12:03:09 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id F21EB1BA1E3; Wed, 2 May 2018 12:03:08 -0400 (EDT) Date: Wed, 2 May 2018 12:03:08 -0400 (EDT) From: Mathieu Desnoyers To: Daniel Colascione Cc: Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson , linux-kernel , linux-api , Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Ben Maurer , rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes Message-ID: <660904075.9201.1525276988842.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> Subject: Re: [RFC PATCH for 4.18 00/14] Restartable Sequences MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.8_GA_2009 (ZimbraWebClient - FF52 (Linux)/8.8.8_GA_2009) Thread-Topic: Restartable Sequences Thread-Index: NleDSVuumozP//06WNd68szD7SonWg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On May 1, 2018, at 11:53 PM, Daniel Colascione dancol@google.com wrote: [...] > > I think a small enhancement to rseq would let us build a perfect userspace > mutex, one that spins on lock-acquire only when the lock owner is running > and that sleeps otherwise, freeing userspace from both specifying ad-hoc > spin counts and from trying to detect situations in which spinning is > generally pointless. > > It'd work like this: in the per-thread rseq data structure, we'd include a > description of a futex operation for the kernel would perform (in the > context of the preempted thread) upon preemption, immediately before > schedule(). If the futex operation itself sleeps, that's no problem: we > will have still accomplished our goal of running some other thread instead > of the preempted thread. Hi Daniel, I agree that the problem you are aiming to solve is important. Let's see what prevents the proposed rseq implementation from doing what you envision. The main issue here is touching userspace immediately before schedule(). At that specific point, it's not possible to take a page fault. In the proposed rseq implementation, we get away with it by raising a task struct flag, and using it in a return to userspace notifier (where we can actually take a fault), where we touch the userspace TLS area. If we can find a way to solve this limitation, then the rest of your design makes sense to me. Thanks! Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com