Received: by 10.192.165.148 with SMTP id m20csp4295478imm; Mon, 30 Apr 2018 15:48:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoPolcUKK1IMaWSJxXvxTGGwVyEYMDg8isy/Z8qtUGR23XQ1S11Qgl+RJrY7mQffuUQr+BO X-Received: by 10.98.61.84 with SMTP id k81mr13531499pfa.193.1525128514213; Mon, 30 Apr 2018 15:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525128514; cv=none; d=google.com; s=arc-20160816; b=LJNLnEOSM0b+Up0s9KH0mijYtcqCMxeB9MwrD99GgVOrFYOhtWQT5m15VC9Nid+dbf NHeXgZM1TXOowxoANym6DZpVkd1tYDyBi+hvT7Ma4eNg9VmKu9YpNhDVvGgEspYaHvYl xwhji/jML7jKyY7y4BPYoPvIxSq+JFfYcNr/Lrvy/A4dX3ZFCtDjb80xj27hDyMLrtEF dnHxqWavpjDDysaywLJhIWOBhmJ3/3HNWDt6hOeKVF+tz+PXW7H/3CDUQWrtTPgT/9I6 d1+Zjrycau8UiF66WQRnq+35k3nnaeniQrfSSzXGk0SUphqqc5xscr1hWF6KqotaTZT+ 15PQ== 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 :message-id:date:subject:cc:to:from:arc-authentication-results; bh=I4W1JC3GFrhwKRpqY+Hg5Ma94oJH40/osiy8/zxR6wU=; b=BKjbrN3X8T11LMpWYJDpsn579rRPB94HceJ2yf7DKrOsHsXqwK1f/a/rgd7TmgFTVu Um3Hfauu9C1zBRr/o10QxMBuGq4I44VTQ2oL3PAaIiOnZ9CoSJSP3KFlhtTy3O8m5DBR +2LEKNq5HHYJUbmrMJj5SNrHmIZWoIC+sEAgBinRGoUDJhUCz7sgRHFDREEzFTL0uewl L0z8YkxCbSPtZAOZDqiV0zWIunCEXfkifIm5Y+w9ivxivv04UPsV1XDFZE01JztJljLE eXcwo6XtfMybO4qxBP7Zc7qbiTXWGDrKLFu2jEYoSZqfGpYlxBK33Evmxp+I8MMZxOua cvqA== 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 g17-v6si7862545plo.568.2018.04.30.15.48.20; Mon, 30 Apr 2018 15:48:34 -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 S1755415AbeD3Wop convert rfc822-to-8bit (ORCPT + 99 others); Mon, 30 Apr 2018 18:44:45 -0400 Received: from mail.efficios.com ([167.114.142.138]:52780 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755282AbeD3Won (ORCPT ); Mon, 30 Apr 2018 18:44:43 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 0111E1A6260; Mon, 30 Apr 2018 18:44:43 -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 J_ExMOGFWcN8; Mon, 30 Apr 2018 18:44:42 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 50BE91A624A; Mon, 30 Apr 2018 18:44:42 -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 jNjcBhSbQXpc; Mon, 30 Apr 2018 18:44:42 -0400 (EDT) Received: from thinkos.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id DD1A11A6243; Mon, 30 Apr 2018 18:44:41 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson Cc: 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 , Joel Fernandes , Mathieu Desnoyers Subject: [RFC PATCH for 4.18 00/14] Restartable Sequences Date: Mon, 30 Apr 2018 18:44:19 -0400 Message-Id: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Here is an updated RFC round of the Restartable Sequences patchset based on kernel 4.17-rc3. Based on feedback from Linus, I'm introducing only the rseq system call, keeping the rest for later. This already enables speeding up the Facebook jemalloc and arm64 PMC read from user-space use-cases, as well as speedup of use-cases relying on getting the current cpu number from user-space. We'll have to wait until a more complete solution is introduced before the LTTng-UST tracer can replace its ring buffer atomic instructions with rseq though. But let's proceed one step at a time. The main change introduced by the removal of cpu_opv from this series in terms of library use from user-space is that APIs that previously took a CPU number as argument now only act on the current CPU. So for instance, this turns: int cpu = rseq_per_cpu_lock(lock, target_cpu); [...] rseq_per_cpu_unlock(lock, cpu); into int cpu = rseq_this_cpu_lock(lock); [...] rseq_per_cpu_unlock(lock, cpu); and: per_cpu_list_push(list, node, target_cpu); [...] per_cpu_list_pop(list, node, target_cpu); into this_cpu_list_push(list, node, &cpu); /* cpu is an output parameter. */ [...] node = this_cpu_list_pop(list, &cpu); /* cpu is an output parameter. */ Eventually integrating cpu_opv or some alternative will allow passing the cpu number as parameter rather than requiring the algorithm to work on the current CPU. The second effect of not having the cpu_opv fallback is that line and instruction single-stepping with a debugger transforms rseq critical sections based on retry loops into never-ending loops. Debuggers need to use the __rseq_table section to skip those critical sections in order to correctly behave when single-stepping a thread which uses rseq in a retry loop. However, applications which use an alternative fallback method rather than retrying on rseq fast-path abort won't be affected by this kind of single-stepping issue. Feedback is welcome! Thanks, Mathieu Boqun Feng (2): powerpc: Add support for restartable sequences powerpc: Wire up restartable sequences system call Mathieu Desnoyers (12): uapi headers: Provide types_32_64.h (v2) rseq: Introduce restartable sequences system call (v13) arm: Add restartable sequences support arm: Wire up restartable sequences system call x86: Add support for restartable sequences (v2) x86: Wire up restartable sequence system call selftests: lib.mk: Introduce OVERRIDE_TARGETS rseq: selftests: Provide rseq library (v5) rseq: selftests: Provide basic test rseq: selftests: Provide basic percpu ops test (v2) rseq: selftests: Provide parametrized tests (v2) rseq: selftests: Provide Makefile, scripts, gitignore (v2) MAINTAINERS | 12 + arch/Kconfig | 7 + arch/arm/Kconfig | 1 + arch/arm/kernel/signal.c | 7 + arch/arm/tools/syscall.tbl | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/systbl.h | 1 + arch/powerpc/include/asm/unistd.h | 2 +- arch/powerpc/include/uapi/asm/unistd.h | 1 + arch/powerpc/kernel/signal.c | 3 + arch/x86/Kconfig | 1 + arch/x86/entry/common.c | 3 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/x86/kernel/signal.c | 6 + fs/exec.c | 1 + include/linux/sched.h | 134 +++ include/linux/syscalls.h | 4 +- include/trace/events/rseq.h | 56 + include/uapi/linux/rseq.h | 150 +++ include/uapi/linux/types_32_64.h | 67 ++ init/Kconfig | 23 + kernel/Makefile | 1 + kernel/fork.c | 2 + kernel/rseq.c | 366 ++++++ kernel/sched/core.c | 2 + kernel/sys_ni.c | 3 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/lib.mk | 4 + tools/testing/selftests/rseq/.gitignore | 6 + tools/testing/selftests/rseq/Makefile | 29 + .../testing/selftests/rseq/basic_percpu_ops_test.c | 312 +++++ tools/testing/selftests/rseq/basic_test.c | 55 + tools/testing/selftests/rseq/param_test.c | 1259 ++++++++++++++++++++ tools/testing/selftests/rseq/rseq-arm.h | 732 ++++++++++++ tools/testing/selftests/rseq/rseq-ppc.h | 688 +++++++++++ tools/testing/selftests/rseq/rseq-skip.h | 82 ++ tools/testing/selftests/rseq/rseq-x86.h | 1149 ++++++++++++++++++ tools/testing/selftests/rseq/rseq.c | 116 ++ tools/testing/selftests/rseq/rseq.h | 164 +++ tools/testing/selftests/rseq/run_param_test.sh | 120 ++ 41 files changed, 5572 insertions(+), 2 deletions(-) create mode 100644 include/trace/events/rseq.h create mode 100644 include/uapi/linux/rseq.h create mode 100644 include/uapi/linux/types_32_64.h create mode 100644 kernel/rseq.c create mode 100644 tools/testing/selftests/rseq/.gitignore create mode 100644 tools/testing/selftests/rseq/Makefile create mode 100644 tools/testing/selftests/rseq/basic_percpu_ops_test.c create mode 100644 tools/testing/selftests/rseq/basic_test.c create mode 100644 tools/testing/selftests/rseq/param_test.c create mode 100644 tools/testing/selftests/rseq/rseq-arm.h create mode 100644 tools/testing/selftests/rseq/rseq-ppc.h create mode 100644 tools/testing/selftests/rseq/rseq-skip.h create mode 100644 tools/testing/selftests/rseq/rseq-x86.h create mode 100644 tools/testing/selftests/rseq/rseq.c create mode 100644 tools/testing/selftests/rseq/rseq.h create mode 100755 tools/testing/selftests/rseq/run_param_test.sh -- 2.11.0