Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp181905imm; Thu, 4 Oct 2018 21:06:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV61up+pxH+PpSQQWc4gnkuY78hYw3IPlj0lRHRua1/X5M9EuxoeuZLyGs6N2D7k8Kt3s7yWI X-Received: by 2002:a62:3942:: with SMTP id g63-v6mr10234892pfa.170.1538712387167; Thu, 04 Oct 2018 21:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538712387; cv=none; d=google.com; s=arc-20160816; b=mT8SO4dMnMy+O/z7lRGNWsK9aV1q/Qbwb0L0/Je0fun6i1Or31YAfNBs4KlGI6cYxJ zHqN8OY/MSQyGsMJfu3b1b90Jqs5XtD5t34myAABeaQdR55PSexkEJNiu5/RzQ1Wuv9f A9E7ipH6GxO2Tur4g1d6wvGv3Txllw7e+zIpxNw4rla4i5NWJ3jzS5679RqOdKAB40Ti CLI44Ago6fEuOxS+MGfjBAgHBGdWy0jD8UBzQQu6iLw1fQMff2gLaMJuRD6+5m90jAra ANxUhEjZznp5dnhA8b8nBD30PkZ9bprSan0TkVj+oUyNg56Du1OaC1nZAI/D4KzsvLBd Wx3Q== 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=sneRiApjkE2w/LYnauim2aX4bIqXkJ3JToZQnFGODZI=; b=qS/PtEDF+ZnY9p4xDUyFWfQBfkHssTtsQr+YtejJo1pxcwDm8oa5usnF3Vhv5xOAmF oNt+JD/G+AZeupiIyerx309I3RVlmBplNS32JSMTsqHneYJqy6mpaUHEx/vdxnTXmom5 bCUS6ki8k269kb2Qjd+Th74fEr7JfDJgUVJHHqi8nIIzzep6eV1YqxIDvco3puGmBodt 7SQq9jXFXBrDgrf6STR/yPkfReWaI/Y+H+vH4Nb29BM6vUQkQbWW1tBuO/cDN2bv8hbt lqK1S5WUO+jMVxE9uzTSifoybgacZdHxqTSTthPM49ZGwRtQSto5X2C854qVCmtVaN7b Npfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G925Ez54; 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 c27-v6si6934665pgc.461.2018.10.04.21.06.11; Thu, 04 Oct 2018 21:06:27 -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=G925Ez54; 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 S1727667AbeJEK7U (ORCPT + 99 others); Fri, 5 Oct 2018 06:59:20 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36569 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726742AbeJEK7U (ORCPT ); Fri, 5 Oct 2018 06:59:20 -0400 Received: by mail-pf1-f196.google.com with SMTP id b7-v6so4427459pfo.3; Thu, 04 Oct 2018 21:02:32 -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=sneRiApjkE2w/LYnauim2aX4bIqXkJ3JToZQnFGODZI=; b=G925Ez54V6JJWAef4ifohJatJCsxpMB3vmgzPXoleKdhs2SUZ1saufdVQb43Te9LG/ VMP7duDIeynYhl/lRxVvlvTsDI3eBLW/rZJXFGtR9fSvrT/2nEtnHo5N2uF3ZSrDEpay irbzwETAEbj208oSKf+x8TPpIWjqIyVgi+9frgwQK2gFY33UZ/o/YPi+T/fSDzcwP9O9 7XGwPRp78aymRSx8CjSetBbZ8BybVcDOeK8MVVfjSXYWvOb+uJ+bKL9fm4K3nTSNh+xk 6kj5l/cYdt2TnnhV8OrsIES/odt1eMN+pa6HHkK8Lr+Vg+zR/ruKiHT7d/jMj2pvNlE6 afxA== 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=sneRiApjkE2w/LYnauim2aX4bIqXkJ3JToZQnFGODZI=; b=fAdLnjr6zv8oICvJxLiGvkhg1MYF5JyL0JKx+JTr74ylagtJfVe9i2PGWXP4d8Be11 4dIcE2KS3ec84KLiVd03QHGrbjyCsm6cUThlcjkFJPKDEa8Hz7KmAGxyZFfwJwIy1Olm HG9ydfgu6nmD7aIDHPEx2xqpZrP6A6Ii8w+Zyino3H3qaTUwQ42no9ux/Y96itCJ4ofK j+zpDylycEKwClW0P5hKGHZ7HjXTJeQJ5UhtDSWRRjzXRLIWUiNnXP3Xi+IuorTz0jOF T1bz3k/ce0JE7hMmfP/gCf9oAoNi6Xk8NWuNoUe3hgXcA9Tt8FZ4zmE25jLuf8kIE44r vtAQ== X-Gm-Message-State: ABuFfohKjI2CDm6nt+4JkRveWNxNXFpTvCSc+zEj/QZ0zW5OAwQN++qx PT5kZn8aIVCgcc6vWTk3qq4= X-Received: by 2002:a62:2741:: with SMTP id n62-v6mr2718591pfn.138.1538712151684; Thu, 04 Oct 2018 21:02:31 -0700 (PDT) Received: from blueforge.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c2-v6sm8787899pfo.107.2018.10.04.21.02.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 21:02:30 -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 Cc: linux-mm@kvack.org, LKML , linux-rdma , linux-fsdevel@vger.kernel.org, John Hubbard , Al Viro , Jerome Glisse , Christoph Hellwig Subject: [PATCH v2 2/3] mm: introduce put_user_page[s](), placeholder versions Date: Thu, 4 Oct 2018 21:02:24 -0700 Message-Id: <20181005040225.14292-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181005040225.14292-1-jhubbard@nvidia.com> References: <20181005040225.14292-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 introduces put_user_pages(), and a few dirty/locked variations, as a replacement for release_pages(), for the same reasons. These may be used for subsequent performance improvements, via batching of pages to be released. This prepares for eventually fixing the problem described in [1], and is following a plan listed in [2], [3], [4]. [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. [3]https://lkml.kernel.org/r/20180710082100.mkdwngdv5kkrcz6n@quack2.suse.cz Bounce buffers (otherwise [2] is not really viable). [4] https://lkml.kernel.org/r/20181003162115.GG24030@quack2.suse.cz Follow-up discussions. CC: Matthew Wilcox CC: Michal Hocko CC: Christopher Lameter CC: Jason Gunthorpe CC: Dan Williams CC: Jan Kara CC: Al Viro CC: Jerome Glisse CC: Christoph Hellwig Signed-off-by: John Hubbard --- include/linux/mm.h | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a61ebe8ad4ca..1a9aae7c659f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -137,6 +137,8 @@ extern int overcommit_ratio_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *); +int set_page_dirty(struct page *page); +int set_page_dirty_lock(struct page *page); #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) @@ -943,6 +945,44 @@ 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); +} + +/* For get_user_pages*()-pinned pages, use these variants instead of + * release_pages(): + */ +static inline void put_user_pages_dirty(struct page **pages, + unsigned long npages) +{ + while (npages) { + set_page_dirty(pages[npages]); + put_user_page(pages[npages]); + --npages; + } +} + +static inline void put_user_pages_dirty_lock(struct page **pages, + unsigned long npages) +{ + while (npages) { + set_page_dirty_lock(pages[npages]); + put_user_page(pages[npages]); + --npages; + } +} + +static inline void put_user_pages(struct page **pages, + unsigned long npages) +{ + while (npages) { + put_user_page(pages[npages]); + --npages; + } +} + #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) #define SECTION_IN_PAGE_FLAGS #endif @@ -1534,8 +1574,6 @@ int redirty_page_for_writepage(struct writeback_control *wbc, void account_page_dirtied(struct page *page, struct address_space *mapping); void account_page_cleaned(struct page *page, struct address_space *mapping, struct bdi_writeback *wb); -int set_page_dirty(struct page *page); -int set_page_dirty_lock(struct page *page); void __cancel_dirty_page(struct page *page); static inline void cancel_dirty_page(struct page *page) { -- 2.19.0