From patchwork Tue Feb 1 07:05:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 12731430 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90657C433EF for ; Tue, 1 Feb 2022 07:06:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234378AbiBAHGr (ORCPT ); Tue, 1 Feb 2022 02:06:47 -0500 Received: from mail-bn8nam11on2057.outbound.protection.outlook.com ([40.107.236.57]:31777 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229987AbiBAHGq (ORCPT ); Tue, 1 Feb 2022 02:06:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QJBnV8NXSyQ1MNLXhKAy6u8Wx44H8iybl+tjml1WNaYYNk/5pNiWLKCoL5U/GvIraOkFOcF6blZiNqqpQ9BWY0n3SXtYm79UaJLgYsdslQGi0rHa7mRUrIyN+/9Knu1godJ6nnAhz1ndMtxkISNjSGt3COT1ce1wEvYHy/j+0/vPaoOvxACvu31anDdP5QKSfYFwz2E46VaKZL9RmiMe6ZUoiPz4YqqlI14urYgdxwX6ulkP9rlFkl1ZZ1Rc5crOf7CQ1myFIabYu5m+SdX+lvJbwJ7dSIvIA3pDHzLtafKs+Nl/jQZTQBAMe/On9hUzgOJcW0HLTkUFyckc8FvoLg== 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=PQ6LFUw58IhtHcaNI9ZjfoZam2GnuJDjPgplnJRKc/Q=; b=HbFBHkLkbvP3uRNECwJyBALjfI/UmSLGXUOZ07446n6Rt6iy1IR4GzC/xkTqgurAMWWyyshvK9AnN/sGgwpSqHBtzOfjF85o2AJXteOrnhX2LAlvR45pdigIShR84rHcEfqrcPCohoLfkO11qyTZJcgODn/eJPfiRyt9iQag7RJ1OAjc1WyFTOuduupk0LlTXKtkyOAg3F87ms/jn4e+gb9CbZWr5hQnpQ6cksnD2dIkyjiTVAG5UtOMcTEG/QIfG7vJ3JHsJm62m9L5EW/dn6V1zN4i65e3FDHafYWeVR3ehx+5Keed/82zs5s9qQa1m5b+inq0rxJgYZgA+KSklg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=PQ6LFUw58IhtHcaNI9ZjfoZam2GnuJDjPgplnJRKc/Q=; b=cmGQ7K5hu7bBBamvK3PlJ4u8sZLtzmWBY7uNB6uL2+hyelaWRt99uwZELD3bvmfMMYZEjlpWl/5H6FO1J8niE/LOKv/qMzjBTEUIsCd8TEOyCFNCjVX3KOWtBurUazExJJw2du+jsIZ6KlRECXA8cE/8AsGAK2KMNUmt316qglOQu2LqKteJ+G22Px8rF++hvYe3A42Vapx68GYZy0u7ZUwfuqzwH637hJ7fvH0MwZImC7hU7fiY/7E4dGT+GpDq5gjINy2Zg5N43e67iGmMDKexyxLT4bXcJWMs7wx5tqPcgaGkKZkgcH+2riGL2mT99H4aNlqRjZy5D4GYihOBbA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by CH2PR12MB3991.namprd12.prod.outlook.com (2603:10b6:610:2f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Tue, 1 Feb 2022 07:06:44 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::48bc:2cb6:45e3:41fd]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::48bc:2cb6:45e3:41fd%4]) with mapi id 15.20.4930.022; Tue, 1 Feb 2022 07:06:44 +0000 From: Alistair Popple To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: Felix.Kuehling@amd.com, rcampbell@nvidia.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, hch@lst.de, jgg@nvidia.com, jglisse@redhat.com, willy@infradead.org, alex.sierra@amd.com, jhubbard@nvidia.com, Alistair Popple Subject: [PATCH 0/3] Migrate device coherent pages on get_user_pages() Date: Tue, 1 Feb 2022 18:05:54 +1100 Message-Id: X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BYAPR02CA0065.namprd02.prod.outlook.com (2603:10b6:a03:54::42) 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: 5d45719f-e22e-4606-94f2-08d9e5516789 X-MS-TrafficTypeDiagnostic: CH2PR12MB3991:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dH9+SqoasWTXDJUfFKYQyJWQZLnV+yCmHB2XtbG01x12nWNBDHhft0B3x98+4WvBxCXD8UnaRC04kdw0E1OxiY1d2eOdns4J6g8DMU28wvT1rlxb1g8cO94kw/iYEQFdtOyJuLZqb2ke9z4zsiR9H5pSU+/Ji4DSwxbwmBX2HANY7iES56lStrQGBvJIpf0/pHkkhl+hPaOXQ4hb42X9K7axuMURnyYt2c05XyDYqiBadhfwq+rJyxtLjBxuXsro9B27YR646H+WPVn/PQJVjB+WVij+WAqcN4qXFt3uXNIvPHMsUr94DsZ11mMSouCNaS9XBgsTH9kktnbh7gla1rXxX4b/26SaK8YYYcbO2qskjsX4HEzV9GeLg2CsiGnbaI2eBcjnlcf/kLlrqPaXNw6y0z2J0BPkCA8olAajqsuJCwC5sETnsDVXVLkArfYiuO/h9FkF+3z0JGbzun/IY+e7pX5mGocD72hs0wYeyw6PlGOOWFsCND7q9ZpGJFYDnSfjiK3DnLBYV/Lh9WxNegJcn+HMgdcSe/na86iF6m9pw78h/87kf8+jAgCnGBeKz9RYlZZ6b5l0Zk8fwrtkMZp8568NYAl6xHOChlkmETwNRqFlAHAgxx2dHJmYTuGLw+tYQYNGg9nwfwyPN1rMgb8yuT2q1y9cwWx/+/cljsAkjhq4HCGfXLj009XNBxih++8LdoLRX4qGr29jeyGXpjNxpAz3PFjPVT7wo7FGhxY= 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:(13230001)(4636009)(366004)(508600001)(86362001)(6486002)(966005)(7416002)(2906002)(5660300002)(66556008)(8936002)(83380400001)(66946007)(6512007)(4326008)(66476007)(36756003)(8676002)(186003)(2616005)(26005)(107886003)(6506007)(316002)(38100700002)(6666004)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yJpSR4Ivpl2uU+CRF8EpOKvxWKNIOO1dh8ovOiqjLTAM7XtAKkh7sLDwu9/wnKQmheOLu2ZJaWAteJWn+LLh4XhVd8H2YLkNrdTXgGV4NmaUb1gX28+ZSeJ52FynX2U3rm4NI3pX3eTsJ3CdE8bKDMeJ8PVNm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y08icSC0YAPAzYMi12kBNuZC0cdO6iBkd+oeHQoKy22210gwlVuLXm9x5oXZ1LHLisZJbo8brfnWQJUxYKnO5wM7cbxUqtghfg2Q6hWfQ3JKPaGVRLCqgxPi5I7tauDmx5U399bUbDXAMOPp/cx3y60q3ZGufWuH9p5oCwy/qpeZJrQbxFhzdJhMkXMXx34YlG53XKXIwjImMlEDMJknFyG2jDLxbnVBT9C0Vm9DfUEFxet4jerFG/gbnkxNaK0BKSgmG92+WCr6wJ68mv1SXBxJEgkcpftet5qTm0qCHopN6jeMuWaBuPB7a4iXt86J1yGLhZ1+QkHlvwt6qqNJD38x/CEWTtciUyj62TpdPFklY72YrFHj0TbTBb/4mw5C9Qfdt8XByE3WaURJYpZ5vOYw0rZoNNvM4abkoo= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d45719f-e22e-4606-94f2-08d9e5516789 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2022 07:06:44.4473 (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: uIQg5Zp1O8fPY1y392cb2jjQlTsPm3bFnXXyuTZ19vMOKGGQL2s5X6cQrGWgpBtzTqi65N+TRR5Rm/Js5omEIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3991 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Device coherent pages represent memory on a coherently attached device such as a GPU which is usually under the control of a driver. These pages should not be pinned as the driver needs to be able to move pages as required. Currently this is enforced by failing any attempt to pin a device coherent page. A similar problem exists for ZONE_MOVABLE pages. In that case though the pages are migrated instead of causing failure. There is no reason the kernel can't migrate device coherent pages so this series implements migration for device coherent pages so the same strategy of migrate and pin can be used. This series depends on the series "Add MEMORY_DEVICE_COHERENT for coherent device memory mapping"[1] and should apply cleanly on top of that. [1] - https://lore.kernel.org/linux-mm/20220128200825.8623-1-alex.sierra@amd.com/ Alex Sierra (1): tools: add hmm gup test for long term pinned device pages Alistair Popple (2): migrate.c: Remove vma check in migrate_vma_setup() mm/gup.c: Migrate device coherent pages when pinning instead of failing mm/gup.c | 105 +++++++++++++++++++++++--- mm/migrate.c | 34 ++++---- tools/testing/selftests/vm/Makefile | 2 +- tools/testing/selftests/vm/hmm-tests.c | 81 ++++++++++++++++++++- 4 files changed, 194 insertions(+), 28 deletions(-)