Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6967541ybi; Mon, 22 Jul 2019 04:54:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzY2rPncX9YqK/TkFzcLR3wVH/OpEUJUj850g3w2HXp5Wrr+BvCty54bcXhxaK8zNTnDKku X-Received: by 2002:a17:90b:f0f:: with SMTP id br15mr77881183pjb.101.1563796459366; Mon, 22 Jul 2019 04:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563796459; cv=none; d=google.com; s=arc-20160816; b=zoGNyo2tdqBCNXSK6cFhLXWVimlIDnizQSMW6tkKXDlhpK68m+Q4+Nt6lMRs/6c8mA 3eTMwByuW6GiTmzZ72FV36O0ubFA7PNP/HLd71CND8JY4ASx3xCHUAwowiOOK+ONEA2g pxTaHWJqHCit++xsE6+wYTwTX4MB7yd8PFKxiukvyIAp9rmBsVyo9UjXOH8b7TeJ/127 qlN5aYsqFR1tQ/usTJKa23CDBeTRLu1MthYahYxMSTwl77Zw/ACqTGiAMoU+SDjpLCR5 MYfGLMQULwSyLbjWwl/BiZ+2Qm32cdsYUPnEwWKS2DYEJlEzvMjibi6zlf/6k9J35/9k c9XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=urPxkwOym5lxnAAUEUOneOxI40UkREYaiMYiFYZBiIs=; b=Ya9cEeY+GDTpYMNI3E7/y+l1ShS9Y7te/byKLfBcWP8qxuHzcw4Mc8FUlKtrGUhHtG uK13sG5BWVZsJ6tipTeF6xgM+F4MV12rDuD/gFBnGQX68EwqPY4yyv67dbnqyWSz1INp F9L69/SXKG/9SDutu0XtjD4R8oFh0KmmA1hoWv6ra3hE0OglXOBs3GyfjqKVIBmpqzV6 7/nfGfFlDXcy87b2VDnM6PeH2L6IoRdf8Yp7e/Hlqh+eZxkBTr4cf7AXg9upPCaMrk9W PCHDN1USjI31ZtJM+64/7hXJv5W/E9WsixWA++KHEOVRG3iwgDTXiCkcvTM9qMCGN72L aZ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=TXUpZd6L; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn22si10625383plb.422.2019.07.22.04.54.02; Mon, 22 Jul 2019 04:54:19 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=TXUpZd6L; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729127AbfGVJog (ORCPT + 99 others); Mon, 22 Jul 2019 05:44:36 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35268 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727167AbfGVJoe (ORCPT ); Mon, 22 Jul 2019 05:44:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=urPxkwOym5lxnAAUEUOneOxI40UkREYaiMYiFYZBiIs=; b=TXUpZd6L0YbxCncr1sT24mkFmX KdB/rJzomvHFe2vcYwtDiUWfXEb1N01spG6VnZkFRqZff6JTTSyVg6e2XYqqfAEPSFbxcPRWZvq7C X2Qor61E/+M2izt/dhGwdlhTh/mx4lUGDG9IFMT3BJGDUGZYpplivXhqVFZhj1Yts7FzlI5fZ0EuQ HPaB2GbWNvXyIHipogv1Dam/RNzkNllIiqYX3fN8H+EielY8T5BUPYFjBqVtiWN7qpDT6hCZdSE5Z e0YIgF2g0ItU/oWpaJMr+Lj/9moAJg5bcrft1jtgZcH8pGR341dRszQE/TWWzSWibmPDL0j4K+oQ3 g/VnYbfw==; Received: from 089144207240.atnat0016.highway.bob.at ([89.144.207.240] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hpUru-0001rb-RN; Mon, 22 Jul 2019 09:44:31 +0000 From: Christoph Hellwig To: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jason Gunthorpe , Ben Skeggs Cc: Ralph Campbell , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Felix Kuehling Subject: [PATCH 1/6] mm: always return EBUSY for invalid ranges in hmm_range_{fault,snapshot} Date: Mon, 22 Jul 2019 11:44:21 +0200 Message-Id: <20190722094426.18563-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722094426.18563-1-hch@lst.de> References: <20190722094426.18563-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; vma = find_vma(hmm->mm, start); if (vma == NULL || (vma->vm_flags & device_vma)) -- 2.20.1