Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752352AbdGaNc6 (ORCPT ); Mon, 31 Jul 2017 09:32:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37034 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752308AbdGaNct (ORCPT ); Mon, 31 Jul 2017 09:32:49 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 32A5B5DD80 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=aarcange@redhat.com Date: Mon, 31 Jul 2017 15:32:47 +0200 From: Andrea Arcangeli To: Michal Hocko Cc: Mike Rapoport , Andrew Morton , "Dr. David Alan Gilbert" , Pavel Emelyanov , linux-mm , lkml , stable@vger.kernel.org Subject: Re: [PATCH] userfaultfd_zeropage: return -ENOSPC in case mm has gone Message-ID: <20170731133247.GK29716@redhat.com> References: <1501136819-21857-1-git-send-email-rppt@linux.vnet.ibm.com> <20170731122204.GB4878@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170731122204.GB4878@dhcp22.suse.cz> User-Agent: Mutt/1.8.3 (2017-05-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 31 Jul 2017 13:32:49 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1303 Lines: 44 On Mon, Jul 31, 2017 at 02:22:04PM +0200, Michal Hocko wrote: > On Thu 27-07-17 09:26:59, Mike Rapoport wrote: > > In the non-cooperative userfaultfd case, the process exit may race with > > outstanding mcopy_atomic called by the uffd monitor. Returning -ENOSPC > > instead of -EINVAL when mm is already gone will allow uffd monitor to > > distinguish this case from other error conditions. > > Normally we tend to return ESRCH in such case. ENOSPC sounds rather > confusing... This is in sync and consistent with the retval for UFFDIO_COPY upstream: if (mmget_not_zero(ctx->mm)) { ret = mcopy_atomic(ctx->mm, uffdio_copy.dst, uffdio_copy.src, uffdio_copy.len); mmput(ctx->mm); } else { return -ENOSPC; } If you preferred ESRCH I certainly wouldn't have been against, but we should have discussed it before it was upstream. All it matters is it's documented in the great manpage that was written for it as quoted below. +.TP +.B ENOENT +(Since Linux 4.11) +The faulting process has changed +its virtual memory layout simultaneously with outstanding +.I UFFDIO_COPY +operation. +.TP +.B ENOSPC +(Since Linux 4.11) +The faulting process has exited at the time of +.I UFFDIO_COPY +operation. To change it now, we would need to involve manpage and other code changes. Thanks, Andrea