Received: by 10.213.65.68 with SMTP id h4csp528012imn; Wed, 28 Mar 2018 08:03:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx49fvYcRRP2huN+jKIW2OIV0sn8/WBkeeEQIYueKWNd67yav6XXgplkC5hOvudXT0qhX3jjI X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr4206823plt.111.1522249408204; Wed, 28 Mar 2018 08:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522249408; cv=none; d=google.com; s=arc-20160816; b=mMY6VEuYismQoYMz8bgSOu+EIMfdbrD7dtBeJtP8IMZc1KKwkxqcMD+zJqV3r94Rjc m6e4KKFFs3FdCu1ibfOBwIeodLzA5OV9v5/hQIXuDNxEBOCmDXrQGXVvpgROTj70vkth GqKPJpm7XCoHm7OqOk0WCjpxriWCIw846uZ6CNU2AIZe5MxCUJdIaC81j/BUd0HeBrEC cXF4QzZKfgRqt7dMyPYtg/Xno9ybB4jB4Rzu9R5AdFl6SLfbb9g/z/0zdLULaU01KT2P Yh0FgoTXsg/PFuA2Dts84SmP5OtPOMeth4/+kt4KmORmwrvpDRhP+v1P6NtRDfLpkSF6 BGOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=vWY8aFFrfrxA9C4TAO5Yf3/qxPRx475/1NBlIDclrUM=; b=KgiXW0XKDj0BsnJeNjF5BaLtfwQjw5f1+DlXXqktbELsE8KASYdDrMs7jlgJFtSmsj J54cOcIhrs9RpDImsqydtbDpSmxMUkDxofgfouH5fuAYt4GGxbE8+NPkake94yXU1Tr8 aLRuBqFRze48Jbh9AG6LEBs+0moMJ0b1iTeBHV6NBTM504OQyvnFtPqKuNl99VqszDbH gTJAoRzfA3OSr8bIHc/leOMbc065IyIK+ZWtO/OvvbmjfQ94FZTrbtmYFyzveOhu8JmI aE4UZPOIIHGvNrvwFy+DSHNeMYN9NXQS9RCONQMBGUwwosUTRAkSRaSlbgqZ83WTvnC+ DYwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Y1jerkd9; 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 n22si2598630pgc.121.2018.03.28.08.02.39; Wed, 28 Mar 2018 08:03:28 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Y1jerkd9; 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 S1753858AbeC1PAZ (ORCPT + 99 others); Wed, 28 Mar 2018 11:00:25 -0400 Received: from merlin.infradead.org ([205.233.59.134]:56048 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753629AbeC1PAX (ORCPT ); Wed, 28 Mar 2018 11:00:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vWY8aFFrfrxA9C4TAO5Yf3/qxPRx475/1NBlIDclrUM=; b=Y1jerkd9Tg8W4aCsf+MgeMCb/ vIkYqnOZrU7SKhFiQSMiag4VCon6/shocMANPuEa7M3DlLkkxhql3jjFhrCIzgV+WOob5LwjLQy+K dLf/CjVKFweanD8vrf3F4Xb6O9lof7MEc1ivsME0Niggf5zXEphkafAZ5JSQw4H5mQt4G3mBKoHQO 4vKuqI9HmkMq5IMaFH/RBJXMq+V8b5bP0Sewr0Z4QBdBORFC3QSB9xNUPAGbearDFQxoSxdLyjW4/ G1yuoTD/2V6UYfCB7Rve1cigMB20MajOp6FdPPsLQ3+aiKUHuQSs403pTyTobsTdZB7eoFlgZMvRf d7o52t+fg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1CYF-0002qD-Lv; Wed, 28 Mar 2018 14:59:48 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 59444202A4A09; Wed, 28 Mar 2018 16:59:46 +0200 (CEST) Date: Wed, 28 Mar 2018 16:59:46 +0200 From: Peter Zijlstra To: Mathieu Desnoyers Cc: "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 , Alexander Viro Subject: Re: [RFC PATCH for 4.17 02/21] rseq: Introduce restartable sequences system call (v12) Message-ID: <20180328145946.GH4082@hirez.programming.kicks-ass.net> References: <20180327160542.28457-1-mathieu.desnoyers@efficios.com> <20180327160542.28457-3-mathieu.desnoyers@efficios.com> <20180328125004.GV4043@hirez.programming.kicks-ass.net> <1523662633.2105.1522248474778.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1523662633.2105.1522248474778.JavaMail.zimbra@efficios.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 28, 2018 at 10:47:54AM -0400, Mathieu Desnoyers wrote: > ----- On Mar 28, 2018, at 8:50 AM, Peter Zijlstra peterz@infradead.org wrote: > > > On Tue, Mar 27, 2018 at 12:05:23PM -0400, Mathieu Desnoyers wrote: > >> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > >> index fb5fc458547f..66b070444a7e 100644 > >> --- a/kernel/sched/sched.h > >> +++ b/kernel/sched/sched.h > >> @@ -1249,6 +1249,7 @@ static inline void __set_task_cpu(struct task_struct *p, > >> unsigned int cpu) > >> #endif > >> p->wake_cpu = cpu; > >> #endif > >> + rseq_migrate(p); > >> } > > > > I think you want that in set_task_cpu(), right next to nr_migrations++. > > This would miss the __set_task_cpu() call from sched_fork() and wake_up_new_task(). Correct; but since those are _new_ tasks they _SHOULD_ not have an active RSEQ to begin with. > Those cases are not accounted as explicit "migrations", but it does change the CPU > of the current task. So if for some weird reason userspace wants to fork() while in > a rseq critical section, we want to trigger a rseq restart. If at all possible I would make it SIGSEGV when issueing SYSCALL()s from within an RSEQ. > An alternative to this would be to call rseq_migrate() in rseq_fork(). > > Thoughts ? Yes, don't try and support that at all. It's _insane_.