Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp569450iob; Wed, 11 May 2022 22:58:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjiv957IIwppUVi2xoQrTjIEKqwCacmc9Q9ScKsx/64ifLllYgbKrztMaVK+I5vWT12bjy X-Received: by 2002:a17:902:7c13:b0:156:ca91:877f with SMTP id x19-20020a1709027c1300b00156ca91877fmr28490834pll.15.1652335132066; Wed, 11 May 2022 22:58:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652335132; cv=pass; d=google.com; s=arc-20160816; b=VeA9hVmMk7NKCKgW6tWpdYuvlokXWd8Uz/YiblN8KcquT0GwqTgctB/q49+b8hS964 E6tFK7tHh1dMepZzrTe5aF11GZqypQOoDo9PRt9HJJiJ2/YidVoaELqGR3c4rwgzuB4W Okyzd7FPCHtYOQIrxdhePiOhJNjRbn0OTkpnFla199SggWUg2JbF1jc/bP+RqwgJpRvK qm8AuJ1EhBwmNE+8lw4KHpaq3l+MESIaTpLYDF23TEjNl5cAvSvfjsgAHaYfm2OH4VG/ FI/drO41lmjKDRQNirEiWetza3lNVppVCkKVB3igh3LPbJ9AVWU6YvylaFVCJXVS2+bq DgyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:dkim-signature; bh=DaexaYEwujO48q287Trhj9X5PhJm400sAtz9sET7r04=; b=fYLZkX8sckIPfaE/5ZViJxGxJmyNZ/sqYiEAC19XuLac+2VKWsYGmFTOGfntluYzfO NYIMk3ggZFlxoEyI9ksy+VE6wJip8vEUv+ki2c60tJ2eJQMvUB3UASNgKxafh47NVux/ uL5bMYVnqeQeLWG47FRJG17SpdKpv6t1StaqXchaD1Amm9FBBkd3ELtQtHE9Qm4ZAniI 7zTSFfgQteLCfRxSI8IY8cju1UYT/6Hsr9VE0cVYzyHrkUCkeCP/q8i5/PP6ZGyHnDv3 0pu5nseVm+hHEVla8ahXQIbqvR47XOykNFf9Y94BzaVNjn4bg3ijdEep4JIvOUE8x2Z5 /PuA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Rofs7RfN; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ba2-20020a170902720200b00158da867027si3995146plb.624.2022.05.11.22.58.19; Wed, 11 May 2022 22:58:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Rofs7RfN; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241220AbiELC5o (ORCPT + 99 others); Wed, 11 May 2022 22:57:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239781AbiELC5m (ORCPT ); Wed, 11 May 2022 22:57:42 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1A054D9FD; Wed, 11 May 2022 19:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JoOUnNAcq13YsTuP3sNLF5JofphHe8u+VypkCnuDuIjcY/EtNh88Wg5q7dwilXCDz0Dq98g37MBS5DPLgvX7S1la+jhXFmzQXCMZCMIzwfgFsNsRfxl7GD07HHMC/WnLeNLlQDKrSdGnhH+3C/w8cn6VTYHeOAkaCkM+HCbPZgNiDCWwVm5DG/wOgUceVn9G1b3AEZtPsIhiWKyIuIpK/Jl4Z/Kz+B8fEZEBRJzLmsi2kMPaXsZdv/vry3FAKp6aV3q5JBUiEe/jUWqxWUOua4YEl96a9lJuvLr/nghLtnc9Ztqe/gOiBTieewhOw6EqfOpjVBvmW79SPbNRzyirAA== 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=DaexaYEwujO48q287Trhj9X5PhJm400sAtz9sET7r04=; b=XrQulxvCOz1fVXdsm8CesgSRl5TVHvtI0rRZztOx+EoHCYMC2V0z0cygI+Vc3wtH8En30CiGdXZbOW9Vn6xTVOn6zUoO4XEHTNpILxAYgLrG3KFC2bZtLBfWoUF+2pHAuT3BrcqbE4N4rL6rhtkC5MmpobjQA3+xuVG4WCI0oQ34MvyZ1piIcchXo2FcyJ/HC2nH/33UHZyvMsYkpqZAvkzjSJaWG/zhcsPEhdsZucM2WVEDAMrrtiKaMrs4vLZHNwcgxCLBvRZufNstcksl8E5r8l7PTUu8itjtlEffxEbU1tEoXVzfjgE7cCaEtnvVuscfcnVrngqUFAV8Yx4WUQ== 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=DaexaYEwujO48q287Trhj9X5PhJm400sAtz9sET7r04=; b=Rofs7RfNCoPVwBeQxAdWQicegq4pTvb5UXy3ClJdkeXoWk02a/aZrvo3/0GL8nmY5MK5sruJ63t8CJl0jYXkxuCGNN9GBIfzGsnED9augUWplwwKYLSqwTuBonVNs7BYINXJ6zr8lDZwzxPLzd/kZeyzdJmgV3wNhjzc150Tp65e9QXqiBcvje1m/7TtmKt8LRYeb6HESzttUpLLJhNmNFuyeVDGwPB6IPZt0jp+UWBfnFy7Gccd4UrCzL9uP36vVtuWq4uZcxMYwzWcXdTLZ1QD8D51su9IEhfSs9bJgnmPAGGTtCI3fZdkPBJQBgP2c2W3JkkhL8jeIZURTgRUDA== 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 DM6PR12MB3836.namprd12.prod.outlook.com (2603:10b6:5:1c3::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Thu, 12 May 2022 02:57:38 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::2d17:b68a:e101:4c18]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::2d17:b68a:e101:4c18%6]) with mapi id 15.20.5227.023; Thu, 12 May 2022 02:57:38 +0000 References: <20220505213438.25064-1-alex.sierra@amd.com> <20220505213438.25064-5-alex.sierra@amd.com> User-agent: mu4e 1.6.9; emacs 27.1 From: Alistair Popple To: "Sierra Guiza, Alejandro (Alex)" Cc: "jgg@nvidia.com" , "rcampbell@nvidia.com" , "willy@infradead.org" , "david@redhat.com" , "Kuehling, Felix" , "amd-gfx@lists.freedesktop.org" , "linux-xfs@vger.kernel.org" , "linux-mm@kvack.org" , "jglisse@redhat.com" , "dri-devel@lists.freedesktop.org" , "akpm@linux-foundation.org" , "linux-ext4@vger.kernel.org" , "hch@lst.de" Subject: Re: [PATCH v1 04/15] mm: add device coherent checker to remove migration pte Date: Thu, 12 May 2022 12:39:16 +1000 In-reply-to: Message-ID: <87fslfqwyo.fsf@nvdebian.thelocal> Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0259.namprd03.prod.outlook.com (2603:10b6:a03:3a0::24) 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: 73d153d8-e246-41f9-25a6-08da33c32c47 X-MS-TrafficTypeDiagnostic: DM6PR12MB3836:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w/pPmjDfbxu3ft4PrCPoAJpYKVUdyoKgAATBVvg8dKkLJYlaujobsFJKG3LbbYmlgXHh2CJIXatw0lNp6aOsl6h4+qyFRGO/TSDV8TlU3FN5949HdC9BAc3xFHT2kusVtqc1boldRPSImsZ0L38oOKG6k2fgxvpoUOc4Z6t35b6rpvGS/YNTS75kAAr15nRt6CeCxH8Xr4l3ZxZhsLZqQEtl3lCpiSbpuXIrqFLuAr5fu3v0Iw3gBmO0ReAhZsh1iHvYTJtLrJh8aZ/nf0sVQA1TNrlvQovgkB6UaOEXsRBLS9lpF3Cee1tefi6eIElX51s7zmB9k1b+F7pfQngKsgMyleyojW41u8HaFSr+L3GpU/llx3LPz0YeKgLjZbpFPDOB4NzxoMgSs0wpw41+VAYKO1Ma+ef1RKeoC78N24lSRBQsfmSe1j+U5dVVzYVeZAMiilnBue20lIEyfdmxzvyTLA0rOjRM7vXxzEwo1QGKh7N1lGanSUrrxXKWfrfDHCZKQ1WU3GkpIrHVR2EQLRWfEebAt3lhyqNeGsURuMRPm7XGoBafd2qoEoRV6n985LXi4L3rgnADy5ADp+AQ0ejpr48ERSwmu9CSjsROwcFceBV5VKFvNY7G/25u8IpJOXkd4ksivf/k/XZYin7Hof9d+zDKJdxFgZhNKYQ2a3TaTyAg8OhI+YqbDQlVIqXeMYnydP69UJ90xgz9dm9I2hn1KY6Zkyx4WpQ/El2lrcs= 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)(53546011)(66476007)(6486002)(66946007)(54906003)(508600001)(4326008)(8676002)(66556008)(6506007)(6916009)(6512007)(26005)(9686003)(6666004)(38100700002)(86362001)(2906002)(8936002)(316002)(186003)(5660300002)(83380400001)(7416002)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?P+O5kbRwh0tJFrP7gNfNVaD/xRBVVkGEHYZjDJPhxgqRkuQ3IrTj9QY2UkC3?= =?us-ascii?Q?ZKuqN4kNiSiNet0yMJBBGapBnIj0LUHHBcEBHvO3kufYljOqyjpHM5zDNJf6?= =?us-ascii?Q?sx3nU0wsw3A4Zfu6pYeAQctjqxk7Y4ColL6qTvbSaYGk7P1iNc565qVjBLV+?= =?us-ascii?Q?hjsQ2bgeX9u25bTAFOXEudAjtvJqMjDvwab5q4+N1jbyyKxXI7SiZhplAWOQ?= =?us-ascii?Q?1F5rzp3jSuJxjFwY160MS2Qu/oCylmkAM3gTFU0OdYb1qzIyPY5thmdUK8fM?= =?us-ascii?Q?zaTXoO9uV5aeJp2D17KBTQ53dHmqTlDMOFejuMrzivyiBG14PO7g79CkDJcD?= =?us-ascii?Q?THYOIHWuDRwwBEnvT66wYbhkl4ngw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P2+aNX2OOO8a2qLED7W87qHBf9ZP8GJZ7LuZxV2tA/EXrLSCXtCu/B?= =?us-ascii?Q?rC4jCw6mH9RnkMQ9Ls/3UTTFb1jU6mO6M2NmCDq4RLV/ZcP2tTHjL59frp5A?= =?us-ascii?Q?/Ly1zY7KE6311RKtXjuqMt5ydTVUFyvrLs6sNT8X0KTmLjA7dE/Eut99Yi11?= =?us-ascii?Q?RCA1C6MqNZcpGfNza2IiqdORKPFfxBagpIVUrm1QPCuQnKvYMB7LHrZEYgNI?= =?us-ascii?Q?RSUfp9Jfv5fJ88NKkB8VmzjdrsPRu9AP8tBX/+9UqZ14GOmRbmYiVuYAfuPM?= =?us-ascii?Q?GGWDzT014xZxg8IF3J1YQ7S1NXPGWRXmM1LxEXm9y+K9HVszvttRkPPnUThP?= =?us-ascii?Q?1yfEjkJADdaTw00DL1wIQW3GJAkXcm/vYM7XIuIgaEXmTUf2e4dPdzGQK0dj?= =?us-ascii?Q?wxZy9t1s2PJCIQs9zm8gk+6RsyiPkmtNXoVC4OlRAFW/FGw11eoS0Os4WOZg?= =?us-ascii?Q?0BvEjoRmLg=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73d153d8-e246-41f9-25a6-08da33c32c47 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2022 02:57:38.4908 (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: 6qDQ2HV38/aF3MMNFuDDqDNoSUEBtv9J2drnDa+Z7zhbMM1neZw5lh1hApa91kri7xq57Kr2HVfQCoBj7Vsr5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3836 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org "Sierra Guiza, Alejandro (Alex)" writes: > @apopple@nvidia.com Could you please check this patch? It's somehow related to migrate_device_page() for long term device coherent pages. > > Regards, > Alex Sierra >> -----Original Message----- >> From: amd-gfx On Behalf Of Alex >> Sierra >> Sent: Thursday, May 5, 2022 4:34 PM >> To: jgg@nvidia.com >> Cc: rcampbell@nvidia.com; willy@infradead.org; david@redhat.com; >> Kuehling, Felix ; apopple@nvidia.com; amd- >> gfx@lists.freedesktop.org; linux-xfs@vger.kernel.org; linux-mm@kvack.org; >> jglisse@redhat.com; dri-devel@lists.freedesktop.org; akpm@linux- >> foundation.org; linux-ext4@vger.kernel.org; hch@lst.de >> Subject: [PATCH v1 04/15] mm: add device coherent checker to remove >> migration pte >> >> During remove_migration_pte(), entries for device coherent type pages that >> were not created through special migration ptes, ignore _PAGE_RW flag. This >> path can be found at migrate_device_page(), where valid vma is not >> required. In this case, migrate_vma_collect_pmd() is not called and special >> migration ptes are not set. It's true that we don't call migrate_vma_collect_pmd() for migrate_device_page(), but this doesn't imply migration entries are not created. We still call migrate_vma_unmap() which calls try_to_migrate() to install migration entries. When we have a vma migrate_vma_collect_pmd() is a fast path for the common case a page is only mapped once. So migrate_vma_collect_pmd() should fairly closely match try_to_migrate_one(). I did experiment locally with removing the fast path to simplify the code, but it does provide a meaningful performance improvement so I abandoned it. I think you're running into the problem addressed by https://lkml.kernel.org/r/20211018045247.3128058-1-apopple@nvidia.com but for DEVICE_COHERENT pages. Based on that I think the approach below is wrong. You should update try_to_migrate_one() to deal with DEVICE_COHERENT pages. It would make sense to do that as part of patch 1 in this series. The problem is that try_to_migrate_one() assumes folio_is_zone_device() implies it is a DEVICE_PRIVATE page due to the check in try_to_migrate(). >> Signed-off-by: Alex Sierra >> --- >> mm/migrate.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/mm/migrate.c b/mm/migrate.c index >> 6c31ee1e1c9b..e18ddee56f37 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -206,7 +206,8 @@ static bool remove_migration_pte(struct folio *folio, >> * Recheck VMA as permissions can change since migration >> started >> */ >> entry = pte_to_swp_entry(*pvmw.pte); >> - if (is_writable_migration_entry(entry)) >> + if (is_writable_migration_entry(entry) || >> + is_device_coherent_page(pfn_to_page(pvmw.pfn))) >> pte = maybe_mkwrite(pte, vma); >> else if (pte_swp_uffd_wp(*pvmw.pte)) >> pte = pte_mkuffd_wp(pte); >> -- >> 2.32.0