From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752880Ab3FXSnv (ORCPT ); Mon, 24 Jun 2013 14:43:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47057 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964Ab3FXSnu (ORCPT ); Mon, 24 Jun 2013 14:43:50 -0400 Date: Mon, 24 Jun 2013 20:39:31 +0200 From: Oleg Nesterov To: Denys Vlasenko Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] epoll_wait: fix EINTR leak Message-ID: <20130624183931.GA4464@redhat.com> References: <1372087913-7854-1-git-send-email-dvlasenk@redhat.com> <20130624170856.GA475@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130624170856.GA475@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/24, Oleg Nesterov wrote: > > On 06/24, Denys Vlasenko wrote: > > > > Usage of EINTR is wrong. > > I agree, this is not nice. However "fix EINTR leak" doesn't look > accurate, -EINTR is fine as an error code. Just the syscall should > restart if possible. > > > --- a/fs/eventpoll.c > > +++ b/fs/eventpoll.c > > @@ -1598,7 +1598,7 @@ fetch_events: > > if (ep_events_available(ep) || timed_out) > > break; > > if (signal_pending(current)) { > > - res = -EINTR; > > + res = -ERESTARTNOHAND; > > This and other similar changes do look right. > > Say, sys_epoll_wait(). With this patch it can sleep, then return > ERESTARTNOHAND. > > And we restart it with the same timeout again. If you want to > make it restartable, you need ERESTART_RESTARTBLOCK and > do_restart_epoll_wait() which we do not have. > > See for example sys_poll() which implements this logic. But, to avoid the confusion, please note that this change won't make it restartable wrt SA_RESTART. But it will help PTRACE_ATTACH or PTRACE_INTERRUPT or other "spurious" signal. We simply can't do this because there is no way to update "timeout" later if the task actually returns to user-mode. Oleg.