Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8337744ybi; Thu, 6 Jun 2019 10:30:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxM1C/GWEvaCCVl8cbm92GdX9JwnzXMeak+/0wEizxJVrjyLLarLidTUNm5IIluHi+FiAei X-Received: by 2002:a63:5009:: with SMTP id e9mr4253992pgb.396.1559842244482; Thu, 06 Jun 2019 10:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559842244; cv=none; d=google.com; s=arc-20160816; b=zhT87W+fVkuW/4/mQNJM+ghYLC9mUkTaD+yRubmAEtHcRYijBp3COf4HVLFLo/LMCB L4MmoSgnVBbdNjhs2NN+JcZEjqZBE8LYUpgzaQXPWT+rJn+tGeAWAnsysM2GsGbMrUxx u8Kb0fBa/XQvBFlfNXlVRjoDWEFULaWBQxPW4I0DZMO9lgnFIRWuHS88HG7rmATYTH8r ZQlA5EZg05d41KCwWeKaY67HPNbmeVt39tseqr9rSfrf0KcOeSq4ZEV9iimKIz/GN54C ZXyDVDYwoztdCWnjulsrbqsPcGuy7aBc+CIHjaNqiDc+X2KaRnjLMPahwPbelnA4+Nj7 6GAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=XgHuMxiKPSChNcj64paxtu21Xrqqe7mEFx6nEXTs7bo=; b=u7Ia2ZEufUCzTNlTd/GHVPr0ACqD+88Xj9dqS7XQ4S41cOhaO3XA4le6+1mJdGfKZl Pd4QeM910VcCChBz//OabUFHBI5JAcCgpYtXm1uftYJlOFb5Y57/0UH7C71VEoxi1q2s cnHTZ6Ms6InY0UZTWVc8FZUOtrvkmIeGClAuByqd6pQqxjYC2+7t5X2z8a2y2H/7Zdq1 3ft6l0TeuOvXj1e+J1k/BLGW0YoetpU62+zYfIuNawJbVdtRV46/QMlC3YRGc1L5DqKU aR7ejYS03J10TS3v/YjflCL8eGRUX/FhoTnwVNVzQnBMYZivq/vjHSxuK0G8//50N+2g 4pVg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6si107791pjo.91.2019.06.06.10.30.27; Thu, 06 Jun 2019 10:30:44 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728632AbfFFOJN (ORCPT + 99 others); Thu, 6 Jun 2019 10:09:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50444 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727603AbfFFOJM (ORCPT ); Thu, 6 Jun 2019 10:09:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14D6E30C34C4; Thu, 6 Jun 2019 14:08:57 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.159]) by smtp.corp.redhat.com (Postfix) with SMTP id D22F01084285; Thu, 6 Jun 2019 14:08:52 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 6 Jun 2019 16:08:56 +0200 (CEST) Date: Thu, 6 Jun 2019 16:08:52 +0200 From: Oleg Nesterov To: Andrew Morton , Deepa Dinamani Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, dbueso@suse.de, axboe@kernel.dk, dave@stgolabs.net, e@80x24.org, jbaron@akamai.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, omar.kilani@gmail.com, tglx@linutronix.de, stable@vger.kernel.org, Al Viro , "Eric W. Biederman" , Linus Torvalds , David Laight Subject: [PATCH 1/2] select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR Message-ID: <20190606140852.GB13440@redhat.com> References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> <20190606140814.GA13440@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190606140814.GA13440@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 06 Jun 2019 14:09:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org do_poll() returns -EINTR if interrupted and after that all its callers have to translate it into -ERESTARTNOHAND. Change do_poll() to return -ERESTARTNOHAND and update (simplify) the callers. Note that this also unifies all users of restore_saved_sigmask_unless(), see the next patch. Signed-off-by: Oleg Nesterov --- fs/select.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/fs/select.c b/fs/select.c index 1fc1b24..57712c3 100644 --- a/fs/select.c +++ b/fs/select.c @@ -925,7 +925,7 @@ static int do_poll(struct poll_list *list, struct poll_wqueues *wait, if (!count) { count = wait->error; if (signal_pending(current)) - count = -EINTR; + count = -ERESTARTNOHAND; } if (count || timed_out) break; @@ -1040,7 +1040,7 @@ static long do_restart_poll(struct restart_block *restart_block) ret = do_sys_poll(ufds, nfds, to); - if (ret == -EINTR) { + if (ret == -ERESTARTNOHAND) { restart_block->fn = do_restart_poll; ret = -ERESTART_RESTARTBLOCK; } @@ -1061,7 +1061,7 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds, ret = do_sys_poll(ufds, nfds, to); - if (ret == -EINTR) { + if (ret == -ERESTARTNOHAND) { struct restart_block *restart_block; restart_block = ¤t->restart_block; @@ -1102,11 +1102,7 @@ SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds, unsigned int, nfds, return ret; ret = do_sys_poll(ufds, nfds, to); - - restore_saved_sigmask_unless(ret == -EINTR); - /* We can restart this syscall, usually */ - if (ret == -EINTR) - ret = -ERESTARTNOHAND; + restore_saved_sigmask_unless(ret == -ERESTARTNOHAND); ret = poll_select_copy_remaining(&end_time, tsp, PT_TIMESPEC, ret); return ret; @@ -1135,11 +1131,7 @@ SYSCALL_DEFINE5(ppoll_time32, struct pollfd __user *, ufds, unsigned int, nfds, return ret; ret = do_sys_poll(ufds, nfds, to); - - restore_saved_sigmask_unless(ret == -EINTR); - /* We can restart this syscall, usually */ - if (ret == -EINTR) - ret = -ERESTARTNOHAND; + restore_saved_sigmask_unless(ret == -ERESTARTNOHAND); ret = poll_select_copy_remaining(&end_time, tsp, PT_OLD_TIMESPEC, ret); return ret; @@ -1413,11 +1405,7 @@ COMPAT_SYSCALL_DEFINE5(ppoll_time32, struct pollfd __user *, ufds, return ret; ret = do_sys_poll(ufds, nfds, to); - - restore_saved_sigmask_unless(ret == -EINTR); - /* We can restart this syscall, usually */ - if (ret == -EINTR) - ret = -ERESTARTNOHAND; + restore_saved_sigmask_unless(ret == -ERESTARTNOHAND); ret = poll_select_copy_remaining(&end_time, tsp, PT_OLD_TIMESPEC, ret); return ret; @@ -1446,11 +1434,7 @@ COMPAT_SYSCALL_DEFINE5(ppoll_time64, struct pollfd __user *, ufds, return ret; ret = do_sys_poll(ufds, nfds, to); - - restore_saved_sigmask_unless(ret == -EINTR); - /* We can restart this syscall, usually */ - if (ret == -EINTR) - ret = -ERESTARTNOHAND; + restore_saved_sigmask_unless(ret == -ERESTARTNOHAND); ret = poll_select_copy_remaining(&end_time, tsp, PT_TIMESPEC, ret); return ret; -- 2.5.0