From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [RFC PATCH v11 for 4.15 01/24] Restartable sequences system call Date: Thu, 16 Nov 2017 19:43:05 +0100 Message-ID: <20171116184305.snpudnjdhua2obby@hirez.programming.kicks-ass.net> References: <20171114200414.2188-1-mathieu.desnoyers@efficios.com> <20171114200414.2188-2-mathieu.desnoyers@efficios.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20171114200414.2188-2-mathieu.desnoyers-vg+e7yoeK/dWk0Htik3J/w@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Mathieu Desnoyers Cc: "Paul E . McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 List-Id: linux-api@vger.kernel.org On Tue, Nov 14, 2017 at 03:03:51PM -0500, Mathieu Desnoyers wrote: > +/* > + * If parent process has a registered restartable sequences area, the > + * child inherits. Only applies when forking a process, not a thread. In > + * case a parent fork() in the middle of a restartable sequence, set the > + * resume notifier to force the child to retry. > + */ > +static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags) > +{ > + if (clone_flags & CLONE_THREAD) { > + t->rseq = NULL; > + t->rseq_len = 0; > + t->rseq_sig = 0; > + } else { > + t->rseq = current->rseq; > + t->rseq_len = current->rseq_len; > + t->rseq_sig = current->rseq_sig; > + rseq_set_notify_resume(t); > + } > +} This hurts my brain... what happens if you fork a multi-threaded process? Do we fully inherit the TLS state of the calling thread?