From patchwork Mon Jul 9 08:05:53 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: 10513837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8A54B60318 for ; Mon, 9 Jul 2018 08:06:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BCFA200DF for ; Mon, 9 Jul 2018 08:06:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EB1226253; Mon, 9 Jul 2018 08:06:57 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 2411A200DF for ; Mon, 9 Jul 2018 08:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754403AbeGIIGh (ORCPT ); Mon, 9 Jul 2018 04:06:37 -0400 Received: from mail-yb0-f196.google.com ([209.85.213.196]:35335 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751048AbeGIIGe (ORCPT ); Mon, 9 Jul 2018 04:06:34 -0400 Received: by mail-yb0-f196.google.com with SMTP id x15-v6so6855541ybm.2; Mon, 09 Jul 2018 01:06:34 -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; bh=7S1uPsIr5ADBgcsgfQb4AMK/6T1OOwRBEXslU8sjZiY=; b=kwIJgKrE0YOzuOXJvBG9U+xP5LxBts9K2k1ZRAtY7CcW2slMAlN9pAHZNx3DVtl2DO JHc3YYglBOk4Ykw59UIzu6vxs/x0yut94bXwKpr9aIXZ4eAS+lsMtg59+59rc2j0gOAZ yVsxwMKVZfqcv3lIy/SNOugOgFo1xBEZiiWCpAfhAq6fWaDioArMnRwZ3630405WV0M6 v4DxPqMAe/Zn+JX14cCtubT0ecuciRTlUTJrrN5Pet++Glk+OdZyDDU9IM1jBRoajjQE uGx+aqgKYTQJ8EsbQO0WcxtZHMPDoJ4X5uMZgOkW+syh//s3DAvCPgAOBAINP99ZvsaJ bvNw== 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; bh=7S1uPsIr5ADBgcsgfQb4AMK/6T1OOwRBEXslU8sjZiY=; b=QV7tgkdxo6AQWYpKggzJR5ywV9LdxfVd4yGP4uyysQPUxEOab4tLPes0f+HExRFW1x zvuZDSSk/PxfPQq2PgSkxrIM81lZ8NzcNTq2DuMTlJLrctEkX35/iHu/4DaqBCRM5uKi Zi9PKGTye4Flv2pv70yVTRLuivMf2hGDwdmsmnv9zcahJP61J6NxbUFob/oSvsb6uMK0 oPQ1ji96yLJU4KKe0wQGhBfN5KIcgYQIFxl5aUW5SXvwo95dxYEzT85pQQUNvjF5aTFk ZO/uQU2YJ8F9A4laVjIQiknb6/r4UexcHHrLhyXQKK5AFGh/lOiHrAfiHvQ1SyugTAgH cnoA== X-Gm-Message-State: APt69E3SXVUn/dPgRSZ9empf2zOoJMxfK/YyjJHUEFr4Qxgo7u7WBKtR XZN7CxGlaqzXOZSuACO6WObwlg== X-Google-Smtp-Source: AAOMgpcPEHeVirfQm8JXNox+KWiLSEVztBX+fVQf/b7dx2Q+QbR9+nSiNbcyUsQ/BCM2ZmrAGPXz2A== X-Received: by 2002:a25:403:: with SMTP id 3-v6mr10679430ybe.396.1531123594044; Mon, 09 Jul 2018 01:06:34 -0700 (PDT) Received: from sandstorm.nvidia.com ([2600:1700:43b0:3120:feaa:14ff:fe9e:34cb]) by smtp.gmail.com with ESMTPSA id w64-v6sm6339514ywe.46.2018.07.09.01.06.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 01:06:33 -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 1/2] mm: introduce put_user_page(), placeholder version Date: Mon, 9 Jul 2018 01:05:53 -0700 Message-Id: <20180709080554.21931-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180709080554.21931-1-jhubbard@nvidia.com> References: <20180709080554.21931-1-jhubbard@nvidia.com> X-NVConfidentiality: public Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: John Hubbard Introduces put_user_page(), which simply calls put_page(). This provides a safe 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. Subsequent patches will add functionality to put_user_page(). Signed-off-by: John Hubbard --- include/linux/mm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index a0fbb9ffe380..db4a211aad79 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -923,6 +923,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