Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753821AbcCLSKT (ORCPT ); Sat, 12 Mar 2016 13:10:19 -0500 Received: from 216-12-86-13.cv.mvl.ntelos.net ([216.12.86.13]:51722 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753773AbcCLSKM (ORCPT ); Sat, 12 Mar 2016 13:10:12 -0500 Date: Sat, 12 Mar 2016 13:10:06 -0500 From: Rich Felker To: Ingo Molnar Cc: Linus Torvalds , Andy Lutomirski , Andy Lutomirski , the arch/x86 maintainers , Linux Kernel Mailing List , Borislav Petkov , "musl@lists.openwall.com" , Andrew Morton , Thomas Gleixner , Peter Zijlstra Subject: Re: [musl] Re: [RFC PATCH] x86/vdso/32: Add AT_SYSINFO cancellation helpers Message-ID: <20160312181006.GE9349@brightrain.aerifal.cx> References: <20160310164104.GM9349@brightrain.aerifal.cx> <20160310180331.GB15940@gmail.com> <20160310232819.GR9349@brightrain.aerifal.cx> <20160311093347.GA17749@gmail.com> <20160311113914.GD29662@port70.net> <20160312170509.GB1108@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160312170509.GB1108@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2032 Lines: 47 On Sat, Mar 12, 2016 at 06:05:09PM +0100, Ingo Molnar wrote: > > * Linus Torvalds wrote: > > > On Fri, Mar 11, 2016 at 11:39 AM, Linus Torvalds > > wrote: > > > > > > "An implementation may also mark other functions not specified in the > > > standard as cancellation points" > > > > .. but that was from the Linux man-page. The open group has > > > > "An implementation shall not introduce cancellation points into any > > other functions specified in this volume of POSIX.1-2008" > > > > So yeah, it looks like there would need to be some way to filter things. > > > > Oh well. > > Is this really a big problem? Signals are asynchronous anyway, so if a C library > uses signal delivery for cancellation, it has to be ready to get the signal > delivered in the 'wrong' moment, for the wrong system call. The system call has to > be restarted in that case - or the interruption result has to be returned. The signals used for cancellation are not interrupting; the handler is installed with SA_RESTART. If cancellation is disabled when the handler is invoked, it does nothing at all. Otherwise, it first modifies the saved signal mask to leave itself block after it returns (the reason why involves complex nested-signal corner cases you probably don't want to know about). Then, if the signal handler determines the interrupted context is at a cancellation point, it rewrites the saved program counter to act on cancellation rather than restarting the syscall. If not, it does nothing else. > The _cancellation_ itself will then still be executed during the next suitable > cancellation point: which will be before doing the next cancellable system call > (or libc API). > > So I think it can still all be made work with SA_SYNCHRONOUS. > > It would only be a show stopper if Linux didn't cover all required system calls. > Covering _more_ system calls is not a problem AFAICS. But I might be missing > something ... You're missing a lot. Rich