From patchwork Mon Oct 8 21:16:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john.hubbard@gmail.com X-Patchwork-Id: 10631439 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 974FF15E8 for ; Mon, 8 Oct 2018 21:16:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AB5F29816 for ; Mon, 8 Oct 2018 21:16:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E0FF29839; Mon, 8 Oct 2018 21:16:32 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 060FF29816 for ; Mon, 8 Oct 2018 21:16:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDD2E6B0010; Mon, 8 Oct 2018 17:16:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EB4336B0266; Mon, 8 Oct 2018 17:16:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC9C66B0269; Mon, 8 Oct 2018 17:16:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 9E7456B0010 for ; Mon, 8 Oct 2018 17:16:30 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id e15-v6so18459842pfi.5 for ; Mon, 08 Oct 2018 14:16:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:mime-version:content-transfer-encoding; bh=3SwmFY4jXs0sJ3RkahlBQalMCCI13w3vJK/FnRSX15g=; b=iHY7vQNZLTKIMzETjJ3ChTMGpIUhORDn/nA3ze5f0FjIUbaTXJw74Vej0Ofv1j7Bsr cYG5jwekfv/XqnBAfA2rI26er8nbJ4KvOrdULsS2Zulj8spfqFog/qoIBHBiEpRKe2Gf 8b0bOc9vhViNWA5fde9sZUUIOh9T/nn5FKDF3g+6FtvfKS3H9OoFUN/ynutBBPcMB268 RUFwBejbx3ffhb+JQPG4ij3yjJvgWREC9rGOHILeBYUsOW+u7OlhZpCw4B6IfRXbTb09 NALLoJk2NRXD6eG+Ov5S+Z1iDFq4BZvwUqcjTYQdTHXSbvWg/Ka7caiZWvDcda5USIeD dwBA== X-Gm-Message-State: ABuFfoghZC589Cpln2TcDkg1aHJvB3VJdKXvP4awzTl0tspKPd8kd7kR eEMIJCYx/HHRiloAhJ1K7u4dAOj8ko/j39dGNh4immsM9XR34d+3Wl/dTjJkYOnag+isLG2YCFl ekhDw8o85lNmKl4ZWMP5AYYg54MRA6P0aWSVwvlVOYIGJKyMf9OOZeTdz6dZzjyxvd2u6s/qGkQ +Oj8rehIwmPX00JfsJRaW1+Fmb5VZlUCASZ5Q0TDZPcK8QWyDk8MLCiX7gkT91rjDroXtj+5LNC lswRYACfAdKIZYqHjso7pkEDcvKex5SJwIMigllzf0+YeD3TjFRmdA0AUJbivDiFnqoz4rbjA0D t6J4H6LaK3REGjmMtXmTCtONQOMKdKoIBdqRCo4eN/S3iqybTgoYHbmf+Rudd/JkN3bA2D0XlKl w X-Received: by 2002:a17:902:d01:: with SMTP id 1-v6mr26020624plu.88.1539033390271; Mon, 08 Oct 2018 14:16:30 -0700 (PDT) X-Received: by 2002:a17:902:d01:: with SMTP id 1-v6mr26020586plu.88.1539033389152; Mon, 08 Oct 2018 14:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539033389; cv=none; d=google.com; s=arc-20160816; b=fVU5gYzBukquVgxj5nRwENR7X9uz/PqtpljiJtzB7BFYcFmfJyYZgJXFYOav49w1iO nkx37I8yua8625kcDf1IUS6a3vTBUHUQiFMQ7/Q+XE2wEknXVYlW/KJbvrbvgY2KV6cA P/npz1Zw687/OQ/s/BTn+mJSP2ucYPYEOwXeIS9/jXe5UlFEmLZbIYsPL054ZtCTJiBP d3r6Y52+stHw8bIWd62tzKu2kRQ8xaIgbm9/EMcZqfGBMpOO60iBonIf5uMAORWcFH1w h9+s4I6luJbMGdcX4c9+hldXQknRlNala2yryPUgLpiva5RTN8ej3e75N25Q6+YAICLS a4Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=3SwmFY4jXs0sJ3RkahlBQalMCCI13w3vJK/FnRSX15g=; b=C02W7AqGOPPM2YxHJaDs6KEGlt/oIg8MpsjsGgQ5072PtULC3DWj0OtbMSl/jz4TwD ZbmWUH6rNdGIRW9zkM0ZSSm57gqD3xYRwxltHib6X9vi2ykM42IvxzilyJh9D9d2LnAH KEYneaxTnXMovCjgbqKCKbrz8I8RA/2P1uOrBkLEiLtgy4LaAsA+CH21CRuuyFtZ0ed+ uD1p2g1Z4oC2e2hjocx95iQHrxXrXUI4oUL3WnwSYe3oyxtKsdtrkL/flUZc7ElYp5o1 LcfGZhW+sZ3CT8wePu+JkkyjM6QvqhJDtzdQe/HSJyvFVveBbRtkmgZEblbgIiX+Z5BU 0xTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Mu7f+CGY; spf=pass (google.com: domain of john.hubbard@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.hubbard@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h194-v6sor15085607pfe.64.2018.10.08.14.16.28 for (Google Transport Security); Mon, 08 Oct 2018 14:16:29 -0700 (PDT) Received-SPF: pass (google.com: domain of john.hubbard@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Mu7f+CGY; spf=pass (google.com: domain of john.hubbard@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.hubbard@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3SwmFY4jXs0sJ3RkahlBQalMCCI13w3vJK/FnRSX15g=; b=Mu7f+CGYuavAm6LT3wKt2q3gupspRXJ9W9dzlGI8FXame7/UARagjYP+NiNdgstmGN R78sSogaAPABWfNqZpIb4gX4JZQ/fZBLD1hUhL93SDL4wB6kRPzOSXuR7x/5wudfbkcz KEit7dbY1CUdnzaSAQCAYW5gYIg1HrCrERGIzCF72G26wazkL8GyZRQiHaU0xKn7whq+ weben2m+iQ8Oy36RAOdLrzB1zQZEdaKQa53Hsf7UBrygnF2/FSh1msVLdaeyBd/TkvsY JiO+ldDgbTyIgFtGVx74zsS2Zmro22M2yOwJHbmja/jTuaQSZbIeEZcEnVfCq74WxHtc pFpw== X-Google-Smtp-Source: ACcGV62nxj2SeoUr3i/lvPLCL4XiL6oJYEDBIBIRp6r4C8vQ+mqDba/yODkRcqzVMN+L9V3KsmYtaw== X-Received: by 2002:a62:2c16:: with SMTP id s22-v6mr22057024pfs.6.1539033388744; Mon, 08 Oct 2018 14:16:28 -0700 (PDT) Received: from blueforge.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id w127-v6sm23480045pfd.112.2018.10.08.14.16.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 14:16:27 -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 , Ralph Campbell , Andrew Morton Subject: [PATCH v4 0/3] get_user_pages*() and RDMA: first steps Date: Mon, 8 Oct 2018 14:16:20 -0700 Message-Id: <20181008211623.30796-1-jhubbard@nvidia.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-NVConfidentiality: public X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: John Hubbard Andrew, do you have a preference for which tree (MM or RDMA) this should go in? If not, then could you please ACK this so that Jason can pick it up for the RDMA tree? Changes since v3: -- Picks up Reviewed-by tags from Jan Kara and Dennis Dalessandro. -- Picks up Acked-by tag from Jason Gunthorpe, in case this ends up *not* going in via the RDMA tree. -- Fixes formatting of a comment. Changes since v2: -- Absorbed more dirty page handling logic into the put_user_page*(), and handled some page releasing loops in infiniband more thoroughly, as per Jason Gunthorpe's feedback. -- Fixed a bug in the put_user_pages*() routines' loops (thanks to Ralph Campbell for spotting it). Changes since v1: -- Renamed release_user_pages*() to put_user_pages*(), from Jan's feedback. -- Removed the goldfish.c changes, and instead, only included a single user (infiniband) of the new functions. That is because goldfish.c no longer has a name collision (it has a release_user_pages() routine), and also because infiniband exercises both the put_user_page() and put_user_pages*() paths. -- Updated links to discussions and plans, so as to be sure to include bounce buffers, thanks to Jerome's feedback. Also: -- Dennis, thanks for your earlier review, and I have not yet added your Reviewed-by tag, because this revision changes the things that you had previously reviewed, thus potentially requiring another look. This short series prepares for eventually fixing the problem described in [1], and is following a plan listed in [2], [3], [4]. Patch 1, although not technically critical to do now, is still nice to have, because it's already been reviewed by Jan, and it's just one more thing on the long TODO list here, that is ready to be checked off. Patch 2 is required in order to allow me (and others, if I'm lucky) to start submitting changes to convert all of the callsites of get_user_pages*() and put_page(). I think this will work a lot better than trying to maintain a massive patchset and submitting all at once. Patch 3 converts infiniband drivers: put_page() --> put_user_page(), and also exercises put_user_pages_dirty_locked(). Once these are all in, then the floodgates can open up to convert the large number of get_user_pages*() callsites. [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 CC: Ralph Campbell CC: Andrew Morton John Hubbard (3): mm: get_user_pages: consolidate error handling mm: introduce put_user_page*(), placeholder versions infiniband/mm: convert put_page() to put_user_page*() drivers/infiniband/core/umem.c | 7 +-- drivers/infiniband/core/umem_odp.c | 2 +- drivers/infiniband/hw/hfi1/user_pages.c | 11 ++--- drivers/infiniband/hw/mthca/mthca_memfree.c | 6 +-- drivers/infiniband/hw/qib/qib_user_pages.c | 11 ++--- drivers/infiniband/hw/qib/qib_user_sdma.c | 8 ++-- drivers/infiniband/hw/usnic/usnic_uiom.c | 7 +-- include/linux/mm.h | 49 ++++++++++++++++++++- mm/gup.c | 37 +++++++++------- 9 files changed, 93 insertions(+), 45 deletions(-)