Received: by 10.213.65.68 with SMTP id h4csp1580131imn; Sun, 1 Apr 2018 09:16:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx494dgGDiEF6aEyrVJGFF/6N04MQM1k0M+e6Y3rEQw0GdxAzTVij8kYlqa3iLkwTTglhIEq7 X-Received: by 10.98.171.11 with SMTP id p11mr4920064pff.161.1522599395702; Sun, 01 Apr 2018 09:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522599395; cv=none; d=google.com; s=arc-20160816; b=qaWhYUbqiQSeWa0b+SuNQlcQKP+ZSDNfAG+vW7CCuGtuH9ZyxDOXO0tyqeWvqN44Mj Tfup5ZcUPLnj2+9akmVV3CDha8AatTQxo1cSeWZ6gSE12feSUZpejb0wxP1ylh3dKHBt LSi04zo1H7GYZut70r1ObEWnvy0Wp4VEFBJXFAR8w8uuor1RVVyb/39DEsvNaQ1Umt1U tNKIowS5/rU3tQYYPJDPKr42iYNpH7p+3oa8qBZP0S5Z1f6Ce+5eVV48ZzDr4VwNZd7P qZCAFXZdiQ2/U5YOLxAVcRKhScaAitjQzKuZ5k8H9t71V0M/RCnE1vhdYNcZqDV5jb36 ERDA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=2Nc3wu4/alwj6dvGbTifyfFg8Lkco6LD5Xfr9NFFvnM=; b=FwSwMSxEOt8aHlGQnSjvkGQraw7xYhZGCSveAELdthRRB/wJMeWY9EBiOuJ5K6KhF3 zSNg8KKvTCD55ZT1ehMTW2BQSA2HZQKSEODkS56nIBbgLeOuf+bmzfGc67jDw9eOXuSt 4L0YHIqfE0uqRQ62H31KH7e9Q07vc307g0XP/uwoJ5nPdnmTWNZxAx8YnM1Z4+HK/vaX kTZY6MFNMpl/PD2uNJTAB7eEeAi2sdEBJ6+8ddxjxucXSNvLkJWOSiJG0k89PdFtReXp nuILK0+Af09q7lMkYKKUDglAGdCiy+5cfKcdn+MgGOF+l07YWdU0pLCJeo0kbkzpAH6v wAjw== 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 q3si1328964pgp.152.2018.04.01.09.16.21; Sun, 01 Apr 2018 09:16:35 -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 S1753650AbeDAQPN (ORCPT + 99 others); Sun, 1 Apr 2018 12:15:13 -0400 Received: from www.llwyncelyn.cymru ([82.70.14.225]:34418 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753602AbeDAQPM (ORCPT ); Sun, 1 Apr 2018 12:15:12 -0400 Received: from alans-desktop (82-70-14-226.dsl.in-addr.zen.co.uk [82.70.14.226]) by fuzix.org (8.15.2/8.15.2) with ESMTP id w31GDvND028265; Sun, 1 Apr 2018 17:13:57 +0100 Date: Sun, 1 Apr 2018 17:13:56 +0100 From: Alan Cox To: Mathieu Desnoyers Cc: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Alexander Viro Subject: Re: [RFC PATCH for 4.17 02/21] rseq: Introduce restartable sequences system call (v12) Message-ID: <20180401171356.085a2a33@alans-desktop> In-Reply-To: <20180327160542.28457-3-mathieu.desnoyers@efficios.com> References: <20180327160542.28457-1-mathieu.desnoyers@efficios.com> <20180327160542.28457-3-mathieu.desnoyers@efficios.com> Organization: Intel Corporation X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-redhat-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 Tue, 27 Mar 2018 12:05:23 -0400 Mathieu Desnoyers wrote: > Expose a new system call allowing each thread to register one userspace > memory area to be used as an ABI between kernel and user-space for two > purposes: user-space restartable sequences and quick access to read the > current CPU number value from user-space. What is the *worst* case timing achievable by using the atomics ? What does it do to real time performance requirements ? For cpu_opv you now give an answer but your answer is assuming there isn't another thread actively thrashing the cache or store buffers, and that the user didn't sneakily pass in a page of uncacheable memory (eg framebuffer, or GPU space). I don't see anything that restricts it to cached pages. With that check in place for x86 at least it would probably be ok and I think the sneaky attacks to make it uncacheable would fail becuase you've got the pages locked so trying to give them to an accelerator will block until you are done. I still like the idea it's just the latencies concern me. > Restartable sequences are atomic with respect to preemption > (making it atomic with respect to other threads running on the > same CPU), as well as signal delivery (user-space execution > contexts nested over the same thread). CPU generally means 'big lump with legs on it'. You are not atomic to the same CPU, because that CPU may have 30+ cores with 8 threads per core. It could do with some better terminology (hardware thread, CPU context ?) > In a typical usage scenario, the thread registering the rseq > structure will be performing loads and stores from/to that > structure. It is however also allowed to read that structure > from other threads. The rseq field updates performed by the > kernel provide relaxed atomicity semantics, which guarantee > that other threads performing relaxed atomic reads of the cpu > number cache will always observe a consistent value. So what happens to your API if the kernel atomics get improved ? You are effectively exporting rseq behaviour from private to public. Alan