From patchwork Wed Mar 11 18:34:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11432501 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 49232921 for ; Wed, 11 Mar 2020 18:35:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BFBED2074B for ; Wed, 11 Mar 2020 18:35:21 +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="On0nSMgz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFBED2074B 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 803876B0006; Wed, 11 Mar 2020 14:35:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 78C156B0007; Wed, 11 Mar 2020 14:35:18 -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 5B7F26B0008; Wed, 11 Mar 2020 14:35:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 4258A6B0006 for ; Wed, 11 Mar 2020 14:35:18 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id F35488248068 for ; Wed, 11 Mar 2020 18:35:17 +0000 (UTC) X-FDA: 76583933874.11.copy77_6867f0023ff12 X-Spam-Summary: 2,0,0,1649ac593406c1f5,d41d8cd98f00b204,jgg@ziepe.ca,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1437:1515:1535:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4250:4385:5007:6117:6119:6120:6261:6653:7576:7901:7903:8660:10004:11026:11473:11658:11914:12043:12291:12297:12438:12517:12519:12663:12679:12683:12895:13069:13148:13161:13229:13230:13311:13357:13894:14095:14096:14181:14384:14394:14721:21080:21444:21451:21627:21740:21990:30046:30054:30056,0,RBL:209.85.160.195:@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:31,LUA_SUMMARY:none X-HE-Tag: copy77_6867f0023ff12 X-Filterd-Recvd-Size: 5066 Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 18:35:17 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id l21so2336192qtr.8 for ; Wed, 11 Mar 2020 11:35:17 -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:mime-version :content-transfer-encoding; bh=XocowDuniR0hmNfpL1nEDZsX1TOc8gKZoEyeLoQxAU8=; b=On0nSMgzQD/BpXWJeG3hXripgnyMnySf+BC95POCcQqeO/TzGQajxSwEOoyuXJtnu9 Cfx3f+Xjjn9Ee1s/v/MuIMr+SVLx7H7b1hMWPBCqfg+l6JS+9WMRPfQEczcnGusZzh+Y 15/zHItu4eJaxFNVJYFq9I0qdDWF7UHAcr9ha3NYPnbyqFNembAnXROws9f7wDW67p0y 3upwjd+YZigMo3GnsOPgN9fKtEQuJn8s/S9ZJefjtE7nRs8HH5QwgQTYKapfTZpgpWeD 4n+8FpA3t8sOWGh/aaUkNXcy9C0l9AZdjs7ES4bsrq1pMQMtujg25B3xc3/zgDG4pype JtpQ== 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:mime-version :content-transfer-encoding; bh=XocowDuniR0hmNfpL1nEDZsX1TOc8gKZoEyeLoQxAU8=; b=O2qMGCNXzzb5ZNsqO0uDCm31CvgCV41Qp0px0WDUmKFI1WblLWU8L2HAath8m0fJIJ nJsuEba9etqag83bNEI96xUIOZHP0kxeLVHbRhStiNAVrfOhjNrNqmtA7IiyP8nire9M l8WK2TYDr96WV5sB6xiCMRHeEv33TNt6kmJfqfwhFomURs+hREhsLGmx51X3/ZZN/xaK M59tVVUijNSxsumFE0Nrpx4bec25soprMRN0EHe+K/u8UyspuWl5kWqFuwvrtEE4yLLV l29lhHelJDtCIg36FUJmlDHCvbWGu17stNpRcMrGgyhzlMxK+pU/uSG54fNDse8WdBW6 D+xQ== X-Gm-Message-State: ANhLgQ3PPBfNArgHiETc2f/gPnpn2wXGXalwqJF/54LSOeTyn3nWmqv6 8o1bZteS8ieubjwwHVnztYgScw== X-Google-Smtp-Source: ADFU+vuHlgD4b9kXT5mtcSVhfQ4qfz45k/hdWlhMqHwFglRZBRjT/lnkg+9CGQkkuoKUS5C0N6Ncpw== X-Received: by 2002:ac8:6685:: with SMTP id d5mr3989843qtp.170.1583951716238; Wed, 11 Mar 2020 11:35:16 -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 h5sm9213171qkc.118.2020.03.11.11.35.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Mar 2020 11:35:15 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jC6CI-000163-UO; Wed, 11 Mar 2020 15:35:14 -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 hmm 0/8] Various error case bug fixes for hmm_range_fault() Date: Wed, 11 Mar 2020 15:34:58 -0300 Message-Id: <20200311183506.3997-1-jgg@ziepe.ca> X-Mailer: git-send-email 2.25.1 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 The hmm_range_fault() flow is fairly complicated. The scheme allows the caller to specify if it needs a usable result for each page, or if it only needs the current page table status filled in. This mixture of behavior is useful for a caller that wants to build a 'prefetch around fault' algorithm. Although we have no in-tree users of this capability, I am working on having RDMA ODP work in this manner, and removing these bugs from hmm_range_fault() is a necessary step. The basic principles are: - If the caller did not ask for a VA to be valid then hmm_range_fault() should not fail because of that VA - If 0 is returned from hmm_range_fault() then the entire pfns array contains valid data - HMM_PFN_ERROR is set if faulting fails, or if asking for faulting would fail - A 0 return from hmm_range_fault() does not have HMM_PFN_ERROR in any VA's the caller asked to be valid This series does not get there completely, I have a followup series closing some more complex cases. I tested this series using Ralph's hmm tester he posted a while back, other testing would be appreciated. Jason Gunthorpe (8): mm/hmm: add missing unmaps of the ptep during hmm_vma_handle_pte() mm/hmm: don't free the cached pgmap while scanning mm/hmm: do not call hmm_vma_walk_hole() while holding a spinlock mm/hmm: add missing pfns set to hmm_vma_walk_pmd() mm/hmm: add missing call to hmm_range_need_fault() before returning EFAULT mm/hmm: reorganize how !pte_present is handled in hmm_vma_handle_pte() mm/hmm: return -EFAULT when setting HMM_PFN_ERROR on requested valid pages mm/hmm: add missing call to hmm_pte_need_fault in HMM_PFN_SPECIAL handling mm/hmm.c | 166 ++++++++++++++++++++++++++----------------------------- 1 file changed, 79 insertions(+), 87 deletions(-) Signed-off-by: Jason Gunthorpe Reviewed-by: Ralph Campbell Reviewed-by: Christoph Hellwig