From patchwork Mon Feb 7 06:22:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12736921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE4F1C433F5 for ; Mon, 7 Feb 2022 06:31:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2623E6B0074; Mon, 7 Feb 2022 01:31:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 213DD6B0075; Mon, 7 Feb 2022 01:31:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08DDD6B0083; Mon, 7 Feb 2022 01:31:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id E8FA06B0074 for ; Mon, 7 Feb 2022 01:31:35 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9BD35220CD for ; Mon, 7 Feb 2022 06:22:38 +0000 (UTC) X-FDA: 79114989996.03.FEDF9A3 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2042.outbound.protection.outlook.com [40.107.243.42]) by imf14.hostedemail.com (Postfix) with ESMTP id 0A201100007 for ; Mon, 7 Feb 2022 06:22:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ez8Kb8af7X0COMUk99TvC0zkis9L5Zkgy6Ja/sLcqB0xC4MjJZ1Fxcr+PWEpj947yXQlloGRd+aYSWsxbLPVhn6KeK8nd8cLGhELP6aSZUY+ZrgbtMh6ugFoKMjAr2aPDKhBCzal3MxhLII0UuJcExefD3on8wOaFCev/cQ4X5CAzIml7c4G3MoJqsGnQDUHnOnSJt8zPo38qRuuNWwiAezI94I4jLiDUMWxZnQhhnJHwcyymp2aAnlI4osnaH7uxd1A++sm3ySQq8aWZ/puCq6YcD97nLUrzTUgjVOQiqGFFpwTRj8GDYlHt3NTM2LVVFkEVqPqv2Cr+jsBidFJlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EGv0z9ojEXOjWjpAU1jboDQlS+KHpuPMdtW9AZqOTRs=; b=ZviEVtGNui/AxVnsrfyLba1cwGsNl2+IHP4JX9VUT3uuwhoBez4oqaKoJW1EN+nHjKlu3qP/ywDh4wtugm37x6uhGlmXzeTvU0+MlA67CtC+CuLowwNrrPuE7BASn0jbtGP2f2aPhOqivyto8LhmBM/ZDpnzcj8CWlvtdA/wujnV7yL+NGJjhQE/3MvFi1x4U5SDJqtQUscwGqzWG3z1OZhd1eiJLEcp14dN5TfqPVX/c5p8qbzUOfvGb7drKDVO3UD60Vp66zq+Pq/FyBJMw6zui3I8LFwybqjl5jniQ0dhk9pmLPhlIqs2sU5/xaC8NcKSq/id2Wf+Yc7TGP29/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EGv0z9ojEXOjWjpAU1jboDQlS+KHpuPMdtW9AZqOTRs=; b=iz5kPco3rurWNhuvr43C/Yp1Z5SCPsAuoOTKa+k6AD8gyd4Ywp8AFhDCxhhCnrKO8faVERah7NMLPGFRjWK7XtD82R6Q0SBs1SjqkSfxWw9oTJmSjY3XoY2SZttAt8QnAje6RvxNjHjgavtm/UmC3wovZQJgp5dDi4qFZVro52HxeNnuIfI2ZGqy27BDuKrCDDj1rnjjvr3+nTXYzmRQbtSGeCtJRBdGC8ctcw7uph5pchCeuvsNfSODa45OLHGX27aF554IonV9XZGh/cGulon5gTggDig74WV/MVIvq1AmP4tr7ivUDC1c5SP6dymHg1Vq1LcuhHu9tBqh8rxu8A== Received: from MWHPR19CA0004.namprd19.prod.outlook.com (2603:10b6:300:d4::14) by BYAPR12MB3318.namprd12.prod.outlook.com (2603:10b6:a03:df::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Mon, 7 Feb 2022 06:22:34 +0000 Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:300:d4:cafe::b3) by MWHPR19CA0004.outlook.office365.com (2603:10b6:300:d4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18 via Frontend Transport; Mon, 7 Feb 2022 06:22:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT033.mail.protection.outlook.com (10.13.174.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Mon, 7 Feb 2022 06:22:33 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 7 Feb 2022 06:22:33 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Sun, 6 Feb 2022 22:22:32 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Sun, 6 Feb 2022 22:22:32 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Christoph Hellwig Subject: [PATCH v5 1/5] mm: Fix invalid page pointer returned with FOLL_PIN gups Date: Sun, 6 Feb 2022 22:22:09 -0800 Message-ID: <20220207062213.235127-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207062213.235127-1-jhubbard@nvidia.com> References: <20220207062213.235127-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 431e5ffb-99f7-4c34-791b-08d9ea023a5a X-MS-TrafficTypeDiagnostic: BYAPR12MB3318:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:264; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rfc0Al0IUxK/TjjI6sWjNayEfVG05xSMkepvzALNtXSe1jf+vxqEm4HpGO5lcKtalbFWxhTDPCDVR/rX5vc76dFaWru/iBseYVC+V5JmiTfI6tMYfslds6wyBQVVy2VmBpmgX7oFpA2o2Hy44kirwqORIV9GSghUZN3ZowKzwR0G9tMMq0RIJG4kyoxVyqFIIzN+SsivHJLmxuhnk/Qvk+AgXN9GMJmlgzkma8eBJJB8VEqCijKT1JMvrhPY/fS3qpj3dCbwjOqsRqV/hf+eY76LX3bYBKy+EfgE0Mhk7MLCmxCGeiJdyFZ4sVwGJiWAMKFG0kNMZrwqdwDNOxsy6kRwYEtkvrkJi1jyX9pybiWBMe+a4JIyQ+vZP/nwenWK9YABuOOR2ofHfy+qTpcWLCDuvoB462PPovVzdtpbhUs6UBCs115LJjtKimqAgpMPCWEdt0QnTomHDlwNnerTgk4Y72EK/6KqbsHZoUwT005KiSNdIfPSA+HiC47ncN95MESOZrMm1L8x2vvbY1Rt6etH6L/VU41JnVt7sU7hfAOR/y1+soC5x2eC/c7z/HcEywfhAKBk40ySLj7JCC10ovO+XWhEzEdJEywLY6JsE7rzrOU9a7BKZRhqElq4jS5mltdtQ2/LuR5dLQf1Li2tvRHZ9GN0Sfnf9D0VcWLX6RAAdb4fOjkVtgJiL3uezrK10e2NDtiZlZXdeYxTCFOwNg== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(36756003)(26005)(186003)(316002)(54906003)(6666004)(336012)(81166007)(47076005)(1076003)(2616005)(2906002)(356005)(426003)(110136005)(40460700003)(86362001)(82310400004)(5660300002)(508600001)(7416002)(8676002)(36860700001)(8936002)(4326008)(70586007)(83380400001)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 06:22:33.8384 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 431e5ffb-99f7-4c34-791b-08d9ea023a5a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3318 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0A201100007 X-Rspam-User: nil Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=iz5kPco3; dmarc=pass (policy=reject) header.from=nvidia.com; spf=none (imf14.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.243.42) smtp.mailfrom=jhubbard@nvidia.com X-Stat-Signature: srq1tfx5x6mompaf5dsioefhqrtrfmw5 X-HE-Tag: 1644214957-188276 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: From: Peter Xu Alex reported invalid page pointer returned with pin_user_pages_remote() from vfio after upstream commit 4b6c33b32296 ("vfio/type1: Prepare for batched pinning with struct vfio_batch"). It turns out that it's not the fault of the vfio commit; however after vfio switches to a full page buffer to store the page pointers it starts to expose the problem easier. The problem is for VM_PFNMAP vmas we should normally fail with an -EFAULT then vfio will carry on to handle the MMIO regions. However when the bug triggered, follow_page_mask() returned -EEXIST for such a page, which will jump over the current page, leaving that entry in **pages untouched. However the caller is not aware of it, hence the caller will reference the page as usual even if the pointer data can be anything. We had that -EEXIST logic since commit 1027e4436b6a ("mm: make GUP handle pfn mapping unless FOLL_GET is requested") which seems very reasonable. It could be that when we reworked GUP with FOLL_PIN we could have overlooked that special path in commit 3faa52c03f44 ("mm/gup: track FOLL_PIN pages"), even if that commit rightfully touched up follow_devmap_pud() on checking FOLL_PIN when it needs to return an -EEXIST. Attaching the Fixes to the FOLL_PIN rework commit, as it happened later than 1027e4436b6a. Cc: Andrea Arcangeli Cc: Andrew Morton Cc: Jan Kara Cc: Kirill A. Shutemov Fixes: 3faa52c03f44 ("mm/gup: track FOLL_PIN pages") Reviewed-by: Claudio Imbrenda Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara Reported-by: Alex Williamson Debugged-by: Alex Williamson Tested-by: Alex Williamson Signed-off-by: Peter Xu [jhubbard: added some tags, removed a reference to an out of tree module, and reflowed to 72 columns.] Signed-off-by: John Hubbard --- mm/gup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/gup.c b/mm/gup.c index a9d4d724aef7..80229ecf0114 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -465,7 +465,7 @@ static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, unsigned int flags) { /* No page to get reference */ - if (flags & FOLL_GET) + if (flags & (FOLL_GET | FOLL_PIN)) return -EFAULT; if (flags & FOLL_TOUCH) { From patchwork Mon Feb 7 06:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12736916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5885CC433EF for ; Mon, 7 Feb 2022 06:30:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 683006B0074; Mon, 7 Feb 2022 01:30:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 632A06B0075; Mon, 7 Feb 2022 01:30:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AE0A6B0078; Mon, 7 Feb 2022 01:30:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id 3ADB96B0074 for ; Mon, 7 Feb 2022 01:30:10 -0500 (EST) Received: from forelay.prod.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by fograve04.hostedemail.com (Postfix) with ESMTP id 9EE5E9519D for ; Mon, 7 Feb 2022 06:22:49 +0000 (UTC) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 68E2991ACD for ; Mon, 7 Feb 2022 06:22:39 +0000 (UTC) X-FDA: 79114990038.06.8E8BA78 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2079.outbound.protection.outlook.com [40.107.243.79]) by imf09.hostedemail.com (Postfix) with ESMTP id CD1B6140007 for ; Mon, 7 Feb 2022 06:22:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dP9KxJMqfJhsx3J/YlU+Y+hb2KH3WUExWVKfGi/EK7DP9D03yZVPUSu9vnLHUc9qgKlcN4/wl/O188h+j4wMov3BNq9cwhEWarBEVdFVho1mNlfV64dtNxjpacHour7ondkMpVMCSR/5nMLZ0oNa3rZuV8BG1ONPp8ZIgPSfyM73UJg50GPhjLOsv5URDFSUrdqIiaYTl0ROvwe7PQwWbZcUPBfS1LHN1OS4TXr1kp1LmyZPVKkXK4AXgpE7zJkF/VfNWlrAn9lPXbsgWMISKPMDZ4u9bm+Skl+o9y9lEpX/7W8y2cQgL9oidTqMcNuDYnCM0nWoCV0x3tpFXZ8mgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9fyvjXSGsf7r6O7bQli9gyuzn1Mg9QRkvlBMVFHTNH4=; b=KMKMp/9oPutzcFyI+iYLaDNI1MYoMFoek5sdVpj7ByZ3KM5ZSrcNLZQ0iISn/VrKa2bKWHZhfHJp59CVT5SH0CWVn2yglg5kbDsdrjko4gfrUvM3Zx/UJuMtnCOI3pOwD+sjCDqh1ZvIwVAoFJ1DoocIea9daq6+/N0k9woHMTrgPBQYmP4rMbBTx4JL14ZnB2/8Ff8I9qOgxR7Hkimas6CUQB0fgnN7y4O2jN4ZWDRzFMEVjJB1tTkUh4rtd1CmHDTlTYJQKmgxbv01GIMIYVYJ7Xo4TlYpp7YYApcvQ9VGydUxqmPXAjh4fPwFTC4vxdxOtePWnVkYBGFTrZGTtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9fyvjXSGsf7r6O7bQli9gyuzn1Mg9QRkvlBMVFHTNH4=; b=ceZK/HX+QT1jRMU7fNU71rXWhKPMZb0mfoxHiO9MYcC0cnTj/mHFRNcoxxkwMxB6vKOpMbirmO7+gTeHLUKl/oBmnyru4VDY4z4Gx66YF5Mgy7mOy8KT4WULEGsDoZ59lujwbGVw5er8KaC9qAzi0pWk7FntHxm5S1FNxpF2igLXEW76XoY1+wEKgw/IDC/YtIY9ZDxdmPlnX/rLGFNGK+QslknpVFyyg0uoGZdhNZm8K5R3AMv002tr2keCPkBQg2vGy4JtdeKBZ8ORYyWWkyJxpCHKDsm7hHfVthWS7FAj0JhOUqFs+aYUFQEsnLn+r37YbnNpG2yD3aPeOr94Jw== Received: from DS7PR03CA0173.namprd03.prod.outlook.com (2603:10b6:5:3b2::28) by MN2PR12MB3167.namprd12.prod.outlook.com (2603:10b6:208:a9::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Mon, 7 Feb 2022 06:22:35 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b2:cafe::f5) by DS7PR03CA0173.outlook.office365.com (2603:10b6:5:3b2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Mon, 7 Feb 2022 06:22:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT047.mail.protection.outlook.com (10.13.172.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Mon, 7 Feb 2022 06:22:34 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 7 Feb 2022 06:22:34 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Sun, 6 Feb 2022 22:22:33 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Sun, 6 Feb 2022 22:22:33 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Christoph Hellwig , Jason Gunthorpe Subject: [PATCH v5 2/5] mm/gup: follow_pfn_pte(): -EEXIST cleanup Date: Sun, 6 Feb 2022 22:22:10 -0800 Message-ID: <20220207062213.235127-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207062213.235127-1-jhubbard@nvidia.com> References: <20220207062213.235127-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c1f2101-2dcf-4f28-02f6-08d9ea023ae1 X-MS-TrafficTypeDiagnostic: MN2PR12MB3167:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nj13Xrj8Pb7067NwzsEMzD6MEtlJp7KcwI613pjefclB8gXZM/PmrF96KHrUm3XSwKFDZ7YPioCzye4L+ZR8A2mtukfbYoZOCTkXOkYZPBl1EQLizH/+glJTFATHb3Vtn9r4A2A8p3XAM3SojbMjJlaKOVaTVRYGJpNODt6P/z+B3BQlQIBPGgl0EjASndOxcVTlCggKNz8mp9zLOKo/MlQGEZ6Mt1ALIz/an+dgQjVMfpxv0f6D06fgfa229D7+UiMFJVezSsaU1rY4NM+wF8u+IhnuV1IxZ0wSYL75q2evrDAsimIP2u9e1kwXxUMtmf9zLW8l4979to3yBV7VqH1mX4Gms4lC5hp9HWTMOpNhpltG0JXCPwXpUovUwG4xyEvswVKOxxLDZWvXLgexSIhIHz0lwoAun0Wc8cJNMRWg3s5Sxh/rS/xNxCHWg6SaI3lGxKO1X0f2vs7sA1qRLhT5UKRQiU/EHNlIzIiZvEOMNuatVZlUM+pHE44Nc7JU/zIzL+N2CV+UEOaFRDrpsmrwa8nRgRdOZNK4sV58shZwnUJJiLUbVJDx5dplGIZ8Fjw5gg47P0JCrOJrghB5iCOy6YF+OOMOGnMf5DFcf+BMU8b3fYiW2dRIC1MW5HvbL13z1tI05gm9ci168B+tmf0OAc/vM6Z93PJcetj5CVvBfLvO6aDGi/qRa5Ws1k1YCyU/Y3V4tK9N5HXbBNN8gw== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(8676002)(86362001)(2906002)(70586007)(82310400004)(8936002)(70206006)(356005)(4326008)(81166007)(7416002)(508600001)(107886003)(1076003)(2616005)(83380400001)(6666004)(110136005)(36756003)(26005)(186003)(54906003)(316002)(40460700003)(426003)(36860700001)(336012)(47076005)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 06:22:34.7044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c1f2101-2dcf-4f28-02f6-08d9ea023ae1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3167 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="ceZK/HX+"; spf=none (imf09.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.243.79) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com X-Rspam-User: nil X-Rspamd-Queue-Id: CD1B6140007 X-Stat-Signature: 54nbijmby1b6nz99yzm6bfciba4k1gx1 X-Rspamd-Server: rspam12 X-HE-Tag: 1644214958-599526 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: Remove a quirky special case from follow_pfn_pte(), and adjust its callers to match. Caller changes include: __get_user_pages(): Regardless of any FOLL_* flags, get_user_pages() and its variants should handle PFN-only entries by stopping early, if the caller expected **pages to be filled in. This makes for a more reliable API, as compared to the previous approach of skipping over such entries (and thus leaving them silently unwritten). move_pages(): squash the -EEXIST error return from follow_page() into -EFAULT, because -EFAULT is listed in the man page, whereas -EEXIST is not. Cc: Peter Xu Cc: Lukas Bulwahn Cc: Jan Kara Cc: Matthew Wilcox Cc: Claudio Imbrenda Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara Suggested-by: Jason Gunthorpe Signed-off-by: John Hubbard --- mm/gup.c | 13 ++++++++----- mm/migrate.c | 7 +++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 80229ecf0114..2df0d0103c43 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -464,10 +464,6 @@ static struct page *no_page_table(struct vm_area_struct *vma, static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, unsigned int flags) { - /* No page to get reference */ - if (flags & (FOLL_GET | FOLL_PIN)) - return -EFAULT; - if (flags & FOLL_TOUCH) { pte_t entry = *pte; @@ -1205,8 +1201,15 @@ static long __get_user_pages(struct mm_struct *mm, } else if (PTR_ERR(page) == -EEXIST) { /* * Proper page table entry exists, but no corresponding - * struct page. + * struct page. If the caller expects **pages to be + * filled in, bail out now, because that can't be done + * for this page. */ + if (pages) { + ret = PTR_ERR(page); + goto out; + } + goto next_page; } else if (IS_ERR(page)) { ret = PTR_ERR(page); diff --git a/mm/migrate.c b/mm/migrate.c index c7da064b4781..be0d5ae36dc1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1761,6 +1761,13 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, continue; } + /* + * The move_pages() man page does not have an -EEXIST choice, so + * use -EFAULT instead. + */ + if (err == -EEXIST) + err = -EFAULT; + /* * If the page is already on the target node (!err), store the * node, otherwise, store the err. From patchwork Mon Feb 7 06:22:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12736917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFD6FC433F5 for ; Mon, 7 Feb 2022 06:30:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 326D66B0078; Mon, 7 Feb 2022 01:30:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D6A96B007B; Mon, 7 Feb 2022 01:30:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1036C6B007E; Mon, 7 Feb 2022 01:30:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id EF7366B0078 for ; Mon, 7 Feb 2022 01:30:36 -0500 (EST) Received: from forelay.prod.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by fograve03.hostedemail.com (Postfix) with ESMTP id 2C9AE181E4CDD for ; Mon, 7 Feb 2022 06:22:49 +0000 (UTC) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DC69A8249980 for ; Mon, 7 Feb 2022 06:22:38 +0000 (UTC) X-FDA: 79114989996.23.DD96482 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2045.outbound.protection.outlook.com [40.107.236.45]) by imf03.hostedemail.com (Postfix) with ESMTP id 74AF720002 for ; Mon, 7 Feb 2022 06:22:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TgZfhUkLTXgaYE8591THaQiGtE/nTvmJ8/wQ/FGyBUhRNiLnGLEb86DWW9CgU5LbTkgQ5SublTEtvYSEwwjjCnJ74HC4d9Cp0RcnkSSBvH0M+tkBACBdXVZYhZMgwgD0PRwh4446WiWkvF4POaGN8FSE4GOHhH1kn+p6m/pMuybJjdn1yIWLgZY2G9f6ua7uEhkxftVoZ48qkErrkCcRlbfIht0pJqngVFiKeMc6s3xV58EQNcRq2DfhSdYl76XsU5q0FYDrSbJxP7Lcjr4tt3kN74Oy8BHYNK47OBR8BAqnD3b+3s4HQwUcUa4tAE4zorncSKfS2LJ6E7B85EM/KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VqmeqmDK9WNONzndgAGAbct149ZFM+Hb4kqc64wfHqs=; b=Sf2DfdlYwp3AWcyb5Pn2l57wjZ3ZGlK9gKcygIGbyXHPM1pNnnMUszCAecKuBigF+Mw4SkuS4r0k/vieZkIvf6ZQSU7IdzB56al5dRuUVJkD+hxYAjaBjAqJR7bWFWAGyWpYzHEREXNlBbDfBTW+eRZxi4vqOLvMEqFpSnkPs0NBsg9Pqfs2qasEeNmvMzN4BXki0W54e7wRuf3N5PKa9NZEPM+571cLIw9gwG0zla+OXy54dy2BrccYCFhhqqnLZ0dquAVUVomlhTAHTKAVmGMf3Bqc8+O8lCTGGUQzdFgVXho2/N01cpV4I/J4fT71ahkmvb45i5K03SsXMu+yxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VqmeqmDK9WNONzndgAGAbct149ZFM+Hb4kqc64wfHqs=; b=FPbN0QA4zUB4Fa99nhxNdAVPgFCWUs0tKB5cnURHl3l35F7E0rs/h9AlUiSbYNOnB4RdL5rPCxbtzZv4WJNDpJ9CvRX6DKeZJCA7wXCdoTZKlqq/nVKlIU4xfCe4iDAgPhmVsNAlFJ4OIZ+sboetqxDeoDkus62ot27EENadZ4oWWhkSThSvQ0MPeX516SXxW38WRdH1tp5gly3yWQyID7DD6H90YyLIEAYlCImh6IVLP1E6Z6WQXV26YNENxTtLoEMxVhqNY3xjFwqhXs+6vBVvWiAD384rLjal/KHtYdq6GZZaPkS+vkXtoc18id4muU3k+jnvaH37KmrRtb2iPQ== Received: from BN6PR18CA0008.namprd18.prod.outlook.com (2603:10b6:404:121::18) by BN8PR12MB3122.namprd12.prod.outlook.com (2603:10b6:408:44::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.11; Mon, 7 Feb 2022 06:22:36 +0000 Received: from BN8NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:404:121:cafe::ba) by BN6PR18CA0008.outlook.office365.com (2603:10b6:404:121::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18 via Frontend Transport; Mon, 7 Feb 2022 06:22:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT068.mail.protection.outlook.com (10.13.177.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Mon, 7 Feb 2022 06:22:36 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 7 Feb 2022 06:22:35 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Sun, 6 Feb 2022 22:22:34 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Sun, 6 Feb 2022 22:22:33 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Jason Gunthorpe , Christoph Hellwig Subject: [PATCH v5 3/5] mm/gup: remove unused pin_user_pages_locked() Date: Sun, 6 Feb 2022 22:22:11 -0800 Message-ID: <20220207062213.235127-4-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207062213.235127-1-jhubbard@nvidia.com> References: <20220207062213.235127-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3091bbf4-9ccd-49f3-66a1-08d9ea023bc1 X-MS-TrafficTypeDiagnostic: BN8PR12MB3122:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:972; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tmAyf3gT201eeVSfqvArpAzTLu7Cpx8Mn+QssOe1xn7s2bxtL3LhWBZkesaI3gktH1Q5cqW9SRfS5mYpznUZgvvzqCGx1HAKuOGiFSCNsO4i12TIhaabvaurw0QPpAm8MB149qeBlvqP4HkJWyePND1hakWT+w1eARgQuWBcm7RuzDn90UCUOcipXepcYRN9i66cu+3fASYq00AkrzWmaq3B0r85gD1rB4O7hVrY1wqcMSSv+Oe5vLxsHS+BeYxMd6xwcQNqgmOxxKTw3oMWDJuXUURuh6r/KBMhYPIFKoEH9T9ffa5zr77yx23dPCme67Un/bwBrJzL7Vk13rfDCT23uZR6qr1wY5v4l0i9XbyUqM5gtAWxtDS9MBDUkFhPNG+fO9FvpUcSKowRl+qXZISNafgtKtw776LjhiFXm7G1ZSVohPSQv0UEpL3o9Y4buW3vcWkVNZpVzqztCFSeLumDOo1QdZBMNK8BEhRVZpQsEFc9awctONr/qM8a7Gnsgb9ALgKHpjgQ6bEcLaYFzikCSxWgcp/+mnZbQj5hbnXHL6x2Zc47Uwm+4a5zyrIlCly7ARuoSsTdszghazVlju3pTpYwC08YMh1qI7BhjvrEPpUzloIoi3O5GqGYH5HtrxpQ8H5ahcrpO5AzNI3MWOW3Ghqlnc9ojzM8y74jJdrk7qHGGc0hQR/+0n4dEV4zl2JSfxXyVEY175XnMhW9QQ== X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(7416002)(186003)(4326008)(110136005)(54906003)(5660300002)(2616005)(36756003)(36860700001)(2906002)(70586007)(26005)(356005)(1076003)(70206006)(83380400001)(8676002)(81166007)(8936002)(508600001)(336012)(316002)(40460700003)(86362001)(426003)(82310400004)(47076005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 06:22:36.1438 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3091bbf4-9ccd-49f3-66a1-08d9ea023bc1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3122 X-Stat-Signature: 3b5qpatt4idwtuhtuwxfsbzu6by1j1f5 X-Rspam-User: nil Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=FPbN0QA4; spf=none (imf03.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.236.45) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 74AF720002 X-HE-Tag: 1644214958-154691 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: This routine was used for a short while, but then the calling code was refactored and the only caller was removed. Reviewed-by: David Hildenbrand Reviewed-by: Jason Gunthorpe Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Reviewed-by: Claudio Imbrenda Signed-off-by: John Hubbard --- include/linux/mm.h | 2 -- mm/gup.c | 29 ----------------------------- 2 files changed, 31 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 213cc569b192..80c540c17d83 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1918,8 +1918,6 @@ long pin_user_pages(unsigned long start, unsigned long nr_pages, struct vm_area_struct **vmas); long get_user_pages_locked(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages, int *locked); -long pin_user_pages_locked(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, int *locked); long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, struct page **pages, unsigned int gup_flags); long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, diff --git a/mm/gup.c b/mm/gup.c index 2df0d0103c43..6664dfa7a38f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3146,32 +3146,3 @@ long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, return get_user_pages_unlocked(start, nr_pages, pages, gup_flags); } EXPORT_SYMBOL(pin_user_pages_unlocked); - -/* - * pin_user_pages_locked() is the FOLL_PIN variant of get_user_pages_locked(). - * Behavior is the same, except that this one sets FOLL_PIN and rejects - * FOLL_GET. - */ -long pin_user_pages_locked(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - int *locked) -{ - /* - * FIXME: Current FOLL_LONGTERM behavior is incompatible with - * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on - * vmas. As there are no users of this flag in this call we simply - * disallow this option for now. - */ - if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) - return -EINVAL; - - /* FOLL_GET and FOLL_PIN are mutually exclusive. */ - if (WARN_ON_ONCE(gup_flags & FOLL_GET)) - return -EINVAL; - - gup_flags |= FOLL_PIN; - return __get_user_pages_locked(current->mm, start, nr_pages, - pages, NULL, locked, - gup_flags | FOLL_TOUCH); -} -EXPORT_SYMBOL(pin_user_pages_locked); From patchwork Mon Feb 7 06:22:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12736918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8820C433EF for ; Mon, 7 Feb 2022 06:30:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 60F026B007B; Mon, 7 Feb 2022 01:30:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E7446B007E; Mon, 7 Feb 2022 01:30:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19ECD6B007D; Mon, 7 Feb 2022 01:30:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 025DC6B007B for ; Mon, 7 Feb 2022 01:30:36 -0500 (EST) Received: from forelay.prod.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by fograve03.hostedemail.com (Postfix) with ESMTP id CB85C181EBF15 for ; Mon, 7 Feb 2022 06:22:44 +0000 (UTC) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CF13A181E5176 for ; Mon, 7 Feb 2022 06:22:42 +0000 (UTC) X-FDA: 79114990164.08.F6220B1 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.86]) by imf09.hostedemail.com (Postfix) with ESMTP id 4E28D140008 for ; Mon, 7 Feb 2022 06:22:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QvoNCWNZ2cggSDFZPLcpRrpp8Nn3I/yHTSTzTR4z34Y9nwJKNYhkmE7rIvslOADF5PCZscn8PjjGSIRZdneu4zvfQlxmswocwyKQfF37QOzKAXEKQRF1DCz6BdER1CwO66gL738BQUIDlem9XGiHwxnZQxxePF36RsXjf0qluYwpSzEQvXGlqQjBMTEbDSMKFCf2b1Y22Qp2xW2FJBfBGxewKcDvMpXkk7WnDIfp37IE0BTCngS5zLuYq3C27eyXQUBOi5Sv7B6GYm2afp10ytPCVPXGGv5Qo+jbowcpU57jVvKpN7qNWGuAzJ58BPti3Oi4TeNRYlpp8a51ipErIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DegTwE9NFEicYWZOblQZZlp9tH9DIXZWSkR7haX5kxY=; b=iZJ/EyUXau23ZjPhW3/Ud5BKYeC5fk/tAoZdlx7iNKcCn+9oQ0SA+IkE4Fkt0hEB5b2sfIWS9I9HG/7rgSEJecfokagbTFgzLNDA20Jzy2PfljgbZyY38c4pfV5s1XJCpkgMrWQbBsz3uMOYdBbDGmK77r0OqQOJAg2W1okXUT2BOYolMhtvgzxCBHU2OeuX9sgBwJTx7IugeMaXxpvALLuzR2tT25LLYJijkAomDtyA1KRdgxNZS0t3m4IrGihFL0JJV37iBEgwjNbdGIfHMwtVIeqQ4FW+sNtAejPmRHBQDB+iWEz5XAjs9ADgdzbL4ZPdmI9MfqQRsHHYU+ANuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DegTwE9NFEicYWZOblQZZlp9tH9DIXZWSkR7haX5kxY=; b=IyP2X8Higir6GnJJq5liotvtAIV7HUE2JYJq5I2gMRmFzWTJYgb3IUTaipf1KZRXi/uOHqJhTdk9HApnHaj4Zq0hDi7rkGDwzWN7CTIM4thGw8ku+u3/Un9yTAyLq9495z7D8hMIoSE6WE0JGTDOY6eF68TnB6tQOE19wZzkcOWH3cUgfERy5dqS0P2XzuBxNOR4BouXCo5fDf4kfD68Tk0QdTOrgHWui6OGWEjVCyLwItvLBLBofaLCGofvWr9Gw+Fuvc0zjZeRc8ztHJ5971/ECIBH/+9IhesN6yn+PiffDVmPGtX3bWt0iHgPettRx82nPSSBgpDn0vJ9yIY8ZQ== Received: from MW4PR04CA0151.namprd04.prod.outlook.com (2603:10b6:303:85::6) by CH2PR12MB3990.namprd12.prod.outlook.com (2603:10b6:610:28::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Mon, 7 Feb 2022 06:22:37 +0000 Received: from CO1NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::4d) by MW4PR04CA0151.outlook.office365.com (2603:10b6:303:85::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Mon, 7 Feb 2022 06:22:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by CO1NAM11FT020.mail.protection.outlook.com (10.13.174.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Mon, 7 Feb 2022 06:22:36 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 7 Feb 2022 06:22:36 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Sun, 6 Feb 2022 22:22:35 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Sun, 6 Feb 2022 22:22:34 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Christoph Hellwig , Jason Gunthorpe Subject: [PATCH v5 4/5] mm: change lookup_node() to use get_user_pages_fast() Date: Sun, 6 Feb 2022 22:22:12 -0800 Message-ID: <20220207062213.235127-5-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207062213.235127-1-jhubbard@nvidia.com> References: <20220207062213.235127-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 04adbb69-3679-4652-7eac-08d9ea023c07 X-MS-TrafficTypeDiagnostic: CH2PR12MB3990:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oX6KNGEXMvfcvZ0LNfd5jFRUGqKqSG1wL/5KqQk8Pk6xH14pa+HlT/cG5J+e4TzY/ennRnOzDTJZgbf5sROtOGKhdXjKDqCKHkd9ZOF3Qdi1SjTk3HkRUvk19tVCkHzSTPBJ3CyQAZkkWa8kLXUkwHY2HBZ8TDOI1dlFsj+dRtTapRXiU7QRX+LrzyxvhqOt7cAKHY6GOSoDEFW/amBi8MXAtif1HDmbx5Pv7EcQeJFyI+/0ttDfo3EIB5IaJEraaI5aRG9rJI54GVBuiz65VN9gs5xZnW3ugkQFKuC523Fy1hPq0CwOCOmzakyTuhOjhmFWnT/K1BEu8iz0mDjMN52V/8leGWnH9ZOhtUzclJlqM1eaMCBONH6gf21UIVtqDDt2yt0QXgJKplKysmcdzcGUTKUN9GYgxW2f7rRHX8+RLQXoC5R+ATPJeRtTzOVEbmm95iDu7LxntR+Vx2/VLKlatopRzH10GiwTPRx9XLip0rb639VaZomUh/olT4Y8gMU+DCj1GjeXkBocA9buGLwMMSwng9kFlDlntnWQMWgVlXLn9XeLSqPl1nYajK3z/lJfuyn17AgM1JOVhbyB/I9goto5R0IHdj891fctbJ70q2liWUFKN/uR8I6bK3r5HhxSkvXqFa1muX2UpXOjytmX81eppMTZHv6TwUZgQ5quis/A4JXsSGTIalwG9pRWe6pu6yhFacD43jhynRvGPA== X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(6666004)(8936002)(356005)(5660300002)(70206006)(70586007)(8676002)(81166007)(4326008)(36756003)(83380400001)(7416002)(426003)(336012)(26005)(40460700003)(110136005)(47076005)(1076003)(54906003)(36860700001)(86362001)(2906002)(508600001)(2616005)(107886003)(316002)(186003)(82310400004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 06:22:36.5563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04adbb69-3679-4652-7eac-08d9ea023c07 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3990 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4E28D140008 X-Stat-Signature: nbs3men4dcnkwnkzxpf57z35cpezfuj6 X-Rspam-User: nil Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=IyP2X8Hi; spf=none (imf09.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.93.86) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com X-HE-Tag: 1644214962-316925 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: The purpose of calling get_user_pages_locked() from lookup_node() was to allow for unlocking the mmap_lock when reading a page from the disk during a page fault (hidden behind VM_FAULT_RETRY). The idea was to reduce contention on the heavily-used mmap_lock. (Thanks to Jan Kara for clearly pointing that out, and in fact I've used some of his wording here.) However, it is unlikely for lookup_node() to take a page fault. With that in mind, change over to calling get_user_pages_fast(). This simplifies the code, runs a little faster in the expected case, and allows removing get_user_pages_locked() entirely, in a subsequent patch. Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Jason Gunthorpe Reviewed-by: Claudio Imbrenda Signed-off-by: John Hubbard --- mm/mempolicy.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 028e8dd82b44..3f8dc58da3e8 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -907,17 +907,14 @@ static void get_policy_nodemask(struct mempolicy *p, nodemask_t *nodes) static int lookup_node(struct mm_struct *mm, unsigned long addr) { struct page *p = NULL; - int err; + int ret; - int locked = 1; - err = get_user_pages_locked(addr & PAGE_MASK, 1, 0, &p, &locked); - if (err > 0) { - err = page_to_nid(p); + ret = get_user_pages_fast(addr & PAGE_MASK, 1, 0, &p); + if (ret > 0) { + ret = page_to_nid(p); put_page(p); } - if (locked) - mmap_read_unlock(mm); - return err; + return ret; } /* Retrieve NUMA policy */ @@ -968,14 +965,14 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, if (flags & MPOL_F_NODE) { if (flags & MPOL_F_ADDR) { /* - * Take a refcount on the mpol, lookup_node() - * will drop the mmap_lock, so after calling - * lookup_node() only "pol" remains valid, "vma" - * is stale. + * Take a refcount on the mpol, because we are about to + * drop the mmap_lock, after which only "pol" remains + * valid, "vma" is stale. */ pol_refcount = pol; vma = NULL; mpol_get(pol); + mmap_read_unlock(mm); err = lookup_node(mm, addr); if (err < 0) goto out; From patchwork Mon Feb 7 06:22:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 12736919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 119B7C433F5 for ; Mon, 7 Feb 2022 06:30:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFFD16B007E; Mon, 7 Feb 2022 01:30:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C5A126B0080; Mon, 7 Feb 2022 01:30:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A35926B0082; Mon, 7 Feb 2022 01:30:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 8C9CC6B007E for ; Mon, 7 Feb 2022 01:30:38 -0500 (EST) Received: from forelay.prod.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by fograve02.hostedemail.com (Postfix) with ESMTP id 8782E91ACD for ; Mon, 7 Feb 2022 06:22:55 +0000 (UTC) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5C310181E5176 for ; Mon, 7 Feb 2022 06:22:45 +0000 (UTC) X-FDA: 79114990290.27.0CCE186 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2040.outbound.protection.outlook.com [40.107.244.40]) by imf13.hostedemail.com (Postfix) with ESMTP id C425620003 for ; Mon, 7 Feb 2022 06:22:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E76WsFBEEIL8txT0I1sLAzVRfKUdInjRvcdUpzLTfFhml4ncZ6fAsPGNqIMVq74SK8Al4ug/8fGYBPP1xcUWySm93ciGYLVEquCLkGk8ZmrjH/f/E/xWow2KtQdqw8/ZpFrZU2NuK01VoTAyWKjWTFeu9Rvd45rjKD3FNZySx+98aYCW5mkfY7pxSM0jM01PWaiKmtkWS4oEwcejPul/2vKEEczfGOllEwxr2HRczMRTmKqHRgdVa4BWrUCUWlEjucHgi4OWkGF1vmsYXzil8easBAfGSI5aWpzkQH/M60bPrru3+Mao2uYdmhqR3YLwE2d79JQyYdq7SNDpeOkzLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IVfQ2qQS1xhMrtvuuVVoTMGpOrrX1QlZzQGiscYU/s0=; b=aVoTTPmfKbaXrC/ziRhycwomMEiSnBlrswT3m+f7c6pOeSa69TFvKzaLKCAjJoM0/dICjWSH+gPSMHDQP5C4S+o+yndilV9ybn1X1TwnAojOCeejEQaUZQD1wP2PdKcqZLji5fAPxqi84TwKWLu5ZVTQRqcuzAbKdrBXbQxDzq71PXiTkXDotnCIYbzhicgNpNtMt05OTLNJiDSWVHcAfk9RV/vTAsLXoGP+JqOhnOKT2bxClvzgU7YOTumleS6bXe4KB5jJOep8FYC5zY4xbuw6UHe+icv74O2BGD1sXbcpnYgvA7jTYJ6va7YsD5WJHgG4y2//0p8bZjxwYfsZ1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IVfQ2qQS1xhMrtvuuVVoTMGpOrrX1QlZzQGiscYU/s0=; b=gfSOlSuRFHOOsB6IKI4OxbxFhAP7iFkUVO5OZNVBXUJyPLfDByWDOyii6ll9dpyW16rdPnI47IawNkTLDGr8s7QCAemAPv7X22maYuUMPsS0dIBae3cXUuXR3R3IhRs4HGs2NXNNhOagbSw9FjtIUdxLhCsLcp/37kx6WglABRPqV7D761OoLcvigA90v00RX+fsoSwzHGLs/zZ3BonUrxrXnPyGO/M9SWA3gD0efmBaPdIKbAWPDEakBIo5dOo1A3pCnswlWvAfOAoUE5FfsIysGFARz6oOxdmakpj8tLImcy9cbQbGgNJ/xcLu9nVSZ9pcaT9vKzlU5f+RIB1Zzw== Received: from CO2PR07CA0076.namprd07.prod.outlook.com (2603:10b6:100::44) by BY5PR12MB4801.namprd12.prod.outlook.com (2603:10b6:a03:1b1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.11; Mon, 7 Feb 2022 06:22:37 +0000 Received: from CO1NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:100:0:cafe::4f) by CO2PR07CA0076.outlook.office365.com (2603:10b6:100::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Mon, 7 Feb 2022 06:22:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT066.mail.protection.outlook.com (10.13.175.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.12 via Frontend Transport; Mon, 7 Feb 2022 06:22:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 7 Feb 2022 06:22:37 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Sun, 6 Feb 2022 22:22:36 -0800 Received: from sandstorm.attlocal.net (10.127.8.11) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Sun, 6 Feb 2022 22:22:35 -0800 From: John Hubbard To: Andrew Morton , Peter Xu , Jason Gunthorpe CC: David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , Christoph Hellwig , Matthew Wilcox , Jan Kara , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , , John Hubbard , Christoph Hellwig , Jason Gunthorpe Subject: [PATCH v5 5/5] mm/gup: remove unused get_user_pages_locked() Date: Sun, 6 Feb 2022 22:22:13 -0800 Message-ID: <20220207062213.235127-6-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207062213.235127-1-jhubbard@nvidia.com> References: <20220207062213.235127-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af287de7-34a7-49fb-7553-08d9ea023c8d X-MS-TrafficTypeDiagnostic: BY5PR12MB4801:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xZU4mGKQgLeIvV6Lt8rxEPU0Ld0m7/fDXqezMbqZmugt8rWyNpTrJvSoNXO+lzjemgLlW56ZXJD/1SjI060Jcb4KWNPBlAhRmFfbwBOMVTIgfGpe3gjLPBJLSS1P63tLFtYV+jj12QW+UNbX6SZ6gXDn3XB+7LqIw6LARZZk07X1+RJDzZBBGjhOYsAsH5+LGxSOroxhyiC4ajAs7NS7Ah3lv4Pi2LwQfhyUU/De/f7zdBUrow6NksQfPIFJVdStfvScePq+/aIjWgWmZACJI2sObNPXhf+OODaEEZHWZe+Xa714s+D9kFqYCXdQQNoEjezB3hg1yTFhhYRbN/H4YmjCDP6FiR8p7NVQdK25KCGqeNUP9DPvIIFzTyBHQMvauHqe5mXZ1uOp9smCBz16JKbDBLtWAAr64Woc6Kx03wTlwzA8lulIwkFeb7UlI+wezGr6aFy2aYw69SIhZLfVlLAVyUAOjMZW65dAB8tNEWY8V2nAtGrVWvMFdPlGjzfalpsZSQ82D9ZozHUQubSXX+ATdDsa0BWeOcPmSb1DkR8SKay/JSBHJBTJ+Dcp2Ecit5ZD5eF+UCuImp3FI+lgagLL02DU/WBysoqwe+IUZlGeqX8MMaKZaVDI3T6/pPjCqWlx8KATWySreXk7mCHA8eLu0q6hv6C8EWwZ5k9Iq5VjMlfITAaoFsKfShztZwrrOK27hvY97QieTaX5ad9Y9w== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(36860700001)(336012)(26005)(7416002)(2906002)(5660300002)(47076005)(36756003)(6666004)(40460700003)(83380400001)(186003)(426003)(1076003)(2616005)(82310400004)(4326008)(54906003)(356005)(8936002)(8676002)(508600001)(316002)(81166007)(86362001)(110136005)(70586007)(70206006)(107886003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 06:22:37.5279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af287de7-34a7-49fb-7553-08d9ea023c8d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4801 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C425620003 X-Stat-Signature: asrkjzxpt3a3muehe66xdm96phucjipp Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=gfSOlSuR; dmarc=pass (policy=reject) header.from=nvidia.com; spf=none (imf13.hostedemail.com: domain of jhubbard@nvidia.com has no SPF policy when checking 40.107.244.40) smtp.mailfrom=jhubbard@nvidia.com X-HE-Tag: 1644214964-365934 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: Now that the last caller of get_user_pages_locked() is gone, remove it. Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Jason Gunthorpe Reviewed-by: Claudio Imbrenda Signed-off-by: John Hubbard --- include/linux/mm.h | 2 -- mm/gup.c | 59 ---------------------------------------------- 2 files changed, 61 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 80c540c17d83..528ef1cb4f3a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1916,8 +1916,6 @@ long get_user_pages(unsigned long start, unsigned long nr_pages, long pin_user_pages(unsigned long start, unsigned long nr_pages, unsigned int gup_flags, struct page **pages, struct vm_area_struct **vmas); -long get_user_pages_locked(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, int *locked); long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, struct page **pages, unsigned int gup_flags); long pin_user_pages_unlocked(unsigned long start, unsigned long nr_pages, diff --git a/mm/gup.c b/mm/gup.c index 6664dfa7a38f..7337520afa49 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2145,65 +2145,6 @@ long get_user_pages(unsigned long start, unsigned long nr_pages, } EXPORT_SYMBOL(get_user_pages); -/** - * get_user_pages_locked() - variant of get_user_pages() - * - * @start: starting user address - * @nr_pages: number of pages from start to pin - * @gup_flags: flags modifying lookup behaviour - * @pages: array that receives pointers to the pages pinned. - * Should be at least nr_pages long. Or NULL, if caller - * only intends to ensure the pages are faulted in. - * @locked: pointer to lock flag indicating whether lock is held and - * subsequently whether VM_FAULT_RETRY functionality can be - * utilised. Lock must initially be held. - * - * It is suitable to replace the form: - * - * mmap_read_lock(mm); - * do_something() - * get_user_pages(mm, ..., pages, NULL); - * mmap_read_unlock(mm); - * - * to: - * - * int locked = 1; - * mmap_read_lock(mm); - * do_something() - * get_user_pages_locked(mm, ..., pages, &locked); - * if (locked) - * mmap_read_unlock(mm); - * - * We can leverage the VM_FAULT_RETRY functionality in the page fault - * paths better by using either get_user_pages_locked() or - * get_user_pages_unlocked(). - * - */ -long get_user_pages_locked(unsigned long start, unsigned long nr_pages, - unsigned int gup_flags, struct page **pages, - int *locked) -{ - /* - * FIXME: Current FOLL_LONGTERM behavior is incompatible with - * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on - * vmas. As there are no users of this flag in this call we simply - * disallow this option for now. - */ - if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) - return -EINVAL; - /* - * FOLL_PIN must only be set internally by the pin_user_pages*() APIs, - * never directly by the caller, so enforce that: - */ - if (WARN_ON_ONCE(gup_flags & FOLL_PIN)) - return -EINVAL; - - return __get_user_pages_locked(current->mm, start, nr_pages, - pages, NULL, locked, - gup_flags | FOLL_TOUCH); -} -EXPORT_SYMBOL(get_user_pages_locked); - /* * get_user_pages_unlocked() is suitable to replace the form: *