Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753290AbdHBMev (ORCPT ); Wed, 2 Aug 2017 08:34:51 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55585 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752094AbdHBMeu (ORCPT ); Wed, 2 Aug 2017 08:34:50 -0400 Date: Wed, 2 Aug 2017 15:34:41 +0300 From: Mike Rapoport To: Michal Hocko Cc: Andrea Arcangeli , 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 References: <1501136819-21857-1-git-send-email-rppt@linux.vnet.ibm.com> <20170731122204.GB4878@dhcp22.suse.cz> <20170731133247.GK29716@redhat.com> <20170731134507.GC4829@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170731134507.GC4829@dhcp22.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 17080212-0040-0000-0000-000003CB1D11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17080212-0041-0000-0000-000025C928D0 Message-Id: <20170802123440.GD17905@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-02_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1708020204 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2446 Lines: 72 On Mon, Jul 31, 2017 at 03:45:08PM +0200, Michal Hocko wrote: > On Mon 31-07-17 15:32:47, Andrea Arcangeli wrote: > > 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. > > OK, I wasn't aware of this. > > > +.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. > > Well, ESRCH is more appropriate so I would rather change it sooner than > later. But if we are going to risk user space breakage then this is not > worth the risk. I expected there are very few users of this API > currently so maybe it won't be a big disaster? I surely can take care of CRIU, but I don't know if QEMU or certain database application that uses userfaultfd rely on this API, not mentioning there maybe other unknown users. Andrea, what do you think? > Anyway, at least this is documented so I will leave the decision to you. > -- > Michal Hocko > SUSE Labs > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org > -- Sincerely yours, Mike.