Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp341216imm; Thu, 27 Sep 2018 22:40:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV61gmcew/Y0Ncz2F7KObjRbWq0QL4Pg9adFqt3lYkHMVL1N5GShin1hWm0vR9W2PLNr/AsRT X-Received: by 2002:a62:6643:: with SMTP id a64-v6mr14804216pfc.202.1538113239997; Thu, 27 Sep 2018 22:40:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538113239; cv=none; d=google.com; s=arc-20160816; b=0C4ky+6Zu+Dl0lrJFzcMvi+MtWAqk1kACb4IAY4JUVUPS15XX/bHNc3H66nTRgDCus gpvjhxyNRkgD64smpI3QRhIiehJv+arlbIg20knvpo+U+tYebWxjxXAjq0UZ/5PVnGOn 4Gyodqz8vpJ4TkiFvjzVA1n0TH7GPiJpjWfbuYFSJwsK1DNwHDH/Ni9ArxKh14JmrLwk 8SZcJo826dURClIAT4B8z6fCfNeP6x7xUKO8b4KyJO6YKpIzWSSNVg6Zkukgl2WFbwlE ILWejfQN9mi9uKVUEARWU1S5Fd0ak46Vs3JtGYe0TgyTCHfza4QXx4w4/9f1auvG+py3 6x7A== 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=1mqzGKFVMjSnTLiDsAB/mdn2GuZtUkrT/vpmmy1PyQs=; b=pwpvINKrHEBJdJ1OlkarwY2/BFXsBko4R/4YpNYIRrJI1YrmsqnIvqOc+f17sKKnWT Rc8flMnKHXUFitR+oCBBGC5Eiar+YJjWpi9wapcItswERS3AKAwV6n3K/5f5SszKGy8o xQzrtZWkX6key48atXYHNqEeHe3rzbp9w8P/LODq/lzSFMAi0arSDMTWahi41g4oUB/2 WIQZRTQ0MubRH+ECWcYvfcYS8vxk320pPp6WGPALcTecxC23O0m3lZ6hu3iKeeCS/Dyf CeUajaaE3u0d06uoMnazlXxhJMHWcj4aMKqR6ZjsiR9II2XkmeueB9WP9vfr7M6C5F1/ NfUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o+Kj425j; 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 q14-v6si3857879pgk.346.2018.09.27.22.40.24; Thu, 27 Sep 2018 22:40:39 -0700 (PDT) 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=o+Kj425j; 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 S1728926AbeI1MCC (ORCPT + 99 others); Fri, 28 Sep 2018 08:02:02 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41759 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbeI1MCB (ORCPT ); Fri, 28 Sep 2018 08:02:01 -0400 Received: by mail-pg1-f193.google.com with SMTP id z3-v6so3591331pgv.8; Thu, 27 Sep 2018 22:40:01 -0700 (PDT) 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=1mqzGKFVMjSnTLiDsAB/mdn2GuZtUkrT/vpmmy1PyQs=; b=o+Kj425jnKP42HZw2x4xeAHlUiUb3CZEXHJRcINqCsnanOWKoDQcrLtOmLskp9VWzI R49hevMHgx5Oqhb/KxZmZXFpqPT9XxjRA801Ch4IO4lGkq6dJWo7RJYA3OGLPLE/m1lX shbtgZkw25oR0DBx4bBOEJGoSX5PJRB+9UDhiPtUqQEOu73eqgHSAJOFFpEcOwOmH3Ng FkMF54STPwp6EWRRuKQ5s0l1a/DkGtmuQs9sspRRnxOXE7U790apW8hYjonhKa6WjS9J gPyxjdzkZCTp/NGZ4sftBnnibXaHKNMuTdlafDkkORRZmUAS0dWpdNFtDx1bU9ChbQe8 Du1g== 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=1mqzGKFVMjSnTLiDsAB/mdn2GuZtUkrT/vpmmy1PyQs=; b=Mf/DZj+XV8lBjl5JIbwZp0lC+bo+X1kIJz5V3WvgVwhM5UYyKaHOLnGpawYGNkEMz1 5JeAHil8Ku65Uz5qge89Jith+OLIp6KKOK6zUwyvc8gLKBl9Y6loUL8pGp1auiSk3Jtw WIU/NQxVhPWMlm9jYa8KA62sCYQg+BYqqg8SKwo+nG+AElLOFkJH40FQWoydGkHY+kAQ jQG+uUQKfN0uCo15UCQY56Te0Bi+PRzczZDJlnknJYZFFIov3kWtapf8+lP/Qdf4ZHZ3 n1tyB6D2ZpKnwvFLjp13U9V6/x0sqMXNC1OCJDrpCn2gbnDFPDkW/DnzFdf3zMf+DRHa ZF9w== X-Gm-Message-State: ABuFfoi7nS0CYKAle7YBj0z6QqE4XqWbnVfBl+Oxl82dEGIacKxjA4Wt u/V6qa7VT3k8ct4N1UXs8p8= X-Received: by 2002:a65:448a:: with SMTP id l10-v6mr13566667pgq.382.1538113200923; Thu, 27 Sep 2018 22:40:00 -0700 (PDT) Received: from blueforge.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id u9-v6sm6569953pfi.104.2018.09.27.22.39.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 22:40:00 -0700 (PDT) From: john.hubbard@gmail.com X-Google-Original-From: jhubbard@nvidia.com To: Matthew Wilcox , Michal Hocko , Christopher Lameter , Jason Gunthorpe , Dan Williams , Jan Kara , Al Viro Cc: linux-mm@kvack.org, LKML , linux-rdma , linux-fsdevel@vger.kernel.org, John Hubbard Subject: [PATCH 2/4] mm: introduce put_user_page(), placeholder version Date: Thu, 27 Sep 2018 22:39:48 -0700 Message-Id: <20180928053949.5381-4-jhubbard@nvidia.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928053949.5381-1-jhubbard@nvidia.com> References: <20180928053949.5381-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 Introduces put_user_page(), which simply calls put_page(). This provides a way to update all get_user_pages*() callers, so that they call put_user_page(), instead of put_page(). Also adds release_user_pages(), a drop-in replacement for release_pages(). This is intended to be easily grep-able, for later performance improvements, since release_user_pages is not batched like release_pages() is, and is significantly slower. Also: rename goldfish_pipe.c's release_user_pages(), in order to avoid a naming conflict with the new external function of the same name. This prepares for eventually fixing the problem described in [1], and is following a plan listed in [2]. [1] https://lwn.net/Articles/753027/ : "The Trouble with get_user_pages()" [2] https://lkml.kernel.org/r/20180709080554.21931-1-jhubbard@nvidia.com Proposed steps for fixing get_user_pages() + DMA problems. CC: Matthew Wilcox CC: Michal Hocko CC: Christopher Lameter CC: Jason Gunthorpe CC: Dan Williams CC: Jan Kara CC: Al Viro Signed-off-by: John Hubbard --- drivers/platform/goldfish/goldfish_pipe.c | 4 ++-- include/linux/mm.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 2da567540c2d..fad0345376e0 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -332,7 +332,7 @@ static int pin_user_pages(unsigned long first_page, unsigned long last_page, } -static void release_user_pages(struct page **pages, int pages_count, +static void __release_user_pages(struct page **pages, int pages_count, int is_write, s32 consumed_size) { int i; @@ -410,7 +410,7 @@ static int transfer_max_buffers(struct goldfish_pipe *pipe, *consumed_size = pipe->command_buffer->rw_params.consumed_size; - release_user_pages(pages, pages_count, is_write, *consumed_size); + __release_user_pages(pages, pages_count, is_write, *consumed_size); mutex_unlock(&pipe->lock); diff --git a/include/linux/mm.h b/include/linux/mm.h index a61ebe8ad4ca..72caf803115f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -943,6 +943,20 @@ static inline void put_page(struct page *page) __put_page(page); } +/* Placeholder version, until all get_user_pages*() callers are updated. */ +static inline void put_user_page(struct page *page) +{ + put_page(page); +} + +/* A drop-in replacement for release_pages(): */ +static inline void release_user_pages(struct page **pages, + unsigned long npages) +{ + while (npages) + put_user_page(pages[--npages]); +} + #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) #define SECTION_IN_PAGE_FLAGS #endif -- 2.19.0