Received: by 10.213.65.68 with SMTP id h4csp514257imn; Wed, 28 Mar 2018 07:49:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/z5smFCYXLo0ukr/N1UiQ0b5+TVc7YcwMtRtQ/Y4UT3ziD1eBQrQmTWU3TSolJZ+TXTRVM X-Received: by 2002:a17:902:4303:: with SMTP id i3-v6mr4130895pld.302.1522248562542; Wed, 28 Mar 2018 07:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522248562; cv=none; d=google.com; s=arc-20160816; b=08bqJzprLsYf5se/5rFeeLXX56+tqCqbii6mhp4ouqW0hTrsAK8fwC5lI4qruQ4/2N UrthDx2etm+3ORUqf+qllsQkqF1MMs1mG4NERP0jDoaoMCN/Tqjn3pZExra3/KNvAKRU 2x4Wc8I572/x3iVaRuPsiRyj8ZA2UmHAK/JmlDwiAMofTfxlSDLK69EFw1GsfHt3/rgm t2aYkpEqMRwl7ks03iKvCOos1twMETUEkpyQaOc5hMzB3Uep4l9FcalxIdsJ9rtqqLir fFkGdULKOgbp1D1v3NDob3HGcmIRqZ7HUnwwH6RpyWzIPXUbU/zogyuYLUxqvxXp0jrx sYuA== 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=+phcGUEhj0cHm43BF73j4zzceAIOQLurfphdiXd6HA4=; b=zFZNMJNynXUjremtJePA3hSoHHSZbvpjmGbFb058m0wKwOsb+Dy4lsAMXx/ys+DP5G /4arPL0UxOya0JS7OovkGZch7DICX9astUEmi+KoMlMmI9OrbQNoS5UtJQlIGhmtNDyP aiClGCoIM4eQsoDH33xOJSbsR17+aHFt1i3fneq6bjQHZaHT6cwN80GGyipoycV5Emz0 XEDFEm3e4sPKpoCVloMyP5PyAueu1u+ndnE0dtnNgytENb9CuGyiVTqX51ghMc0lJ7zz Z454qtJZYGz8LTmjlPdJT8Z6T2BqFh55gBaGXJYi91mIVe/cPoPk2H1FqN3xNrKWG03l eDuw== 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 u7si2599467pgc.218.2018.03.28.07.49.07; Wed, 28 Mar 2018 07:49:22 -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 S1753555AbeC1Or7 (ORCPT + 99 others); Wed, 28 Mar 2018 10:47:59 -0400 Received: from mail.efficios.com ([167.114.142.138]:38264 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753512AbeC1Or4 (ORCPT ); Wed, 28 Mar 2018 10:47:56 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id B5D5D1A896F; Wed, 28 Mar 2018 10:47:55 -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 jG6GbRrcsrV3; Wed, 28 Mar 2018 10:47:55 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 0B7FD1A8968; Wed, 28 Mar 2018 10:47:55 -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 WWUt8PAbA2MW; Wed, 28 Mar 2018 10:47:54 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id E2E871A8961; Wed, 28 Mar 2018 10:47:54 -0400 (EDT) Date: Wed, 28 Mar 2018 10:47:54 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra 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 Message-ID: <1523662633.2105.1522248474778.JavaMail.zimbra@efficios.com> In-Reply-To: <20180328125004.GV4043@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> Subject: Re: [RFC PATCH for 4.17 02/21] rseq: Introduce restartable sequences system call (v12) 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.7_GA_1964 (ZimbraWebClient - FF52 (Linux)/8.8.7_GA_1964) Thread-Topic: rseq: Introduce restartable sequences system call (v12) Thread-Index: g8G18zlpGluv5V0WfpsSPI+DeO7luw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- 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(). 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. Note that rseq_fork() implies rseq_preempt(), but userspace can request to track only migrations for a given rseq critical section (by using the RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT flag), so the rseq_preempt() in rseq_fork() is not enough to restart if a migration between CPUs is done across a fork. An alternative to this would be to call rseq_migrate() in rseq_fork(). Thoughts ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com