From patchwork Fri Mar 27 20:00:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11463059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3CA4913 for ; Fri, 27 Mar 2020 20:00:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8735620714 for ; Fri, 27 Mar 2020 20:00:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="CBwtBrf0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8735620714 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 763886B0073; Fri, 27 Mar 2020 16:00:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A12C6B0074; Fri, 27 Mar 2020 16:00:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 569A36B0075; Fri, 27 Mar 2020 16:00:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id 304256B0073 for ; Fri, 27 Mar 2020 16:00:36 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D7E0C824805A for ; Fri, 27 Mar 2020 20:00:35 +0000 (UTC) X-FDA: 76642209630.22.flock75_2248ee45fe50b X-Spam-Summary: 2,0,0,7bcd319b3f8145a2,d41d8cd98f00b204,jgg@ziepe.ca,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3354:3865:3866:3867:3870:3871:3872:3874:4250:4321:5007:6117:6119:6120:6261:6653:7576:7875:7901:7903:9036:9592:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:12986:13894:14181:14394:14721:21080:21433:21444:21451:21627:21990:30003:30012:30054,0,RBL:209.85.222.193:@ziepe.ca:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: flock75_2248ee45fe50b X-Filterd-Recvd-Size: 5931 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Mar 2020 20:00:35 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id j4so12144236qkc.11 for ; Fri, 27 Mar 2020 13:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TDrjscj5VUbtTUg81Gj8EA5DAPIuadUuhV+FJXt/EPU=; b=CBwtBrf0j+KndtyNs7QkByd1ivDhH+r1q5a3WPT7JV3TLYd84eFuXNa2pjKTL8rR01 fA3p/7kp415/LAwD4p4mKcIE3bas9ZhxZsIJyoLJH+hfkHIcJdPy+u+exZl/5J8jDK0m oDQomhjKgAoTF1Yp1ZL0iWj90lQAGleiyozXgaTgCoPdHdnpi3iFynvjUkd/iN5cdCLs opnE1kFN8Bgi3em7/ZY3yGrQbvWohI5okMJe51Qfr4N93myf/IcQCqmPms9ivBuiGyDH g+Rcmc1/kxA/RlbxIu3x8QQJQmnwm+/FkuKvDPbBSX5n058qaQBKousHs+ZmXxlOaPtP FDMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TDrjscj5VUbtTUg81Gj8EA5DAPIuadUuhV+FJXt/EPU=; b=ppyrIPwuMwAThupQR3WVfQTg+9wATSQCAK5jeUWwRMSpqS2LiBqwpXm2JJWXMmIso6 ZBkANLRlRo6cNcbBICVtdc/GkOHubVaoa73CuAdFw7SWM/1jWM+wrkkHLgnAUReeoRKf tEn0UKo1P/E6wLckjK6FYSI3T6lgx6RdsFSh9tyIqy/H2+VR1JXvqhaQ0Po39JNczyo/ 80bVuhOngLWT+En0hisazOBOHhHsAElWg86rjBUfKyBF/6jgMujwzvN2ABRjs4K4Jkvh MPyS+kUXsEzDpXLHwlLGbwUJlV5AVm0wgMmuaus2U37sGYEligbt57Zi5xceBxyenIrv JCHQ== X-Gm-Message-State: ANhLgQ1oKRk0nb+5gjiz+MN15o7nM8DGNz1jf+ddBDCSQjGFxxTvYLk3 j2k1q47j5A7sMZ/uruiH2blWoA== X-Google-Smtp-Source: ADFU+vtbEMaje0l8Yq/7uiD0ikZWgvPtViAmPYH3kZWMXZUn8JFdaevM0Ixe5LKqy7XPslfAtSA1jw== X-Received: by 2002:a37:e40d:: with SMTP id y13mr1045203qkf.39.1585339234848; Fri, 27 Mar 2020 13:00:34 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id y127sm4512371qkb.76.2020.03.27.13.00.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Mar 2020 13:00:28 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jHv9V-0007gA-B2; Fri, 27 Mar 2020 17:00:25 -0300 From: Jason Gunthorpe To: Jerome Glisse , Ralph Campbell , Felix.Kuehling@amd.com Cc: linux-mm@kvack.org, John Hubbard , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Christoph Hellwig , Philip Yang , Jason Gunthorpe Subject: [PATCH v2 hmm 8/9] mm/hmm: do not set pfns when returning an error code Date: Fri, 27 Mar 2020 17:00:20 -0300 Message-Id: <20200327200021.29372-9-jgg@ziepe.ca> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200327200021.29372-1-jgg@ziepe.ca> References: <20200327200021.29372-1-jgg@ziepe.ca> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Jason Gunthorpe Most places that return an error code, like -EFAULT, do not set HMM_PFN_ERROR, only two places do this. Resolve this inconsistency by never setting the pfns on an error exit. This doesn't seem like a worthwhile thing to do anyhow. If for some reason it becomes important, it makes more sense to directly return the address of the failing page rather than have the caller scan for the HMM_PFN_ERROR. No caller inspects the pnfs output array if hmm_range_fault() fails. Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- mm/hmm.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index dc826898979bc5..e875d9ef0968fd 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -77,17 +77,14 @@ static int hmm_vma_fault(unsigned long addr, unsigned long end, unsigned int required_fault, struct mm_walk *walk) { struct hmm_vma_walk *hmm_vma_walk = walk->private; - struct hmm_range *range = hmm_vma_walk->range; struct vm_area_struct *vma = walk->vma; - uint64_t *pfns = range->pfns; - unsigned long i = (addr - range->start) >> PAGE_SHIFT; unsigned int fault_flags = FAULT_FLAG_REMOTE; WARN_ON_ONCE(!required_fault); hmm_vma_walk->last = addr; if (!vma) - goto out_error; + return -EFAULT; if (required_fault & HMM_NEED_WRITE_FAULT) { if (!(vma->vm_flags & VM_WRITE)) @@ -95,15 +92,10 @@ static int hmm_vma_fault(unsigned long addr, unsigned long end, fault_flags |= FAULT_FLAG_WRITE; } - for (; addr < end; addr += PAGE_SIZE, i++) + for (; addr < end; addr += PAGE_SIZE) if (handle_mm_fault(vma, addr, fault_flags) & VM_FAULT_ERROR) - goto out_error; - + return -EFAULT; return -EBUSY; - -out_error: - pfns[i] = range->values[HMM_PFN_ERROR]; - return -EFAULT; } static unsigned int hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk, @@ -286,7 +278,6 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, /* Report error for everything else */ pte_unmap(ptep); - *pfn = range->values[HMM_PFN_ERROR]; return -EFAULT; } @@ -572,9 +563,6 @@ static const struct mm_walk_ops hmm_walk_ops = { * * This is similar to get_user_pages(), except that it can read the page tables * without mutating them (ie causing faults). - * - * On error, for one virtual address in the range, the function will mark the - * corresponding HMM pfn entry with an error flag. */ long hmm_range_fault(struct hmm_range *range) {