Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2700805imb; Mon, 4 Mar 2019 11:47:43 -0800 (PST) X-Google-Smtp-Source: APXvYqznCAdnPdibkqfKRrHNrkv81Pkh8B3KGVeXLDDncIcxTWmKSl5BWA3SGZzclFzpYMDXVM/y X-Received: by 2002:a17:902:7890:: with SMTP id q16mr22007683pll.63.1551728863860; Mon, 04 Mar 2019 11:47:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551728863; cv=none; d=google.com; s=arc-20160816; b=jO7IKJNetQyTROPLk/sdXK971Hsv4CHW0xUYysvlbQ+HHd1CZQybII40BQwN2fFdet 9hGi3tvkIT5D3k1Az8fWAc+xJ7aVE6xe8R0j1a8uLgdMEuEl5YPOO/FGCt8rlqdJ8/W1 XMzCeu1uin0C81Ke0vRzCsPrHGT7Z4y/ynmuEVF34WwqM2OYL5DXs9JQ3ElSHGJ5/0ns LBVZyR/N8zJdvD3rzPvuCbKB5VWkuQ6jKyLy2fSCK5hm8M0RJ+Aleuo9fPIrCQF2Ock3 /o32zOENARzXsQmQzYmWn0EWf2VahpIlOP5RMLOlXvHItykK1wqA/IkbER2+wjf4g0nF tAew== 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=yWPRKNbSliuixUwjxdom69EEKs5phLvSHf5FsoV2aEo=; b=fe/65vtri/ozVrQON5cZX6h7l8dtEuLGHrSaGqzReb42Y6NdMxV7p30dk5+xZP138o A4gGqoQMmpqLaHq855iDYdd2XiDKxE8h1XC0GTRxtHV+nPsJEgicGzgg6JP6d+Ziavpr vvoWbW2HDcIk1S/md8v50r8ZdBIjPnY73S2n1GCUU/+xK5Aoz4z9gvUWJWPR3rauI+UE 2ZAFt8YFjZlymBG9CHbDEi5Sldy+pZiMiCFogL0LG9heBTv+TwA7UalsjAeAYAR5AgIR rHOyUwwltrLTY+5dqvQI8nVY+RGRiNmPdtJGVx/njlIA+vGG1jbhuLSU7e2BgBu0VWi2 ZdFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ECnGDtm9; 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 k63si5722484pge.464.2019.03.04.11.47.27; Mon, 04 Mar 2019 11:47:43 -0800 (PST) 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=ECnGDtm9; 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 S1726327AbfCDTqy (ORCPT + 99 others); Mon, 4 Mar 2019 14:46:54 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35631 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726056AbfCDTqw (ORCPT ); Mon, 4 Mar 2019 14:46:52 -0500 Received: by mail-pf1-f193.google.com with SMTP id j5so3763958pfa.2; Mon, 04 Mar 2019 11:46:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yWPRKNbSliuixUwjxdom69EEKs5phLvSHf5FsoV2aEo=; b=ECnGDtm9cT/1TS0hga7uq1dImBkB33/g5+7V1GOXCCs/Yt+K4CqbeFR0maB0yAWfmx OGvTGBlvqHzJdo6kne4anwU3a0JczgPqPNgOg4gKDfmhFFUEotESymMSQyJfbg/UfTSf l4cOObIj/5hvWKYLS/pAibqGoIYL6rOWMBzGChGZFVuHr5J78wmzDeIuY3fkm/t0zpIp GHIq22p2TtNsZcxskMnXP2L2Nc9gATr4p0vzqKwE8TZIATUO1JvW7CLGDNLGCfBgERbk n33OEotkzz2iw8dZTCUYkkj4teFKAtTlwwGsjg376QodkL9GxL0Sn2xcoMBaCWcVF4GQ NYXg== 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=yWPRKNbSliuixUwjxdom69EEKs5phLvSHf5FsoV2aEo=; b=sURSKY4yJCQUnHQpuJT/71lf/ku+bT5lWzxNsh+/96FI5HRVGeOqSa06sN0GxnNTtH iwuAelbp2mKpjBhagNqSIYJfMuTA2mwhfd0I88CUa8bUOVOJRO+h5k9eGHRV2pgkvhWr X43OhaJ4Jfr2yY93SIGhvnMdwXI67YoHSQxccA0YgfOxsWLM83sp29A7RgOuCTBaOwEu dTUYUqA6eaVsdccTOj5NQBlbuyfsYugSxaW9An8iR3O6L/r9QCYc9X+wHELG91B8m2Ur 2+NNsHNve88o8TfzRgPz62AsYX97TKhNlw2J07Q16LdaivQHytkFpc6ZJKNFUTvgF4a/ 6IPA== X-Gm-Message-State: AHQUAuY8dNJ2NjWqMAk54w4r/S75nJ+YoVuuOKOaFRyaDjZs+qxvH+2J 7dOMjwDAO0p8mvSnyVW5szM= X-Received: by 2002:a62:41cc:: with SMTP id g73mr21187821pfd.145.1551728811727; Mon, 04 Mar 2019 11:46:51 -0800 (PST) Received: from blueforge.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id v15sm13499604pfa.75.2019.03.04.11.46.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 11:46:51 -0800 (PST) From: john.hubbard@gmail.com X-Google-Original-From: jhubbard@nvidia.com To: linux-mm@kvack.org Cc: Andrew Morton , LKML , John Hubbard , Leon Romanovsky , Ira Weiny , Jason Gunthorpe , Doug Ledford , linux-rdma@vger.kernel.org Subject: [PATCH v3] RDMA/umem: minor bug fix in error handling path Date: Mon, 4 Mar 2019 11:46:45 -0800 Message-Id: <20190304194645.10422-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190304194645.10422-1-jhubbard@nvidia.com> References: <20190304194645.10422-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Hubbard 1. Bug fix: fix an off by one error in the code that cleans up if it fails to dma-map a page, after having done a get_user_pages_remote() on a range of pages. 2. Refinement: for that same cleanup code, release_pages() is better than put_page() in a loop. Cc: Leon Romanovsky Cc: Ira Weiny Cc: Jason Gunthorpe Cc: Andrew Morton Cc: Doug Ledford Cc: linux-rdma@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: John Hubbard --- drivers/infiniband/core/umem_odp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c index acb882f279cb..d45735b02e07 100644 --- a/drivers/infiniband/core/umem_odp.c +++ b/drivers/infiniband/core/umem_odp.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -684,9 +685,11 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt, mutex_unlock(&umem_odp->umem_mutex); if (ret < 0) { - /* Release left over pages when handling errors. */ - for (++j; j < npages; ++j) - put_page(local_page_list[j]); + /* + * Release pages, starting at the the first page + * that experienced an error. + */ + release_pages(&local_page_list[j], npages - j); break; } } -- 2.21.0