Received: by 10.192.165.148 with SMTP id m20csp2099153imm; Thu, 3 May 2018 10:20:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLeaTORL2rOwcMe6xD9Owqz5LAGt/HZbh/7ZLPC8wswbJWpzO4N69ko+6lsL+6dR2OlE1K X-Received: by 2002:a63:714d:: with SMTP id b13-v6mr12657506pgn.271.1525368043391; Thu, 03 May 2018 10:20:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525368043; cv=none; d=google.com; s=arc-20160816; b=MLaL/us4UuWHfWR7lzbe8JY3KfLojqRqQscQCGdv3eNGxFaSpmx/cHfRKV+gc1e4oH PcUCrZv0h3uKutzUTbaN04zUIYyxICtU15qUMb0v3vyk1sHD6ldACybn37HWpV/CVSwI Y4+pi3viuYfvZetPHddyoCrWL2jymE6QeiJ911gZYXNV0TAIu7/KNtDm8yGQl8Z01g9f pOl4hDk0zyoWGKN843Gk4GTkPZbH5PbxtakgL/2f0WWXEYqjmtFJY6oglTM6x8SCpfj3 5iw1tith0jVI6QGS839FhnI8M+8hazL8CT9K4kqSWCEc9oCpViqwC+4+qxwjrTCqlsQ/ VgXw== 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=C7A/c2g+lwzqMLxs1AfjW/IbxhYqUSJmDi2XaZVJTG4=; b=clt7TgIXj3ZiAGtoFk75f7a28RslxRN9znTrQon5I9Aa3C+tlVEA74/wZEcZ50mLjh uS0rX2rC68E2rrULVHWwPHaTedykoQ7uLq/N3FhEUJ2V9HJmhUinl/yQoKE32NekCCc1 fCG5Ncbq1en9ns0ldXoZapfE9oGESGqzkAdr2+5PXCS1yP1cYUnGSg1J/pzcLNkSNQ6U baKfrfpWkd7v/r0T71M1MJR0NHgQacHXl6UHBZHMPGC45P1zyY2ulNrXH0Ovl/cD/mmw f98nsqPnwF4i4ha3CP94hZyhZ/lmRXUDYUQRDRe/A46sIq+yYt3TJnfZ8igHlZvOKvn4 FMtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rRfKQlNa; 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 k139si14458867pfd.97.2018.05.03.10.20.29; Thu, 03 May 2018 10:20:43 -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=rRfKQlNa; 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 S1751349AbeECRTM (ORCPT + 99 others); Thu, 3 May 2018 13:19:12 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:54854 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbeECRTK (ORCPT ); Thu, 3 May 2018 13:19:10 -0400 Received: by mail-it0-f66.google.com with SMTP id z6-v6so131159iti.4 for ; Thu, 03 May 2018 10:19:10 -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=C7A/c2g+lwzqMLxs1AfjW/IbxhYqUSJmDi2XaZVJTG4=; b=rRfKQlNa75o4BAN3nPBZTVoYhLE+WxqRvS/Z64YAA6fDpRWki2c/Lb2G5jdrvX8Vej xrM376d+ywy7evneDFdl9z5agm1mcpD1hrez9AZYR8HGOJIbGy0V8bBlAywbvlR/eCsh Erh/v9bZFl2gVO7FAO6CtGXP7rzslfpPmA800Ut9CeyTxXcDIl0K54VlKAukFHszKpIw j1ocnKXfs15WQrIfbso1zs/gIyGLMML1cMpd8Ufm1qIO65LbRSv/82dujLt+h+mm9QKM /qf+41StGPjE1dcye4aOvzO+YoLzsskm3hKR06NbqUY95T+hEZk828MDaXbNmmQVOcNz SiSA== 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=C7A/c2g+lwzqMLxs1AfjW/IbxhYqUSJmDi2XaZVJTG4=; b=E+08wJpYbEefV8WmRoN4peUtuUoYKxg5FyzgX57ovuCAv/88h2Tn1zr3fkLBMICYpv 5VkjXFpfJTQb6kWVmJ9h5V9dVfb5RJ3AG8XQYarT5+3MHEL5fhGQKKA8hHBxFSKeEUGa OGE5+H0ZceZ8joCA1PblOBlg7Geo/eBi0kgpbjvyv7H0FzKCuprMp7B0g8LV2EOQKP0l SAU8PRjjvN2SbXKdIzUxQECB4zKN6tFhnpXAm0dkIZVyJhMG1IwvwjAV70DJiO7BmQ2E qGpv4ZWBAL2CiL7gL2EmcPeeZmT5sRCU/SsCIoQTgOXEdcZWUNwYtEyhKyr8nBXPaU2C smHw== X-Gm-Message-State: ALQs6tBaXGw1C+hpmY1ThdM8VfMD2rRtFSleML1VubBLJCIZ/e0BustL jZaboHWP6XY6Tjq0fhK135cWROEUvx2obqX8onHtKg== X-Received: by 2002:a24:f406:: with SMTP id d6-v6mr16211828iti.89.1525367949447; Thu, 03 May 2018 10:19:09 -0700 (PDT) MIME-Version: 1.0 References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <660904075.9201.1525276988842.JavaMail.zimbra@efficios.com> <1718748931.10084.1525363941807.JavaMail.zimbra@efficios.com> In-Reply-To: From: Daniel Colascione Date: Thu, 03 May 2018 17:18:58 +0000 Message-ID: Subject: Re: [RFC PATCH for 4.18 00/14] Restartable Sequences To: Joel Fernandes Cc: Mathieu Desnoyers , Peter Zijlstra , 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 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 Thu, May 3, 2018 at 9:48 AM Joel Fernandes wrote: > > > can skip the manual schedule we were going to perform. > > By the way, if we eventually find a way to enhance user-space mutexes in > the > > fashion you describe here, it would belong to another TLS area, and would > > be registered by another system call than rseq. I proposed a more generic > Right. Also I still don't see any good reason why optimistic spinning in > the kernel with FUTEX_LOCK, as Peter described, can't be used instead of > using the rseq implementation and spinning in userspace, for such a case. I > don't really fully buy that we need to design this interface assuming any > privilege transition level time. > If privilege level transitions are slow, > we're going to have bad performance anyway. That's not the case. There's a large class of program that does useful work while seldom entering the kernel: just ask the user-space network stack people. It's not wise to design interfaces around system calls being cheap. Even if system calls are currently cheap enough on some architectures some of the time, there's no guarantee that they'll stay that way, especially relative to straight-line user-mode execution. A pure user-space approach, on the other hand, involves no work in the kernel, and doing nothing is always the optimal strategy. Besides, there are environments where system calls end up being more expensive than you might think: consider strace or rr. If the kernel needs to get involved on some path, it's best that its involvement be as light as possible. > we should really stick to using FUTEX_LOCK and > reuse all the work that went into that area for Android and otherwise (and > work with Waiman and others on improving that if there are any problems > with it). FUTEX_LOCK is a return to the bad old days when systems gave you a fixed list of synchronization primitives and if you wanted something else, tough. That the latest version of the FUTEX_LOCK patch includes a separate FUTEX_LOCK_SHARED mode is concerning. The functionality the kernel provides to userspace should be more general-purpose and allow more experimentation without changes in the kernel. I see no reason to force userspace into 1) reserving 30 bits of its lockword for a TID and 2) adopting the kernel's idea of spin time heuristics and lock stealing when the same basic functionality can be provided in a generic way while reserving only one bit. That this mechanism happens to be more efficient as well is a bonus. "Mechanism not policy" is still a good design principle.