Received: by 10.213.65.68 with SMTP id h4csp488408imn; Wed, 28 Mar 2018 07:22:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4816KBpE+uShcWG6aaBnN9cjgr7G0g1hhreVznkFHRSMeKwoWxXKweoFsIibMvccJsOdJ8e X-Received: by 10.99.143.69 with SMTP id r5mr2736511pgn.159.1522246923251; Wed, 28 Mar 2018 07:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522246923; cv=none; d=google.com; s=arc-20160816; b=ucw0YiYdCZRms13cXmF2pE1fvRkuODOAKIGru7QJQ8q/dn0a2XpcHO3bPwaj5zKt+4 ap0LVXTdgvFGuPQuzgDGD376KZwk/lvBv2Wfp4p3LzTKQMSbzIS+cP4OqISSlo9W+ht5 woUvqDOpj+n9YaMAkY6/he60P39eOpdYkxwqNhiFOJ8nQ3vNUi6p87yVcFdon7C1Sheu +ND12cejhVbq7i3CLniEg1mCp0fX84kIpj91la/z5bQ/0fFLTQmiHftn9BdhU0AVNUeC JwErZ8QQzgWvcb6/gzG8C3gr/atFhA0GaNsgkrKzQ740lD9uDgKDOCC/0zkHq8IRDM2r JuFA== 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=uMHzxnbUPT2t1IHn+lPCALKNgVbP/MDwQ7EPT32BkHk=; b=UUCYH27JnmORQZGxYoQu2NSp7COnLcvJDpGd3lORoOs2Y9D2Yif20kN+CJ6rJc/WD6 hOJ0vn7kQERbEu5lrhdjgOiBfDxe20uggtrbZdE8437QNNPfOmef9miJNSKRLVEIt9Q7 uPj/9LSsVFENJU7JwF6IZGjSqkdMCLpwj3Cj/zUjQGqSRnwdG3QeKNC5esWypfLxzXfe 8TF2iZ7w7hi5QnWjYocDjWkT1rSfkv0bTTP794xo50moWsb72NwrB8zPn883RA1VOoaj kN1kTvO7at55VY9WdV+2ONxO0dkCC6zAHK5D4w2Gpwu6Et+NTxcU8R7tQdZ97QbvYMAl NBMg== 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 s20-v6si3477574plp.340.2018.03.28.07.21.48; Wed, 28 Mar 2018 07:22:03 -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 S1753635AbeC1OTi (ORCPT + 99 others); Wed, 28 Mar 2018 10:19:38 -0400 Received: from mail.efficios.com ([167.114.142.138]:36796 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752743AbeC1OTg (ORCPT ); Wed, 28 Mar 2018 10:19:36 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 422D11A833A; Wed, 28 Mar 2018 10:19:35 -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 ZjW33zPotXFc; Wed, 28 Mar 2018 10:19:34 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 3C5461A8336; Wed, 28 Mar 2018 10:19:34 -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 5ICuU58DUO_7; Wed, 28 Mar 2018 10:19:34 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 1EE671A832E; Wed, 28 Mar 2018 10:19:34 -0400 (EDT) Date: Wed, 28 Mar 2018 10:19:33 -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: <1602066458.2029.1522246773927.JavaMail.zimbra@efficios.com> In-Reply-To: <20180328111952.GS4043@hirez.programming.kicks-ass.net> References: <20180327160542.28457-1-mathieu.desnoyers@efficios.com> <20180327160542.28457-3-mathieu.desnoyers@efficios.com> <20180328111952.GS4043@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: oZa9XxD5Ql08V10mQq0a0I1RlslAQw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Mar 28, 2018, at 7:19 AM, Peter Zijlstra peterz@infradead.org wrote: > On Tue, Mar 27, 2018 at 12:05:23PM -0400, Mathieu Desnoyers wrote: >> +#ifdef CONFIG_RSEQ >> + struct rseq __user *rseq; >> + u32 rseq_len; >> + u32 rseq_sig; >> + /* >> + * RmW on rseq_event_mask must be performed atomically >> + * with respect to preemption. >> + */ >> + unsigned long rseq_event_mask; >> +#endif > >> +static inline void rseq_signal_deliver(struct pt_regs *regs) >> +{ >> + set_bit(RSEQ_EVENT_SIGNAL_BIT, ¤t->rseq_event_mask); >> + rseq_handle_notify_resume(regs); >> +} >> + >> +static inline void rseq_preempt(struct task_struct *t) >> +{ >> + set_bit(RSEQ_EVENT_PREEMPT_BIT, &t->rseq_event_mask); >> + rseq_set_notify_resume(t); >> +} >> + >> +static inline void rseq_migrate(struct task_struct *t) >> +{ >> + set_bit(RSEQ_EVENT_MIGRATE_BIT, &t->rseq_event_mask); >> + rseq_set_notify_resume(t); >> +} > > Given that comment above, do you really need the full atomic set bit? > Isn't __set_bit() sufficient? For each of rseq_signal_deliver, rseq_preempt, and rseq_migrate, we should confirm that their callers guarantee preemption is disabled before we can use __set_bit() in each of those functions. Is that the case ? If so, we should also document the requirement about preemption for each function. AFAIU, rseq_migrate is only invoked from __set_task_cpu, which I *think* always has preemption disabled. rseq_preempt() is called by the scheduler, so this one is fine. On x86, rseq_signal_deliver is called from setup_rt_frame, with preemption enabled. So one approach would be to use __set_bit in both rseq_preempt and rseq_migrate, but keep the atomic set_bit() in rseq_signal_deliver. Thoughts ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com