From patchwork Wed Feb 27 01:10:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 10830979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2D301805 for ; Wed, 27 Feb 2019 01:10:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E3142D2B3 for ; Wed, 27 Feb 2019 01:10:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9143B2D3E4; Wed, 27 Feb 2019 01:10:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 377AA2D2B3 for ; Wed, 27 Feb 2019 01:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729187AbfB0BKn (ORCPT ); Tue, 26 Feb 2019 20:10:43 -0500 Received: from mga09.intel.com ([134.134.136.24]:24267 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729108AbfB0BKn (ORCPT ); Tue, 26 Feb 2019 20:10:43 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Feb 2019 17:10:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,417,1544515200"; d="scan'208";a="118052070" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by orsmga007.jf.intel.com with ESMTP; 26 Feb 2019 17:10:42 -0800 Date: Tue, 26 Feb 2019 17:10:52 -0800 From: Ira Weiny To: John Hubbard , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org Subject: put_user_page() question Message-ID: <20190227011051.GB24463@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP John, With your put_user_page patchset, Is there a reason you don't call put_user_page() in the 2 spots shown in the diff below? And Jason, in the second case I find it odd that the driver needs to clear the invalidate_range() callback prior to the final ib_umem_odp_unmap_dma_pages() call such that put_user_page() is called. I am correct that this is how the pages finally get put in the end? Ira diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c index 730b2fa0942e..a63f5eda02ca 100644 --- a/drivers/infiniband/core/umem_odp.c +++ b/drivers/infiniband/core/umem_odp.c @@ -687,7 +687,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt, if (ret < 0) { /* Release left over pages when handling errors. */ for (++j; j < npages; ++j) - put_page(local_page_list[j]); + put_user_page(local_page_list[j]); break; } } @@ -750,7 +750,7 @@ void ib_umem_odp_unmap_dma_pages(struct ib_umem_odp *umem_odp, u64 virt, } /* on demand pinning support */ if (!umem->context->invalidate_range) - put_page(page); + put_user_page(page); umem_odp->page_list[idx] = NULL; umem_odp->dma_list[idx] = 0; umem->npages--;