Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2709209imb; Mon, 4 Mar 2019 12:02:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IY38q1OzD2d+L2X1ilbGB0pxQrUcs+Lp49za8hmywyz+x1akvEGOHcfOQy+93AbYY8lM1Tr X-Received: by 2002:a62:1d0e:: with SMTP id d14mr21243482pfd.73.1551729729514; Mon, 04 Mar 2019 12:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551729729; cv=none; d=google.com; s=arc-20160816; b=myVLeXOHPtb4tWJQSvto2vO/M7aFqjJbxHbL8IzMCGQruToU2Ihvf5NJGzF7w3fg+w DQnV/Grkg+PjV9hEISQrsbX/JPjRiSWzAP5ZjmoR/Cv4wRDaN6wDupKrNNzVETac0Kgt bG0B3m91Aa/4/E8tvlMaDwN5CiZ3s/vkC+R5S9T8nHx9B0sq7Sfh8EF+DfkTXfgTapZi CBqw9EvTki1zqqcPhnvVlfLMY4uUXLt5hgqvf5BSsXInaQ/0UqTwr0956N9cxWjhEue4 +2E2+NdVwhcbxU0X+TW+DrYX7foJYQjODsxU2uOTCoNTCOYse9R6iGZrBz3EjSXrI0pN j0wQ== 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=PmBrd4o9vunmvsiSxTL1Lv8RUgFNQhRz0D3UvZRqmjI=; b=AllUTFs2GKqYp5z8t6f/gZ4FHQMq4f1SF+HQTJpXkgpLbdIdlnZDMEBl/PyEd6HUK7 13cX10gXdqOppGhYOOSk5F144SdYoRjH8YEYdHh6cgvsUU9iriHc4QYl2cukrnis3eML IRp1aEIWxk3IPiZojIaEQe9CVSgex3TYPJYxeYB8DvNAR00/vIM1L6l4JXZ7AWDA9E3I P/blD3xyY1RtVqLA0N8Gy+Y5Wm1TKDWEQ7U0rRhbmwt1LBWJfidK6+S5RjCGaRiMHuGh N/gSAKirU4RVGroKE5NEIadwFSymecMaYM8Gblv8351+8qGCXaoDoU7WJczf9ovJCc24 unkQ== 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 a62si5788028pge.506.2019.03.04.12.01.53; Mon, 04 Mar 2019 12:02:09 -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 S1726194AbfCDT74 (ORCPT + 99 others); Mon, 4 Mar 2019 14:59:56 -0500 Received: from mga03.intel.com ([134.134.136.65]:63294 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbfCDT74 (ORCPT ); Mon, 4 Mar 2019 14:59:56 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 11:59:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,441,1544515200"; d="scan'208";a="120916949" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by orsmga006.jf.intel.com with ESMTP; 04 Mar 2019 11:59:54 -0800 Date: Mon, 4 Mar 2019 03:58:15 -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: <20190304115814.GE30058@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 I meant... Reviewed-by: Ira Weiny just a bit too quick on the keyboard before lunch... ;-) Ira > --- > 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 >