From patchwork Tue Aug 30 02:01:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 12958601 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 6C901ECAAD2 for ; Tue, 30 Aug 2022 02:02:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1231940007; Mon, 29 Aug 2022 22:02:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC0FC6B0073; Mon, 29 Aug 2022 22:02:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 961EC940007; Mon, 29 Aug 2022 22:02:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 83BBB6B0072 for ; Mon, 29 Aug 2022 22:02:00 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 52F9440BFA for ; Tue, 30 Aug 2022 02:02:00 +0000 (UTC) X-FDA: 79854608400.21.0DC78DE Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by imf17.hostedemail.com (Postfix) with ESMTP id 460D540018 for ; Tue, 30 Aug 2022 02:01:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWEdgJ7jkPxk1VtWMsPJArrIG99buzJ0NQQ2OTczLNIswtpn0u0PCsYhWiw4cQ/Wg+4vMYD8ZeuorMbAoOR+fnZqfy78vwNB4WcHLfr0yWO4kg+zqxKL3qrZsF9G1Jph1xL5W6/GYTrCcutDnWSPWpLgbi6nxJHFuO9N5OFf0hM8Nbdk/OTyIcAN29tOeXtIxZJKg2jBl2hKLmxin7YFzYmgaVgo5s83xlpiHfrBLe0hVDY2iKxThbBh40I2wab/9xzEKwQANL6PV+TfsI/BXM6lo7Tq5CQDwOeWzKHXclvBe+YQUjamXFvzJ9tCtUwlYewMknRbBYAPKEP3uOaUjw== 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=rbWSjjVAeMIGNufXuh49GBFDvrvVHDRbO0qpQJzebvo=; b=Oao/6kiIx3YpCqamzva1DAjkYczaKU5d7YJ4oJN+uvOYwu6xECxZN3/IXbZJB7ioccm/6YB1Zgf4rULx4Tc1DWhbRMlkZCLFdGXKZLUyq7Gpg538itxFUM+xGvz5FbG4CaJdLZH+GurK/T5twS52lTbp00Gtd5Z9nVc+qNVRBBB4xm7ga1vuC0h5+str9ZyCmmTy+9kPpnOFWK1vsEOEmZiU9Wu3jMQsMjuumLZlsTwnfKCc3tGhNrqTwZeqayZP8K8s6ep2IjBzB1z1ZwHaRcLlvNMuD2WHYMFnUZx/H4ZLYpDfO4CzBRFNZEj7ff7RgMegZeo5+4xUEJi7JEUMbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=rbWSjjVAeMIGNufXuh49GBFDvrvVHDRbO0qpQJzebvo=; b=VpWoFZ9tkLrumylDupL0A9UcR0DukWuNVQaiacgVNHb8xhFb4OcIhBolpbUFc4P2i0yIKIFN/atNOYTVdUP7nuZGLwEclXAbPlqRp1Y3mBCuVo20rxe4/uQCrvca8R2uGaXEYCfSXVKvJKEvilqyDR9+zA/QGK1G4s+7+W2Rck+ORkw/8G2Ghq+W4PeZ9h8A8kQ/rvT80/iaMsc5neNGuh9Y23xg+4NGzU41iVSnPJc8gpiLc0Cxu1o6Th6j/Ma/0pYYBQ4+9O0f0r95fguYtSdjKlS06n40gDcSWZ3AbU3xzDlcKIB6NVhh97kVflio/8fegBgzAPA2nHjk+/DAQA== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by PH7PR12MB6762.namprd12.prod.outlook.com (2603:10b6:510:1ac::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.19; Tue, 30 Aug 2022 02:01:55 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::7432:2749:aa27:722c]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::7432:2749:aa27:722c%7]) with mapi id 15.20.5566.021; Tue, 30 Aug 2022 02:01:55 +0000 From: Alistair Popple To: Andrew Morton Cc: David Hildenbrand , linux-mm@kvack.org, John Hubbard , Ralph Campbell , Alistair Popple , Peter Xu Subject: [PATCH v2] mm/migrate_device.c: Fix a misleading and out-dated comment Date: Tue, 30 Aug 2022 12:01:38 +1000 Message-Id: <20220830020138.497063-1-apopple@nvidia.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SY5PR01CA0060.ausprd01.prod.outlook.com (2603:10c6:10:1fc::19) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9fbe5de3-fafe-40ee-9efc-08da8a2b9d62 X-MS-TrafficTypeDiagnostic: PH7PR12MB6762:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IlZ4StQoNxzOyjGGUlAC3tAd+63pQ2Ur7ClJMfJ62cdxLlNpkYns/LciFuhD9ewq/1qLFTIYFNRi7UCvIPe6lfVfxpG7SSUXXDfdobGLkEVtbWPpUQADVZlOxlkVT/6ZzWcvaS6Ilz0lbZhRnrP8+OnJomy5Ph5MYx+kj3PAo3ANUqlEBfFtlxcL+8QbKvGg50mZGSfzegd1UsCRCBS9X7F097pwCzvFZqwnYtTuUSMW7GcMcfTuqkI3B4ZCX7Gtozss2p2OiIt5AGzC9DLAKoRI+N8H1ZjCJ7DPzejOYB+BUTvbGWn7QkjS5L0E2+H6ZM61PTAKWl7RZnCKcBb5LSe+ek6t+WgkH/tW+Rafz5/2qN4i7dadB5hp8VPHoagtSPCOypw5N4EN5vQHFTW8xua0TlvS7eDsijUUv8N00N5dQtso9+hI7JRRzGtJdz2iR335xJ3UNSsK43mibmlXi9ioHGKy9DFHxfYxxp63zaLPuRw3B3O6o5eKxvNGrUfj+A24Mi8EXjglaq33C8mIlkadwpGJHys1hvNddt3PwKb3g3ezk47n+kDZiM8HF4l/YPEcpHjjK2zpmOjztUZVnmOr7gw7ykjgtJeKTBbISUov0iMmKPsLMXr23sArrbvYXeEVWs4Ud9PotudyAEBQBXhvJvK2JTVGeODYbPlgcsQzwyazlwUVWN9TE18m2nn+gNbPQEkiY8CaMi5TJ//zlA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(346002)(366004)(39860400002)(136003)(376002)(41300700001)(36756003)(6506007)(86362001)(38100700002)(26005)(6512007)(83380400001)(2616005)(186003)(1076003)(6666004)(66946007)(6486002)(316002)(54906003)(6916009)(66556008)(478600001)(8676002)(4326008)(66476007)(2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uJYV24d3QQNXOElxzS4PePe+56lvsLFtikXqirtzrX5iRp0iBeOxrFbagSXPr18FgsThivIt6iC6YRxu3pECFpC3S/o1zwzhCCG9OHek64CopdREmwIYd1Gq3Xj/J3Q7i26aeXZg/MEKvhiSIbmZwMwg57Kv5QdFXnl59H65SkMUrQZ0qWZCJF0G4NZ+V4u21ZiWoIDp4AD5cCLXb2pfi848z4yRp/4zu0xJBLVHnP1Y8DfFLv1T4ODwkXFkk2jauj/MC0JACruQ1fah/L9mJNqCyk3yrOWE/E/v0dwYauFvki6FJ8Y4rWLm9VcGE5oX+nOTHpv7zysk6n0ddVW9vyJEjSGjKSnNlYRUevhcI0gSoNQGVNeKJIYEJV5CG1RiQdeDupRVmx8yUk+KMWVAjz9uuhqYT6BuERrTG1dVTaeShzdqRzOSIe0D9CFwZ/2C5ovgOjFsoNQjSXNsqUemOkBlID5+mehj5X2RqJxIcZZaXAQIC2ekKEbGjwxP6Hpolfm82R0ySbd6O2JnoOSP7gKBDTKkmKOLgyZpiRFLozBWNd27PzhbjhqAtNyWpg51fxHGMcQ0WPULZm+oo+yuXNWEsMYUk0UxmM X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9fbe5de3-fafe-40ee-9efc-08da8a2b9d62 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2022 02:01:55.5996 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CDKvQTcwNeFMW0ma76VTU8DdX2EQ2blIPErZ/tdqhkd5lMgDkske3KmTrQQSNzArJRhVDz72oQIciknd4MYX8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6762 ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=VpWoFZ9t; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf17.hostedemail.com: domain of apopple@nvidia.com designates 40.107.236.40 as permitted sender) smtp.mailfrom=apopple@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661824920; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=rbWSjjVAeMIGNufXuh49GBFDvrvVHDRbO0qpQJzebvo=; b=2BPm/q4/6Co9Z55DE164WIS0dWVVPkh9SDuPMViHM2kIJv2ySCUoT6AhH4D/rLVB+Ui1p+ UXLCRCHOvWrq3/9tm9Ro0vDVt1Gu3H06jpzNqY6PLOnDsG9B85oLYuKcc/0V7ZnOaN/NHQ n3sgCf2VtFIPpxEFnpb8aKzkzJebqa0= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1661824920; a=rsa-sha256; cv=pass; b=uBGWcHoz2G0PYiVyFA34V8tcVxOUrd6qYdzmhDTgkXBL5K8Dgo9cf4iy7n203qmsAvYUSq kb6yn5HGqFQkCSeDmyhD4brqsGPCVhAkoySxSCGcqGEg0rooTsf5VOn1WZgPErbP2XNCOT 8/6PiBXIAXarBVnlE2UJFwEwDXX2xiI= X-Stat-Signature: q1ncnkx4fdm581etmb3z4wuyn6ccco1p X-Rspamd-Queue-Id: 460D540018 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=VpWoFZ9t; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf17.hostedemail.com: domain of apopple@nvidia.com designates 40.107.236.40 as permitted sender) smtp.mailfrom=apopple@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1661824918-923445 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: Commit ab09243aa95a ("mm/migrate.c: remove MIGRATE_PFN_LOCKED") changed the way trylock_page() in migrate_vma_collect_pmd() works without updating the comment. Reword the comment to be less misleading and a better reflection of what happens. Signed-off-by: Alistair Popple Reported-by: Peter Xu Fixes: ab09243aa95a ("mm/migrate.c: remove MIGRATE_PFN_LOCKED") Acked-by: Peter Xu --- mm/migrate_device.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 5052093d0262..9e7ec925ec51 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -179,9 +179,16 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, get_page(page); /* - * Optimize for the common case where page is only mapped once - * in one process. If we can lock the page, then we can safely - * set up a special migration page table entry now. + * We rely on trylock_page() to avoid deadlock between + * concurrent migrations where each is waiting on the others + * page lock. If we can't immediately lock the page we fail this + * migration as it is only best effort anyway. + * + * If we can lock the page it's safe to set up a migration entry + * now. In the common case where the page is mapped once in a + * single process setting up the migration entry now is an + * optimisation to avoid walking the rmap later with + * try_to_migrate(). */ if (trylock_page(page)) { bool anon_exclusive;