Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2707334imb; Mon, 4 Mar 2019 11:59:34 -0800 (PST) X-Google-Smtp-Source: APXvYqwGB2EB44ejqVvd966xr5u3EBzIMCV9qheCNgZ1cX7UW4Zh3nM8/DtTHQTnSn/IRSgG6eVp X-Received: by 2002:a63:4f61:: with SMTP id p33mr20137028pgl.303.1551729574671; Mon, 04 Mar 2019 11:59:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551729574; cv=none; d=google.com; s=arc-20160816; b=deTc8yeZHVd6tstPnO07LibE1BXePYCCy8FYXNos3pwPLgDwrUuuXe/Rsv2vAhabvv zz+/aOcn1TrWi7EunnWDvvKHxvD/WMccrBweJ2WvzyNFH9LnppgvxBIkmjJbL5GzgVQZ Weh33PCzGuKSpBLuKKdXTxrGFEXjepPlzf5pu5C7yDmHsrziKdF2VP5b0znRpsytQiWr xCRjQIC3sdoYaOrbNfkk2ylPE6Llrz20iETOLJRp1vr2MTcL3PYoH9GL5f5Ub/BZ4oiU t02oHg86UwxWWSK5jbloAlK6sIfLcapiqHuLaeY+XtNsPNFKmJjyOogkhWnkVkQ2vk10 WCEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8Urlv/kHG1i5voROlgsy6xLuxTxqh+sUWVGy9cVwXb8=; b=EiVpawCbKjT1uIeIAzcaa0UNMHaDUAWVKUu4qhEwCyXyWr5Fdq7EqXAvlBq+ObSwc0 fvNw8pTAnsIoEvrz4q1FgDn2guUDxfIYr+0rx8rA5TBQOVX2h7QDMojFgugDdh7M4+9p Nzbf+B3p6tuVWFsyF3iPkfGNT28UkuU3IGYeCJppVue3sNPznpNxSH/6xAorctb7RGB4 TlX1LY2BcBcOxoNiKd+J5DZG06Ir4DjH/QZcy5hKrZK7TDPxmdsxykbJjNqp4tDDrTTw yOGEYsO1yq3nFCmBWXVb+6idR96MEx79gqNbiYBNX8s3SyTubxZWikqjoVCaqaem+gvp Cs5Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x202si5957735pgx.24.2019.03.04.11.59.19; Mon, 04 Mar 2019 11:59:34 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbfCDT6z (ORCPT + 99 others); Mon, 4 Mar 2019 14:58:55 -0500 Received: from mga04.intel.com ([192.55.52.120]:41155 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbfCDT6y (ORCPT ); Mon, 4 Mar 2019 14:58:54 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 11:58:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,441,1544515200"; d="scan'208";a="131541557" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by fmsmga007.fm.intel.com with ESMTP; 04 Mar 2019 11:58:53 -0800 Date: Mon, 4 Mar 2019 03:57:14 -0800 From: Ira Weiny To: john.hubbard@gmail.com Cc: linux-mm@kvack.org, Andrew Morton , LKML , John Hubbard , Leon Romanovsky , Jason Gunthorpe , Doug Ledford , linux-rdma@vger.kernel.org Subject: Re: [PATCH v3] RDMA/umem: minor bug fix in error handling path Message-ID: <20190304115713.GD30058@iweiny-DESK2.sc.intel.com> References: <20190304194645.10422-1-jhubbard@nvidia.com> <20190304194645.10422-2-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190304194645.10422-2-jhubbard@nvidia.com> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 04, 2019 at 11:46:45AM -0800, john.hubbard@gmail.com wrote: > 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 Signed-off-by: Ira Weiny > --- > 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 >