Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1751970ybi; Sun, 30 Jun 2019 23:22:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS6axTVWPoMvzqhbNtjmjlgGFmByawZpteuhK9WyRCvmAnCJ/ctF2LytWQYNDSP7INwRp1 X-Received: by 2002:a17:902:8c83:: with SMTP id t3mr26747021plo.93.1561962162011; Sun, 30 Jun 2019 23:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561962162; cv=none; d=google.com; s=arc-20160816; b=NB241lfbUuoceauWons7iE5E2f6baZvwWgtC+TtEQcb6FJC0G5I+jmH/bFwFSU6A44 yEDL9rI8PDjVZhCfvQ8yaoZxrbY5yfLd8msLWVPqJ2LFDdNdzv1PNfoKW7oNtHzEUAOT SKJKd7sWGaKispTkM0LlsR3lXkX1585eH6vinQoPwrQdJ/HWoQ0IS8XYPNmqCDbCVK1C jLWCIABt1Mt4m2igYNQFYjzaNUu1Jmyx1yL8KTKxraU/ou3wnPkbhJO0JyjFYb8PrAPJ 6qV64hYTzbqzGxl2GEB0kc4PLaQxSid23vjkUb0faZ25k7GgGdBa8PF8LPYa4QsmxzoX bX/g== 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=IzZcWaqQrWGdZeOcxQugf7n/YqC01MqphcLxaz0+wR0=; b=lruaROm8imEQmW/OSM8tCFs5Lc23Jo6FqiEBnnMP9s3TCNlL3f3YbcQvOj+eyzTyT5 rTQE6tghfreMEQ03o6bsA19CzzeaxBqobTMVR0KQZeW3niOpPq5u3kVeJlpmX2xvWRhr pq/bPipdy6V2pc3G6qCvtAjMgBOqsvAfujlCfJXJOOF8ygogmjVK0+/eZhX4v3b7VLc2 KgbRMplQ8MPdyOHyFZyofHgrs+3PcuAfnb0F7KRJEN+x+lhyUalS02T5Tjd3gG/A90Aw vmXJ+ZrzqJYLvLy4T6/f2k1BlPGTWD5ZEpjoNtqnGPC4fNCcsIw2xL4EcyfDps0r8FZB 6YJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=iKEi8d7g; 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 d2si9394569pgo.463.2019.06.30.23.22.26; Sun, 30 Jun 2019 23:22:41 -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=iKEi8d7g; 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 S1727803AbfGAGV0 (ORCPT + 99 others); Mon, 1 Jul 2019 02:21:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48624 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727750AbfGAGVJ (ORCPT ); Mon, 1 Jul 2019 02:21:09 -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=IzZcWaqQrWGdZeOcxQugf7n/YqC01MqphcLxaz0+wR0=; b=iKEi8d7gceCqjmsj3y6uTQglI6 NtyilHlo/Z3cOVWCQphycuVqQ9ZQEAaUmLuPbPaLq8x+TUQ4nPQItVtJhEJtMCQJXUZZyE10291/3 /dabnPYnGrVGTga/rAs5SVW+jf9uVsAeL5AaxVeQdjMWxlyZygrHjfY498GAHgBJlLG/qdbo7Qntr l/rPVwz9p2HuKbtcYVxPcUdGtLeSCQZMVE6Ev8BYFiKy+/6rYLpa5KX6wp4Uhe+17QegQ7nBpRiaR MLNX+XmpbzcP/dTJzryRXIqgDprZnE9ZupEE72sMJwkCLSY4so6Z5irk7JglSSP6q8vxZyFsiEJ/m AzaC/mig==; Received: from [46.140.178.35] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hhpgX-0003Jv-Ab; Mon, 01 Jul 2019 06:21:05 +0000 From: Christoph Hellwig To: Dan Williams , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jason Gunthorpe , Ben Skeggs Cc: Ira Weiny , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/22] mm: always return EBUSY for invalid ranges in hmm_range_{fault,snapshot} Date: Mon, 1 Jul 2019 08:20:17 +0200 Message-Id: <20190701062020.19239-20-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190701062020.19239-1-hch@lst.de> References: <20190701062020.19239-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 --- mm/hmm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index c85ed7d4e2ce..d125df698e2b 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -974,7 +974,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)) @@ -1069,10 +1069,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