Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932270AbcCDApG (ORCPT ); Thu, 3 Mar 2016 19:45:06 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:38786 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755048AbcCDApD (ORCPT ); Thu, 3 Mar 2016 19:45:03 -0500 Subject: Re: [PATCH] tmpfs: shmem_fallocate must return ERESTARTSYS To: Maxim Patlasov , hughd@google.com References: <20160304002954.19844.52266.stgit@maxim-thinkpad> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, devel@openvz.org From: Mike Kravetz Message-ID: <56D8DA86.6020803@oracle.com> Date: Thu, 3 Mar 2016 16:44:54 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160304002954.19844.52266.stgit@maxim-thinkpad> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1657 Lines: 49 On 03/03/2016 04:30 PM, Maxim Patlasov wrote: > shmem_fallocate() is restartable, so it can return ERESTARTSYS if > signal_pending(). Although fallocate(2) manpage permits EINTR, > the more places use ERESTARTSYS the better. > > Signed-off-by: Maxim Patlasov > --- > mm/shmem.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/mm/shmem.c b/mm/shmem.c > index 440e2a7..60e9c8a 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -2229,11 +2229,13 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, > struct page *page; > > /* > - * Good, the fallocate(2) manpage permits EINTR: we may have > - * been interrupted because we are using up too much memory. > + * Although fallocate(2) manpage permits EINTR, the more > + * places use ERESTARTSYS the better. If we have been > + * interrupted because we are using up too much memory, > + * oom-killer used fatal signal and we will die anyway. > */ > if (signal_pending(current)) > - error = -EINTR; > + error = -ERESTARTSYS; > else if (shmem_falloc.nr_unswapped > shmem_falloc.nr_falloced) > error = -ENOMEM; > else I used the shmem fallocate code as a basis for hugetlbfs fallocate. See, hugetlbfs_fallocate(). Specifically: /* * fallocate(2) manpage permits EINTR; we may have been * interrupted because we are using up too much memory. */ if (signal_pending(current)) { error = -EINTR; break; } I don't know much about the advantages of changing to ERESTARTSYS. But, if it is changed for shmem it should be changed for hugetlbfs as well. -- Mike Kravetz