Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7294159ybi; Mon, 22 Jul 2019 10:28:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtauf8CmrPuGOdib/zOq3lVrbkU5NUUMJOhEmhe42W1vkSsCsc4cACS7kofS66mq1xmV9B X-Received: by 2002:aa7:8193:: with SMTP id g19mr1289637pfi.16.1563816482880; Mon, 22 Jul 2019 10:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563816482; cv=none; d=google.com; s=arc-20160816; b=jfbIEeqMgQxSUrK1+NvQw2aGYGfHsNmh/vAocLWTRz+mRBKoLJ5AJIndEbS++FN9Tq 92uUrWP6l2raejx5HK605a1FivT3+kGZylB77H17o0eiraGavYuOeK+ciJdjCeqP63qC D6DaoCW5Qu0jFzN7Oa+RV9XqMRfPsWQpp575OtSlUXxupnTdM6H10HTwHlRAW+Xw7N8k IQq/3sGbJn8o/gvhQKvoMiZ+1R8RiCQHgcdBs2Na6pOpSPpxtr75V5gPvkxIRKWThpr4 KjX3LoE0LVpmPNXD0aoPib9/0F+ecSL2cNYXWXpwdhoE+HArH+2XV4YkVRbH0eBkTXPA UuYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SUH6arJbp14IVMjbkeZ0K94NO/z20TDutwCqOxsq4Fw=; b=QCJt53RsEC6naKnod2kLj3Itu/y2J4FzLFz+gCVINGeSc8whZwiwkbbQG/2xCTdXJK /MM2hP+UB1MSEMZbhXWQqKVSFFFeYXTndseGL7/csSOxhU3PVMAKE6pZi0bnvUKVRhHp SGWMkPNvfU8gv168Di99Oqf6xkz1oKHqjJZbURTm3r421Fk3xffHicQdFSdrFO26nNSj HyrwMY0EyJ3hEOLtAF3Nu6KsN3mqLZo2oaFvvW1U402CWxedIWeu9rLf0VgiyDh1Mvh+ 9aiiDmSoBwHc1B8Pyz+NaVo3xrc1QUZl+UtCOVN7gyLGtKJosVvnvl3jMOsk/sI0Ox/3 yXVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cNYsnnjV; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f91si8752721plf.300.2019.07.22.10.27.46; Mon, 22 Jul 2019 10:28:02 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cNYsnnjV; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728890AbfGVOhr (ORCPT + 99 others); Mon, 22 Jul 2019 10:37:47 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35570 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbfGVOhr (ORCPT ); Mon, 22 Jul 2019 10:37:47 -0400 Received: by mail-lj1-f194.google.com with SMTP id x25so37894299ljh.2 for ; Mon, 22 Jul 2019 07:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SUH6arJbp14IVMjbkeZ0K94NO/z20TDutwCqOxsq4Fw=; b=cNYsnnjVLguyuhcKHqqxp7hSA5M3S1DZvaBoF80d1MZLvyCLSsdsxyzbqp+hAugfqB La4mTA+QaSN25eS7kR5jYbs5x37bIW38yuFEe9LoQUhA4BKZbg7G89i02FTdSaoa/LHD 0/lmUGsZBZhSpFQ3CDG0yu7d0XOEvaaddpieq56zgY56JIdUSioPyWlIQN+Coy+AXBhh i8jmWmQqzLzSlVGdTV2hn84KzjVBQl4pbwsL+KCS9KIx6GA7hL+D2ZJUFh8ilWXmzYh/ dAZFYOljbOddCkc8Zmh16FrOyiTux9Y7iKOyUucQi77FVxvyJCXpJp2vmP1KIUydFgVE 61bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SUH6arJbp14IVMjbkeZ0K94NO/z20TDutwCqOxsq4Fw=; b=To6Z3sFQCxUEZ8swOxTQbUpFcHl6LqFbqPPNczypSCR6KyCYe+jW5cimXbBBPKIV30 /iPPE9RNaCTd9UeE9Y/FbLVDL5XUfA1KQv02sq7L0t7NdsAn/Sd/9y3QLq8+G2O1nepz PaCsvausSPx6Jc7NeZcaFMd22iPXlix86FN2++E0MNCDgEcNaELCvHsLzukYAHPDrrGu OMFwB/VrRA3XIx1JcpRvXtKO4XioPvjCnJTPOuyn2JSvcw/nQ+1VWbvnxhVxZUUlHFAS 1QK7zYY71EwGMKg/rWlqTwVFs56rJsyUKUXaCBeDmjiW+mJ/ZhgDexrAlOcpWGplknF2 Kb/g== X-Gm-Message-State: APjAAAUN4pkS4pEoSYuEjHu0ZbIXzKB8g7qj7cgmbflu5SRSuZhGWi8+ sgjxI2uo/CO9L5A49TtjowytPZb9jjZ2nLET8U1Z8gsL X-Received: by 2002:a2e:b009:: with SMTP id y9mr25605680ljk.152.1563806265548; Mon, 22 Jul 2019 07:37:45 -0700 (PDT) MIME-Version: 1.0 References: <20190722094426.18563-1-hch@lst.de> <20190722094426.18563-2-hch@lst.de> In-Reply-To: <20190722094426.18563-2-hch@lst.de> From: Souptick Joarder Date: Mon, 22 Jul 2019 20:07:33 +0530 Message-ID: Subject: Re: [PATCH 1/6] mm: always return EBUSY for invalid ranges in hmm_range_{fault,snapshot} To: Christoph Hellwig Cc: =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs , Ralph Campbell , Linux-MM , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Felix Kuehling Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 22, 2019 at 3:14 PM Christoph Hellwig wrote: > > We should not have two different error codes for the same condition. In > addition this really complicates the code due to the special handling of > EAGAIN that drops the mmap_sem due to the FAULT_FLAG_ALLOW_RETRY logic > in the core vm. > > Signed-off-by: Christoph Hellwig > Reviewed-by: Ralph Campbell > Reviewed-by: Felix Kuehling > --- > Documentation/vm/hmm.rst | 2 +- > mm/hmm.c | 10 ++++------ > 2 files changed, 5 insertions(+), 7 deletions(-) > > diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst > index 7d90964abbb0..710ce1c701bf 100644 > --- a/Documentation/vm/hmm.rst > +++ b/Documentation/vm/hmm.rst > @@ -237,7 +237,7 @@ The usage pattern is:: > ret = hmm_range_snapshot(&range); > if (ret) { > up_read(&mm->mmap_sem); > - if (ret == -EAGAIN) { > + if (ret == -EBUSY) { > /* > * No need to check hmm_range_wait_until_valid() return value > * on retry we will get proper error with hmm_range_snapshot() > diff --git a/mm/hmm.c b/mm/hmm.c > index e1eedef129cf..16b6731a34db 100644 > --- a/mm/hmm.c > +++ b/mm/hmm.c > @@ -946,7 +946,7 @@ EXPORT_SYMBOL(hmm_range_unregister); > * @range: range > * Return: -EINVAL if invalid argument, -ENOMEM out of memory, -EPERM invalid > * permission (for instance asking for write and range is read only), > - * -EAGAIN if you need to retry, -EFAULT invalid (ie either no valid > + * -EBUSY if you need to retry, -EFAULT invalid (ie either no valid > * vma or it is illegal to access that range), number of valid pages > * in range->pfns[] (from range start address). > * > @@ -967,7 +967,7 @@ long hmm_range_snapshot(struct hmm_range *range) > do { > /* If range is no longer valid force retry. */ > if (!range->valid) > - return -EAGAIN; > + return -EBUSY; > > vma = find_vma(hmm->mm, start); > if (vma == NULL || (vma->vm_flags & device_vma)) > @@ -1062,10 +1062,8 @@ long hmm_range_fault(struct hmm_range *range, bool block) > > do { > /* If range is no longer valid force retry. */ > - if (!range->valid) { > - up_read(&hmm->mm->mmap_sem); > - return -EAGAIN; > - } > + if (!range->valid) > + return -EBUSY; Is it fine to remove up_read(&hmm->mm->mmap_sem) ? > > vma = find_vma(hmm->mm, start); > if (vma == NULL || (vma->vm_flags & device_vma)) > -- > 2.20.1 >