From patchwork Mon Sep 13 16:15:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sierra Guiza, Alejandro (Alex)" X-Patchwork-Id: 12489907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EB31C433F5 for ; Mon, 13 Sep 2021 16:16:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 53B0360F58 for ; Mon, 13 Sep 2021 16:16:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 53B0360F58 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2CB116B0074; Mon, 13 Sep 2021 12:16:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2542B6B0075; Mon, 13 Sep 2021 12:16:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0558F6B0078; Mon, 13 Sep 2021 12:16:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id EADE66B0074 for ; Mon, 13 Sep 2021 12:16:21 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 723C918066 for ; Mon, 13 Sep 2021 16:16:21 +0000 (UTC) X-FDA: 78583052562.13.CA36DC5 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) by imf18.hostedemail.com (Postfix) with ESMTP id 050484002098 for ; Mon, 13 Sep 2021 16:16:20 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qe8yKQlvNjE2E+VDJ6UI0yPFHKEN3SYbQ8MKMcBP5t+8YKazyniBfrCGULsumbgL2S3Eq0I02+JQpDJ4UiSH5WFAsGj6rALzI8aBZHB1aK7nydPOyf5N4xJRu9TZ9M7crWzHf2iEGdMWnXRpMaUkGYAyupxYnHWY1BNPJZPmlpQD7lix3+/jtO7qoh0gLQmdf1o0dfq34ZHj/KuQg5SE+Yf0U+hPH8jDO4A2EZYst6PfdgBcFdB4pPGyDAqNWBqORHrjF0dpEWAz2unfZFKwhztZvqxgWedHjOE8W7JIwVBFwTfTATn5MBW9budI4M199XcfBNif75tiRYhUPCGWqw== 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; bh=82oeVwrYnrtoo3t65wmfHCT585AIRkrgZr2iPzW4COc=; b=NxziQBkI1RHoURCFg3Dk/U5t3vzRADJfFlu6j3DBBJiaoBt5yZT+XGs+2X8thPpLoo1CLWf9vn30FUVaU4Do7JXyAjWzoajaKL8PARwpTmx8Q0T/cgHnJtRjRWzmKAzY3rwH5IWojIh73ESOxiU2JfR7LPK4x2WgITbKgOy8NWLwZWz4Olmw5qtRH+2LHnc3FFteEq1+iCIXFNFrYSnTLmKKJFuIrLHMuyey0ewFxkLU0OcAo4SMTOSK6FgLtJ1KfzrXaJ6+DulicUibiJQQtGHuWrnRe2QWHhDfQa8oqCWPmYI3AkSnd9pmBwW3hesQ8sySMk/EQnlMNa6muOeH6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=82oeVwrYnrtoo3t65wmfHCT585AIRkrgZr2iPzW4COc=; b=EUy21Vz9/NRMJvAW6zSJDrL2DIa0UcrGjA4rfCBaGpZLthQryqMA5lEQuVQwzLJnKBBNPvJK6jnhgEFWiVMgLBX2i//cymA6vme5AnrAxYNqM7ckTfgyjr0zC5xEm5emaVzdE870oAncUI/eWYnKQQl7WZgWVBE8voAmQpYgqyo= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Mon, 13 Sep 2021 16:16:19 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::f1aa:9adc:b4f:4d14]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::f1aa:9adc:b4f:4d14%7]) with mapi id 15.20.4500.019; Mon, 13 Sep 2021 16:16:19 +0000 From: Alex Sierra To: akpm@linux-foundation.org, Felix.Kuehling@amd.com, linux-mm@kvack.org, rcampbell@nvidia.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, hch@lst.de, jgg@nvidia.com, jglisse@redhat.com Subject: [PATCH v2 04/12] mm: add device public vma selection for memory migration Date: Mon, 13 Sep 2021 11:15:56 -0500 Message-Id: <20210913161604.31981-5-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210913161604.31981-1-alex.sierra@amd.com> References: <20210913161604.31981-1-alex.sierra@amd.com> X-ClientProxiedBy: SA9P223CA0015.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::20) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SA9P223CA0015.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 16:16:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 97ed0f33-e87c-4b9a-57ef-08d976d1d20e X-MS-TrafficTypeDiagnostic: SN6PR12MB2767: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:635; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O0sJXvWo8eoW8JhnXOuP0bp3kpa709Vsc2EBjQTRMZfF56mfydhQ/bxXqPorQTjjP614wafUH3UpZmUJ/JwQcGUW76XOnJ+to9Ot8QQjdvpuiOe6wWtp20iwVhQoc6V03t7S0Glq6+nrk2M+fOUc8i/UYFHYLysaEI7Ut8jf0L4nzAoEAVxrBe1jXm25zd2Lpl8U7l7xJp7LlXhmCxlTH8fCtCO+RRRf+2+f4dc6D75lXuZugtMEpi0SprzHtTQtsreKWMEoYSVKoecP9JK5CmeSvHcxQDV+YX/T+BbdV0XZjaeKH+9zlMLNB+RlN9TZLPL6CAfk2EAQdvoHyQnFWIvJ9wPf43+nUUUKESvk20nuW9bx6h7duOMM/lV1xg/1+M70K791CstuO/vSuGgsV+93/8bbEP/IBoPaq/4+aqv6vn/bz3ZhRZ7dOnDLbhfMs3ctF0OdWR0aVQB08gZR3RcWmLB75fyFtyRBtLaBl+M4sGqTSMwpTOVyt2GG4lY1JqUu2jlHEEkcDJk7k9lvXvW8JmkOuMKnGUWghlz9mpjX8uu/SdrrceKqKMkcfLe80bphQYC6m281UWFByZ8SK7wVeVntcExjignPGqQiqLHMBMMNiyE1pIm6NvMUDREq+FwfXzQgZaPQP1+fLWJQOskJHsO7OxJBUno788KdxRcTwKpNuVYrBsMNhBTzKfA3+DqAa10Slwlk/CsZJoTVRA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA0PR12MB4430.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(1076003)(7416002)(86362001)(66946007)(44832011)(478600001)(2616005)(6666004)(6486002)(52116002)(7696005)(956004)(5660300002)(316002)(83380400001)(4326008)(38350700002)(38100700002)(8676002)(66556008)(66476007)(2906002)(186003)(26005)(36756003)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z+pL25j8ZJy4yO1jnKqNnur5kroCEWNuUO3X8HZ4JrzDZGBXaXz5DQrwJ0C76zkijUcDitYS+yxY8PevXLWLsBafg51teV0r7QVidu2/u8uu6X7l7JX9iLySDGd41b40T5l0YPPZA0BJXE5nxEf7wGwPKmKsCkcmLmYJ4gHAZO4ZJ5c8yELAYjYiRZK/70wdNccl0BMJKzsJekQ08bnpiq+qmVYmBiHhrc33O+YdEKox76zzgeXOTk2EMIUmAegnoF4mhhz5YowYCilxVwANxhTd49LaIkbgekx0+SyU7xOuOcpp8f+Za+g9Zw14DEKecr1a6Q9DpJ2pxTIjz7x6J2tH5kjLauWjRe/yvxhIAOu0MUtLY1WDqYETcFT5+4iVRCSu76DChxWjrBR5NY978HfltMUYYmTNZUxRtvu10pxABa8QKNpPEwiRSQ2UaZE1VlHZaxlIeE13oVhKVrs8IJg2Ye2kyJO1z7/XTOmRgslu0wlzY/iTchLUbI1mnoguDF2NY9O+IP8+V6GVnrE+DkzwH6dXNL5a3i2COVsIdkNBcjdHNvjp1S0gqvci/FyUyVlkylSm3dTn/sExQB1PfeqqLuwpb6ktfuSzc21BT9/CRG4SwR6Fvc5kE+kpDajJWNyL49r0CWRCrakYo6yPEuMfjYuSQ/yYD2RAB5Y54TAn520q4W7cgw8LTqZRxxIfD7D4Ldmi8sbZaJjH1MjpKeVLAmm9k54BT2kp5YffPbi9/8Z8rdkD4DvGr1X7rb0Fk5OhUgUBuNAEEiLRBs0OgKhmuL1srJtH/UnhOM+Vt1cwamfr4JdsNVD4Ce8e4Ub7JipFIMVWwutzOJGbeR01Akj9ZBkWP1gNCQ4jFlDoYG/eHbDV5V1ZQUTNMkE4CiOw7a2ovGUuKlRPMYSkwUDyJm1VFaHCjPAeu4Ow6gB/r0RvSAds6VtnR6MyuNdbEhQ7WK1Gjzl3Gxi0S/0ExNLw0QlJTeH+ppAIC7UuQMmjyRbO8yrc5xohMggPm1iuvENB2cqGap3b3DXy2vbxS6RvgP4E+DA4uLy83/V6YKQychuCJPEwaHLT8dm0IOc3ityvO664sOFcz8VZDyU9LvMmKF2/03In7mok3puUfvcS3aLV6XmK/3pw1RUhFLvnbSi/58uL4auZo29oyeUbri+jN9FduzjKxkvBsyKUBt3asG8+HH4Ujy9gdmQvRjt4PgS3Rcgi5GoVACHliI3emnAFRX1nRgsRDp8EbR/nxy9aUod2sk+icCxnPnRn/heG3Dr70qIwZlYA2bQHvJ2YwqKxrvEPB5eJMca9lY28f6niA8Od0d49Oxsdt0Oxybxiouxz X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97ed0f33-e87c-4b9a-57ef-08d976d1d20e X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 16:16:19.5756 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C343408cN/DD7mRbmMs+C4oMWEgjx6dftyKMIYEqnHbv87ZNfd0MIWIII885qX2HaHFQL5R+E3qC5Irzr3mc4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2767 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=EUy21Vz9; spf=pass (imf18.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.223.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 050484002098 X-Stat-Signature: jgtn91ixeqq6i9dprun6eqz59rg5h9k5 X-HE-Tag: 1631549780-459701 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This case is used to migrate pages from device memory, back to system memory. Device public type memory is cache coherent from device and CPU point of view. Signed-off-by: Alex Sierra --- v2: condition added when migrations from device public pages. --- include/linux/migrate.h | 1 + mm/migrate.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 4bb4e519e3f5..2fe22596e02c 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -156,6 +156,7 @@ static inline unsigned long migrate_pfn(unsigned long pfn) enum migrate_vma_direction { MIGRATE_VMA_SELECT_SYSTEM = 1 << 0, MIGRATE_VMA_SELECT_DEVICE_PRIVATE = 1 << 1, + MIGRATE_VMA_SELECT_DEVICE_PUBLIC = 1 << 2, }; struct migrate_vma { diff --git a/mm/migrate.c b/mm/migrate.c index 7392648966d2..036baf24b58b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2406,8 +2406,6 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, if (is_write_device_private_entry(entry)) mpfn |= MIGRATE_PFN_WRITE; } else { - if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) - goto next; pfn = pte_pfn(pte); if (is_zero_pfn(pfn)) { mpfn = MIGRATE_PFN_MIGRATE; @@ -2415,6 +2413,13 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, goto next; } page = vm_normal_page(migrate->vma, addr, pte); + if (!is_zone_device_page(page) && + !(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) + goto next; + if (is_zone_device_page(page) && + (!(migrate->flags & MIGRATE_VMA_SELECT_DEVICE_PUBLIC) || + page->pgmap->owner != migrate->pgmap_owner)) + goto next; mpfn = migrate_pfn(pfn) | MIGRATE_PFN_MIGRATE; mpfn |= pte_write(pte) ? MIGRATE_PFN_WRITE : 0; }