From patchwork Fri Aug 13 06:31:38 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: 12434761 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 3D476C43216 for ; Fri, 13 Aug 2021 06:32:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CB8EB60FBF for ; Fri, 13 Aug 2021 06:32:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CB8EB60FBF 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 5C29E8D0002; Fri, 13 Aug 2021 02:32:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54C366B0071; Fri, 13 Aug 2021 02:32:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 377788D0003; Fri, 13 Aug 2021 02:32:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 0D0616B006C for ; Fri, 13 Aug 2021 02:32:06 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B42E018037FC3 for ; Fri, 13 Aug 2021 06:32:05 +0000 (UTC) X-FDA: 78469087410.40.0E6E1FB Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2084.outbound.protection.outlook.com [40.107.95.84]) by imf27.hostedemail.com (Postfix) with ESMTP id 6D412700BC63 for ; Fri, 13 Aug 2021 06:32:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cxH5TX/1eTy8YHPLWWX4XHoJ2TbqqKJflU9BDyjaLBFn1w1NP0wBvEWWOLJGF0E8J7Kdal8LB8lyKfgON1c+/V+wEOsHcdaAj84hJtYX6SYio6j09YaoHqGZqq8uqFxe9FdOBiV+Lbpo3c5EZNOzofdI22o61/nwK4YLRXfYV5jRSMZnU4kgQpFkCU46GMaA8UpyjAB7XnxaL2DM6P19X+cFImAFhhuYzScSZgb3ycEOjRZtRudOZB9TdmkTgIK9drH3schV14ujSPxbEZ7rD/HQmtSFPhrM2+JOWRZ6TiU6LaDtHQVGFbZHh/+ltXmxsJGqz79ttRXeNgu0y/KaZA== 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-SenderADCheck; bh=Ez6ZO5fI8nE9uKbR8Crs9JJJ7TUbD/CWkAtdWfvnJD4=; b=jb2UkvMRL4yVBBIk07eBhgEpJKczbOQQN66Vi27Qf+/+FGFswvCmOT4buq+ThNscvM+zKoLW0ZeDgrISiNBHR/LqUqcw30VNMsqR7+YmjEjxt0W82ckWac91OAUru5Ro6GZUXe59uSs2uRpA7GJZFuz/8/xDyD5Uzom1sRffF0EzViogFTNG+Y/vkqbM93vt0XvY9IutHa7o8SPwru8AoFchRxo0nXu/E5ojWf5YKVcni67AaL0uFYQhF4Cxp9KTvBssbvqPKL6gi/sdmcMrRu6bn1C2TWwRv6xgIogu8YiHt5la6OoUpsALQpdj19wl3NosGt20yGJ/aL3YEs945Q== 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=Ez6ZO5fI8nE9uKbR8Crs9JJJ7TUbD/CWkAtdWfvnJD4=; b=eCK2x5Tvz+C3R4XxI2f8U/HfZQz70/rFgfT67ZuEFrRwqBcrSbFG9FQNTUQj5OggiORmDkymckNKvmGuTtzFso60BgqgKiihbGRM4V/fy687iwQFQQSDZY7+KQwQK7Y0xmK+57j0BABvlnPA+fz0nDcVK/fawHVCu55rkAKZ8so= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.16; Fri, 13 Aug 2021 06:32:03 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:03 +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 v6 01/13] ext4/xfs: add page refcount helper Date: Fri, 13 Aug 2021 01:31:38 -0500 Message-Id: <20210813063150.2938-2-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2440cabb-9e14-4f75-e113-08d95e24103e X-MS-TrafficTypeDiagnostic: SN6PR12MB2718: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3572PTgkn1O6E0AgguTQ9GEZFBTNYEyRI8U2hXHIgxWc9OxYPnVPbY6u5ZfBj/2L2sWZMHkejKsfY0R6oZsCl8aI6wcYC/YwoFGPg0b+Vc9Y7eEgNzQg49gidAIU+qEc/4NNmX7EEmDerBD51CrYBD+LSCewW0BN6YBZVJmirhxuSmdkGr8qKyw1LxMoa4IGV8hfXgdz+uNXt2IuwKhxflSiCPX6KNQr7GGTBtiAaXCpwSVPNbsM7V/5TneOtD602y25lzl9QDIRXAff5A3eAPUBToFNIbhvJ2yogoCcBxxfypQBGZO+46v7yn9VK/lDtF4z6zMrZfGqKM5BA3oIvtfOs8yU1wBjv7pXt3XlzYZGqioiQdP8hEMl88SID4alj04to9/UJQG7jsRV1Lp+Aj846rIa82C5nI8t53uufUXlIxgsTT7t8EwubhUKhwacqkbLZCt+ztuUZgplgRacA8tguUyiBQl8RLbVm6JO0ONN4PVfSxa/IPg3hfoZMAHx4TTjk0F6aoZEOR0RmWsKWqMXbBEhP5xG1XPFlR0Z6EDHSk4YIsZiT/jELIbuwTLYSrmzPgLc06edlwMn2ixwWFg6LYS/E5asbLjQWzbIcYxCdhJJHGNcvqYXugE1oEK/DSTcmHqORyAUvd57EOdjcP4q1kE4Wf6eTo04uWh1gWKIg44XSg97IMeYCiVA6IW8nZo0ivUyTRLKxeZ/AqoQLw== 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)(366004)(396003)(376002)(136003)(39860400002)(956004)(44832011)(2616005)(6486002)(4326008)(86362001)(1076003)(5660300002)(478600001)(8676002)(38100700002)(8936002)(316002)(38350700002)(7416002)(2906002)(66946007)(6666004)(36756003)(66476007)(186003)(26005)(7696005)(52116002)(66556008)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /jo+VEa6DRhQpR347EP8hc7okWd1QKF6CDBJITTZQFWKnkBe83RmWu05NJ4UjFw2aawuo8WS3VbmVtiuABz6PpAbjXaU+KGKluV5UYu4Jnx0OXCNjr0vBY5RZrVrp+qZ+XwhJBFd/djYjc1aBCt1ZI16Dpq0zZkXRJDXRrKz23A42QIzR5MOvbTe38zOIZpJUEWJI0jGFKAFqoY5MTWEiM28Ljzu/MLwTgX+6SnW3BwVfJ6rFhNyUJNM6hOtWREh8hwXBcUu557o+w+TbzNClJIjTUkh9gAnG0Ooqngr8DFHkrmkGfnsvMGd/URIEh3J8+JpeAvUDqBpU73pegBxYUCx5A7oyEyrtKBZL+OTgVkzsajBjkUKPE9X1ELKVV/gZ3LZLZ02ML82bHAqfSe/GEZn49zye/YfZymJ7GPQNeI3FshX6iECrtDPPC+Y7k2WBwHrKy48/1xG4Wm4wY7AY+tnqS5Ug/Dm7nKwEi6yMQBJzlyWKcyvpodoiruoTUkhlLNA87lmtFhjESZ3ARQoQ9gXdh6GFl3amGOwPRIN0LldynJBcWD7mOtO+H95MNhAX7KwnOnudLN76RYZK9BQPBffMdQqLb0+kND5pwtP5Df98vjVrGMXZAV+7ifxZfK6wU7IKH2uCiBEhHifcRxWfOYb3GgIaKP5g7RETUcYchzDrED12W/WihrGCcFt/fkcuCrsknZDdTfnzvbaKArM3BkFiTcLvx9BX5O1+sjUij4oKihTEwngyFc3wiP4KesfUdi9U3j5HWTi6GHuHtxZU65qqFDxaM1bBxfjWLVvflkkB3J690anMxRreND3AcgqV7sN2TesG+FCJfLZMFNhjgUBCK85jq2VSvJrx0ex5LfeDrLckujqN85piV2i7ZBknDFKPkTmO8N/qjfgXcsgh6ZFpfBKrZC/DKStsbwwFnefq/7zL6ytEsJr/ecHb+xBLMW6LWrWhKuh71s3/IXeantZU5/yzHtmBxhnbKnkj9HIQfxmSrTgmdeIs0BaF9b8TVe0SV/UoW5mMkdkzACpnYfz5SwAX+tSFjKZumoUTQmJqdZ1e53JQYDr2tbH9YxY7/HvAnHDDzRoRheLCTzVbb0wqcj4hEVVjgrvqM6z9i2TOTnx5eAVJ2E0T7LFvsHvIYoolxzZQ17erUAQGobxZTpFf+D5f6lzgmr+5RdoUrJZRmnl530ghVBIBm6LK0IOZFwIz2ZLjutJnunUu33s7oCPN73CK4BZpycBfe2mgONRzAGNjp8SSGgRjlibX1Td+0s4MMy+JeERpaA03fafSOQMeS9gzNoAdjzpXRZ4r2YBSDHI2pu2mGA6SORWrxjX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2440cabb-9e14-4f75-e113-08d95e24103e X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:03.5424 (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: 4i9tATylxXuHD/6YQ0XzyN0S1HsqNvRZV0KANZSv77KU7nFJeMBKcFCVEoLA7aZHTcwN1DlENW/FoQrCY2ZrJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2718 X-Rspamd-Queue-Id: 6D412700BC63 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=eCK2x5Tv; spf=pass (imf27.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.95.84 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam01 X-Stat-Signature: izxutxxc3atr6tf959eq3r9urq5gk538 X-HE-Tag: 1628836325-86460 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: Ralph Campbell There are several places where ZONE_DEVICE struct pages assume a reference count == 1 means the page is idle and free. Instead of open coding this, add a helper function to hide this detail. v3: [AS]: rename dax_layout_is_idle_page func to dax_page_unused v4: [AS]: This ref count functionality was missing on fuse/dax.c. Signed-off-by: Ralph Campbell Signed-off-by: Alex Sierra Reviewed-by: Christoph Hellwig --- fs/dax.c | 4 ++-- fs/ext4/inode.c | 5 +---- fs/fuse/dax.c | 4 +--- fs/xfs/xfs_file.c | 4 +--- include/linux/dax.h | 10 ++++++++++ 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 62352cbcf0f4..c387d09e3e5a 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -369,7 +369,7 @@ static void dax_disassociate_entry(void *entry, struct address_space *mapping, for_each_mapped_pfn(entry, pfn) { struct page *page = pfn_to_page(pfn); - WARN_ON_ONCE(trunc && page_ref_count(page) > 1); + WARN_ON_ONCE(trunc && !dax_page_unused(page)); WARN_ON_ONCE(page->mapping && page->mapping != mapping); page->mapping = NULL; page->index = 0; @@ -383,7 +383,7 @@ static struct page *dax_busy_page(void *entry) for_each_mapped_pfn(entry, pfn) { struct page *page = pfn_to_page(pfn); - if (page_ref_count(page) > 1) + if (!dax_page_unused(page)) return page; } return NULL; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index fe6045a46599..05ffe6875cb1 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3971,10 +3971,7 @@ int ext4_break_layouts(struct inode *inode) if (!page) return 0; - error = ___wait_var_event(&page->_refcount, - atomic_read(&page->_refcount) == 1, - TASK_INTERRUPTIBLE, 0, 0, - ext4_wait_dax_page(ei)); + error = dax_wait_page(ei, page, ext4_wait_dax_page); } while (error == 0); return error; diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index ff99ab2a3c43..2b1f190ba78a 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -677,9 +677,7 @@ static int __fuse_dax_break_layouts(struct inode *inode, bool *retry, return 0; *retry = true; - return ___wait_var_event(&page->_refcount, - atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE, - 0, 0, fuse_wait_dax_page(inode)); + return dax_wait_page(inode, page, fuse_wait_dax_page); } /* dmap_end == 0 leads to unmapping of whole file */ diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 396ef36dcd0a..182057281086 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -840,9 +840,7 @@ xfs_break_dax_layouts( return 0; *retry = true; - return ___wait_var_event(&page->_refcount, - atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE, - 0, 0, xfs_wait_dax_page(inode)); + return dax_wait_page(inode, page, xfs_wait_dax_page); } int diff --git a/include/linux/dax.h b/include/linux/dax.h index b52f084aa643..8b5da1d60dbc 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -243,6 +243,16 @@ static inline bool dax_mapping(struct address_space *mapping) return mapping->host && IS_DAX(mapping->host); } +static inline bool dax_page_unused(struct page *page) +{ + return page_ref_count(page) == 1; +} + +#define dax_wait_page(_inode, _page, _wait_cb) \ + ___wait_var_event(&(_page)->_refcount, \ + dax_page_unused(_page), \ + TASK_INTERRUPTIBLE, 0, 0, _wait_cb(_inode)) + #ifdef CONFIG_DEV_DAX_HMEM_DEVICES void hmem_register_device(int target_nid, struct resource *r); #else From patchwork Fri Aug 13 06:31:39 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: 12434765 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 6A09BC4320A for ; Fri, 13 Aug 2021 06:32:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0DB2460FBF for ; Fri, 13 Aug 2021 06:32:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0DB2460FBF 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 06CD26B006C; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC2CB6B0071; Fri, 13 Aug 2021 02:32:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9EFA6B0073; Fri, 13 Aug 2021 02:32:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0104.hostedemail.com [216.40.44.104]) by kanga.kvack.org (Postfix) with ESMTP id A31496B006C for ; Fri, 13 Aug 2021 02:32:06 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3EBF119B1B for ; Fri, 13 Aug 2021 06:32:06 +0000 (UTC) X-FDA: 78469087452.22.9F6CD12 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2084.outbound.protection.outlook.com [40.107.95.84]) by imf27.hostedemail.com (Postfix) with ESMTP id CBF44700BC63 for ; Fri, 13 Aug 2021 06:32:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MHtWrlf/OgdCDPkQtVzcCh+SVUOOr2Zw4kFI/QG8mO8DqA9R8sfMIw69G9LR88zzB2xcls7rTvAgJqQf6y4QI9JVvr8zH+4F7d9dBFbOkMMvccgIGgvp2MLcrm5IGKmJ5X32F+AcOtxq3J8qxhKC0sF1R11iVv7hPHaTt3M8rLonNRD+qGgAt9S0SPlUw0VuMxdKAGUO2WFg7QkElLKvgLnI8qARoxJFNnQzsQvi+Moc6951fN4kaLLWIC+DLN9oaN8yhOX9Jg+kxNQDir9sgjuR+TH1Ln0wCrac8nXsbOqdAx6yXA/FgfTJ0FlpX2YXWUpGp0YnB3rrBS99FRv0CA== 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-SenderADCheck; bh=s65BuHAsx0SvDKirKGMcVSUa2xR5zCPMm0rKxA2Cblw=; b=QgQVGxIlwJp1b86MV1GLBAhfFYa75xgQ0MVRWv87vwFbPaCyCw8lptoMVqta4Jo5m2kYfAS6vv+v8aDAmEtX2288y3Q7oGWUNZBbD3iD+mfwVGGzbnnso814BSUF5dFRmX4tPfXoZJ+5TPcbZ6DBK9DXyuG9azD1Y9Af6a69SgGmCBAOx7+/vUmPCDmFMkCPfAEudsYLfQuPZw4KD29VIAwz+fGN8zTI6ra6KTzSIsCYEkpw2GRF9E4CH8A2ZmtKF+gSMloHpKml6SxHs28W08zjzdUCHPpz4gueCE2Hl5QTss5jr3yh8O6/69215IjAvT+f/KF7qEl9X3vDqSJdYg== 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=s65BuHAsx0SvDKirKGMcVSUa2xR5zCPMm0rKxA2Cblw=; b=KfyuiAlb3zUZwi28d24vt3TFnr5io1vCrBJTjd9dscuxvL/RXqs7kP64w5UKH1CGak++ZBudAEphjtv7eNDa17vI3QIWvvBdg7clIQfYHTqJ7s4UozsZbIAR00r5oE4Q+X02wONjNTcm76NNALyCVs9e8NWLq48nvDytFUsWcyM= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.16; Fri, 13 Aug 2021 06:32:04 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:04 +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 v6 02/13] mm: remove extra ZONE_DEVICE struct page refcount Date: Fri, 13 Aug 2021 01:31:39 -0500 Message-Id: <20210813063150.2938-3-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71cbac03-860a-4624-59ee-08d95e2410ab X-MS-TrafficTypeDiagnostic: SN6PR12MB2718: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aDyuA5oSbD5N6HT3T43npVh0U4RusD6POCMqojOcJfLtnN3BYVjnFKqRslC4KLIpd6rMaxako3XGPe+I+OEw4c1nkvs3eTy9ZHY0jbst4/3PhmCaZYf4WZDuFVPkt0jOdYGQcNXcB2PY3oMFTCo8Foq7CegkgmTF0ZGIIieRt8llfUx7ZEj2JbnrRc9V7Qw+nhUgu7Pj1bjmUfoATntHgRfIGqKsavPWJoJXhJACKV1/QXi0fwf8mmkolnXcGTstd3m2ADsm/dTlHaltloko3ZWtsYNkM51GhESy0cy3XA+3fGkCfhaLWw4FNVhU8YMsmqHGK26TfPi7kgkWKY9ZnMZSb9ji+lg6HI86ZO9I5a1p/1ErgPJGT9dl0WUCKE5Yp79AQi2EZ8STaMsp4xjv2iN3R2k3+/Y0b8XZj/yfYltLaDys+YPR/LuzXzEGbnwHE0q6gt1ZD/rfJ5aTO/iNLWJddJnYtqqQxISbLnTpGdOtAcZXK4uQ1yNJR7O04bDOMvLwYvmRitiBUhxDZYclWo0wnNquDguZBYtrs2uZ515Fpo7rGUTtHbvIss2acEz1qsohbm6LIWRK1BWgdAG8nY295fgHKZq0dPXNCIFCHL5R9BGusJ/0TbqTB0ZYD8IQvpx9Wc6/uISGN/H6nk5/+qD+MSBs0NKX77c7nydccZLe5lOJenAjz2idMOx8O9EH3QjA3OPRjz+hCHK9Pp0u9w== 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)(366004)(396003)(376002)(136003)(39860400002)(956004)(44832011)(30864003)(2616005)(6486002)(4326008)(86362001)(1076003)(5660300002)(478600001)(8676002)(38100700002)(8936002)(316002)(38350700002)(7416002)(2906002)(66946007)(6666004)(36756003)(66476007)(186003)(26005)(7696005)(52116002)(66556008)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l0DvLnDyvXSaPwUduBgTKVMYIJ0A+7nDoBkMOg9qv43o6powf7SI0BIdMQYImNAo7LivX151ufQ7LmuMehDTBjy7Non5agfh3L0x3+zYyabOmw1syH5uKX6Syhie3UhVoxwmBMjIX4MPJ7rapjBZsszD52CdpEyJC8EAxEbao110tgqN5tE1o5qzlYQzvGGzOzByT9Tdry1wTdGysjTm0nqDQnJ4W/+RWbn8ELssyLKbu6MFtR6ZFqNQ7VL/G86XqZrHdvTjlJWazsY8TwDzLF8gOKnVkeMDrrF8OMwyd4Fll++qJ9CFW3fcnWKuWCrm2tVYU5xRnwxlwCLiqHvHwPMmR3ql4zC+p/4ZvY1fi8AkfyRMVuLP1vl4c+xgo8CIC3nxaj+JorT62J4AMdRn/MrJtcUZz0xIYnK7Bn1MGIebdj6L+JMZk+qCfnDOVx2wqF4SkTOw4b3kID/psiJ6b6pwjxzQ3AX5oytd3fyZJifEiGGz5ND1pisQU9o66qYQ1ARIZvJcema0C5fQKRQQzBV9E8XGN6GDR0Y/oePqKBIEEoHLa0yfwe3kL4QGScZNtDKuUmcZ2mxIpneri5R0eEBELEztG8YpVksYnXXrIpsUY7rjMwJ0xYbVwML6K04osBLdO3GgWLeIjT8JNQrEsta8k5i28u6ya6Xg/tMb+UK/d3yMFlkweqWujiWsQXGQ5VfIjOP8nIBk83GnLUmR2LS3hf7gDxRsQio2Zqim0AI4Z+PzNzX8PlPUFUsbxH2iH66YVVbUDPj61sK+4xqitc+IhKy/ga4BSpm8WuztgmLUtzBquAMFWkro6mQTYNnWBkUvvwnNWkcqowazjHLq5h8zQNgqe9Ho7XuQhbOjSUmAJ49N3gOJdUhLqAhmc8wZ5K62jeOv6fkHRtqpPF4XC2W1nba2CiyD5adbahabg7fOrUZdkwxnVK9Pkzftou/GQ/1ajEi4QW3SPUDyn7bQ8/TzEcrTxuA3MqK047bdRKmmpAOAehdFGHMUIz7a6TNYq74u0KtPnD0G8N3LDklQu8+UsGB230KezceXYFv+cv5Ju9fDljZnJUFmQwK0VqiXgtD4PNfOCXAsFHyWcQdMuctrZ1yC6u/Zs8UEoDG1hckoVgTyLRMafqZpOal6Uj94zBOCJV/4XH4cDKZ4PZrVN2R6aB10BK0TGwsJ5luY4PX2RefGAtmlHGYcsxSJ6MEYFAp5dmXS5IiMY+xDSJGPoNT/vkdGXZ/GSPpVtG6jf0k+1rUVh8nnaG8MSznWfhru7jT7o4cKs/0n6by8raKySo1QiU0gUyHM7PWARfzjLUAv0ddQvxA/Tw4Iv6c1zq0v X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71cbac03-860a-4624-59ee-08d95e2410ab X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:04.2792 (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: LRle/tFAVPNv9ocYst6qUZ5/Uc+qOw3RhodFasufWOfAJTPkv+JPRpJ8ewGgwYB/NyauysJ1YS1Wm5Csr334Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2718 X-Rspamd-Queue-Id: CBF44700BC63 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=KfyuiAlb; spf=pass (imf27.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.95.84 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam01 X-Stat-Signature: uaferiyq5h9ozquox4z4yreqwau19oiq X-HE-Tag: 1628836325-741673 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: Ralph Campbell ZONE_DEVICE struct pages have an extra reference count that complicates the code for put_page() and several places in the kernel that need to check the reference count to see that a page is not being used (gup, compaction, migration, etc.). Clean up the code so the reference count doesn't need to be treated specially for ZONE_DEVICE. v2: AS: merged this patch in linux 5.11 version v5: AS: add condition at try_grab_page to check for the zone device type, while page ref counter is checked less/equal to zero. In case of device zone, pages ref counter are initialized to zero. Signed-off-by: Ralph Campbell Signed-off-by: Alex Sierra --- arch/powerpc/kvm/book3s_hv_uvmem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- fs/dax.c | 4 +- include/linux/dax.h | 2 +- include/linux/memremap.h | 7 +-- include/linux/mm.h | 13 +---- lib/test_hmm.c | 2 +- mm/internal.h | 8 +++ mm/memremap.c | 68 +++++++------------------- mm/migrate.c | 5 -- mm/page_alloc.c | 3 ++ mm/swap.c | 45 ++--------------- 12 files changed, 46 insertions(+), 115 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_hv_uvmem.c index 84e5a2dc8be5..acee67710620 100644 --- a/arch/powerpc/kvm/book3s_hv_uvmem.c +++ b/arch/powerpc/kvm/book3s_hv_uvmem.c @@ -711,7 +711,7 @@ static struct page *kvmppc_uvmem_get_page(unsigned long gpa, struct kvm *kvm) dpage = pfn_to_page(uvmem_pfn); dpage->zone_device_data = pvt; - get_page(dpage); + init_page_count(dpage); lock_page(dpage); return dpage; out_clear: diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c index 92987daa5e17..8bc7120e1216 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -324,7 +324,7 @@ nouveau_dmem_page_alloc_locked(struct nouveau_drm *drm) return NULL; } - get_page(page); + init_page_count(page); lock_page(page); return page; } diff --git a/fs/dax.c b/fs/dax.c index c387d09e3e5a..1166630b7190 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -571,14 +571,14 @@ static void *grab_mapping_entry(struct xa_state *xas, /** * dax_layout_busy_page_range - find first pinned page in @mapping - * @mapping: address space to scan for a page with ref count > 1 + * @mapping: address space to scan for a page with ref count > 0 * @start: Starting offset. Page containing 'start' is included. * @end: End offset. Page containing 'end' is included. If 'end' is LLONG_MAX, * pages from 'start' till the end of file are included. * * DAX requires ZONE_DEVICE mapped pages. These pages are never * 'onlined' to the page allocator so they are considered idle when - * page->count == 1. A filesystem uses this interface to determine if + * page->count == 0. A filesystem uses this interface to determine if * any page in the mapping is busy, i.e. for DMA, or other * get_user_pages() usages. * diff --git a/include/linux/dax.h b/include/linux/dax.h index 8b5da1d60dbc..05fc982ce153 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -245,7 +245,7 @@ static inline bool dax_mapping(struct address_space *mapping) static inline bool dax_page_unused(struct page *page) { - return page_ref_count(page) == 1; + return page_ref_count(page) == 0; } #define dax_wait_page(_inode, _page, _wait_cb) \ diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 45a79da89c5f..77ff5fd0685f 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -66,9 +66,10 @@ enum memory_type { struct dev_pagemap_ops { /* - * Called once the page refcount reaches 1. (ZONE_DEVICE pages never - * reach 0 refcount unless there is a refcount bug. This allows the - * device driver to implement its own memory management.) + * Called once the page refcount reaches 0. The reference count + * should be reset to one with init_page_count(page) before reusing + * the page. This allows the device driver to implement its own + * memory management. */ void (*page_free)(struct page *page); diff --git a/include/linux/mm.h b/include/linux/mm.h index 8ae31622deef..d48a1f0889d1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1218,7 +1218,7 @@ __maybe_unused struct page *try_grab_compound_head(struct page *page, int refs, static inline __must_check bool try_get_page(struct page *page) { page = compound_head(page); - if (WARN_ON_ONCE(page_ref_count(page) <= 0)) + if (WARN_ON_ONCE(page_ref_count(page) < (int)!is_zone_device_page(page))) return false; page_ref_inc(page); return true; @@ -1228,17 +1228,6 @@ static inline void put_page(struct page *page) { page = compound_head(page); - /* - * For devmap managed pages we need to catch refcount transition from - * 2 to 1, when refcount reach one it means the page is free and we - * need to inform the device driver through callback. See - * include/linux/memremap.h and HMM for details. - */ - if (page_is_devmap_managed(page)) { - put_devmap_managed_page(page); - return; - } - if (put_page_testzero(page)) __put_page(page); } diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 80a78877bd93..6998f10350ea 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -561,7 +561,7 @@ static struct page *dmirror_devmem_alloc_page(struct dmirror_device *mdevice) } dpage->zone_device_data = rpage; - get_page(dpage); + init_page_count(dpage); lock_page(dpage); return dpage; diff --git a/mm/internal.h b/mm/internal.h index e8fdb531f887..5438cceca4b9 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -667,4 +667,12 @@ int vmap_pages_range_noflush(unsigned long addr, unsigned long end, void vunmap_range_noflush(unsigned long start, unsigned long end); +#ifdef CONFIG_DEV_PAGEMAP_OPS +void free_zone_device_page(struct page *page); +#else +static inline void free_zone_device_page(struct page *page) +{ +} +#endif + #endif /* __MM_INTERNAL_H */ diff --git a/mm/memremap.c b/mm/memremap.c index 15a074ffb8d7..5aa8163fd948 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -12,6 +12,7 @@ #include #include #include +#include "internal.h" static DEFINE_XARRAY(pgmap_array); @@ -37,32 +38,6 @@ unsigned long memremap_compat_align(void) EXPORT_SYMBOL_GPL(memremap_compat_align); #endif -#ifdef CONFIG_DEV_PAGEMAP_OPS -DEFINE_STATIC_KEY_FALSE(devmap_managed_key); -EXPORT_SYMBOL(devmap_managed_key); - -static void devmap_managed_enable_put(struct dev_pagemap *pgmap) -{ - if (pgmap->type == MEMORY_DEVICE_PRIVATE || - pgmap->type == MEMORY_DEVICE_FS_DAX) - static_branch_dec(&devmap_managed_key); -} - -static void devmap_managed_enable_get(struct dev_pagemap *pgmap) -{ - if (pgmap->type == MEMORY_DEVICE_PRIVATE || - pgmap->type == MEMORY_DEVICE_FS_DAX) - static_branch_inc(&devmap_managed_key); -} -#else -static void devmap_managed_enable_get(struct dev_pagemap *pgmap) -{ -} -static void devmap_managed_enable_put(struct dev_pagemap *pgmap) -{ -} -#endif /* CONFIG_DEV_PAGEMAP_OPS */ - static void pgmap_array_delete(struct range *range) { xa_store_range(&pgmap_array, PHYS_PFN(range->start), PHYS_PFN(range->end), @@ -102,16 +77,6 @@ static unsigned long pfn_end(struct dev_pagemap *pgmap, int range_id) return (range->start + range_len(range)) >> PAGE_SHIFT; } -static unsigned long pfn_next(unsigned long pfn) -{ - if (pfn % 1024 == 0) - cond_resched(); - return pfn + 1; -} - -#define for_each_device_pfn(pfn, map, i) \ - for (pfn = pfn_first(map, i); pfn < pfn_end(map, i); pfn = pfn_next(pfn)) - static void dev_pagemap_kill(struct dev_pagemap *pgmap) { if (pgmap->ops && pgmap->ops->kill) @@ -167,20 +132,18 @@ static void pageunmap_range(struct dev_pagemap *pgmap, int range_id) void memunmap_pages(struct dev_pagemap *pgmap) { - unsigned long pfn; int i; dev_pagemap_kill(pgmap); for (i = 0; i < pgmap->nr_range; i++) - for_each_device_pfn(pfn, pgmap, i) - put_page(pfn_to_page(pfn)); + percpu_ref_put_many(pgmap->ref, pfn_end(pgmap, i) - + pfn_first(pgmap, i)); dev_pagemap_cleanup(pgmap); for (i = 0; i < pgmap->nr_range; i++) pageunmap_range(pgmap, i); WARN_ONCE(pgmap->altmap.alloc, "failed to free all reserved pages\n"); - devmap_managed_enable_put(pgmap); } EXPORT_SYMBOL_GPL(memunmap_pages); @@ -382,8 +345,6 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid) } } - devmap_managed_enable_get(pgmap); - /* * Clear the pgmap nr_range as it will be incremented for each * successfully processed range. This communicates how many @@ -498,16 +459,10 @@ struct dev_pagemap *get_dev_pagemap(unsigned long pfn, EXPORT_SYMBOL_GPL(get_dev_pagemap); #ifdef CONFIG_DEV_PAGEMAP_OPS -void free_devmap_managed_page(struct page *page) +static void free_device_private_page(struct page *page) { - /* notify page idle for dax */ - if (!is_device_private_page(page)) { - wake_up_var(&page->_refcount); - return; - } __ClearPageWaiters(page); - mem_cgroup_uncharge(page); /* @@ -534,4 +489,19 @@ void free_devmap_managed_page(struct page *page) page->mapping = NULL; page->pgmap->ops->page_free(page); } + +void free_zone_device_page(struct page *page) +{ + switch (page->pgmap->type) { + case MEMORY_DEVICE_FS_DAX: + /* notify page idle */ + wake_up_var(&page->_refcount); + return; + case MEMORY_DEVICE_PRIVATE: + free_device_private_page(page); + return; + default: + return; + } +} #endif /* CONFIG_DEV_PAGEMAP_OPS */ diff --git a/mm/migrate.c b/mm/migrate.c index 41ff2c9896c4..e3a10e2a1bb3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -350,11 +350,6 @@ static int expected_page_refs(struct address_space *mapping, struct page *page) { int expected_count = 1; - /* - * Device private pages have an extra refcount as they are - * ZONE_DEVICE pages. - */ - expected_count += is_device_private_page(page); if (mapping) expected_count += thp_nr_pages(page) + page_has_private(page); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ef2265f86b91..1ef1f733af5b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6414,6 +6414,9 @@ void __ref memmap_init_zone_device(struct zone *zone, __init_single_page(page, pfn, zone_idx, nid); + /* ZONE_DEVICE pages start with a zero reference count. */ + set_page_count(page, 0); + /* * Mark page reserved as it will need to wait for onlining * phase for it to be fully associated with a zone. diff --git a/mm/swap.c b/mm/swap.c index dfb48cf9c2c9..9e821f1951c5 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -114,12 +114,11 @@ static void __put_compound_page(struct page *page) void __put_page(struct page *page) { if (is_zone_device_page(page)) { - put_dev_pagemap(page->pgmap); - /* * The page belongs to the device that created pgmap. Do * not return it to page allocator. */ + free_zone_device_page(page); return; } @@ -917,29 +916,18 @@ void release_pages(struct page **pages, int nr) if (is_huge_zero_page(page)) continue; + if (!put_page_testzero(page)) + continue; + if (is_zone_device_page(page)) { if (lruvec) { unlock_page_lruvec_irqrestore(lruvec, flags); lruvec = NULL; } - /* - * ZONE_DEVICE pages that return 'false' from - * page_is_devmap_managed() do not require special - * processing, and instead, expect a call to - * put_page_testzero(). - */ - if (page_is_devmap_managed(page)) { - put_devmap_managed_page(page); - continue; - } - if (put_page_testzero(page)) - put_dev_pagemap(page->pgmap); + free_zone_device_page(page); continue; } - if (!put_page_testzero(page)) - continue; - if (PageCompound(page)) { if (lruvec) { unlock_page_lruvec_irqrestore(lruvec, flags); @@ -1143,26 +1131,3 @@ void __init swap_setup(void) * _really_ don't want to cluster much more */ } - -#ifdef CONFIG_DEV_PAGEMAP_OPS -void put_devmap_managed_page(struct page *page) -{ - int count; - - if (WARN_ON_ONCE(!page_is_devmap_managed(page))) - return; - - count = page_ref_dec_return(page); - - /* - * devmap page refcounts are 1-based, rather than 0-based: if - * refcount is 1, then the page is free and the refcount is - * stable because nobody holds a reference on the page. - */ - if (count == 1) - free_devmap_managed_page(page); - else if (!count) - __put_page(page); -} -EXPORT_SYMBOL(put_devmap_managed_page); -#endif From patchwork Fri Aug 13 06:31:40 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: 12434767 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 006E4C4338F for ; Fri, 13 Aug 2021 06:32:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A66D160FBF for ; Fri, 13 Aug 2021 06:32:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A66D160FBF 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 703796B0071; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E9E76B0073; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4145B8D0003; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id 220A16B0073 for ; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id ACDA98249980 for ; Fri, 13 Aug 2021 06:32:06 +0000 (UTC) X-FDA: 78469087452.15.0140AB6 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2084.outbound.protection.outlook.com [40.107.95.84]) by imf27.hostedemail.com (Postfix) with ESMTP id 4CF06700BC63 for ; Fri, 13 Aug 2021 06:32:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dqsN9jPA9tBoyLZi1pELWlrIJWZbuSDz37U8blwOVzhREBhykPjc4QHpTiseLRrUsDiVkj4uROXg2CEnpLjRbULIfjlxGaMlst642KZ3Lgz3gSKX0XuK9On9qnPxdrztym2dw8HEbUnVoN2eos/IBESBDMO8fCtVvNkv2IQT6FdUnCxwPDK/RaUNCwfZc7s5cPaUuKBYA1eEubAjdaXbN+fQwGqlAVQoJJa425BNNAMBua0jbDTL8TK+zgIrSgBjb0oqJSL897Pro8i5CRyygk0reHvKgVZo89CfepUjgkSM70XXatI56Ad1mRnEUO+B1DgpCH/crU7KCHJvoKMl/g== 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-SenderADCheck; bh=TUEROg2UDTQq5LhzAavd4Vw/sWGqA8IarIMmnrPNAZ4=; b=diWRcy/oDBmdOmIsBEC4w0RBGYIWLP97nR11wxeTl7e4pddQuz3gNAXQFBj4/zUByNuQ2HPXP43hbyAGYdal2TwhmhZXPeQSSJCJQSPQn7PVC7R0XnqeDjfZW0/Y4Ctvg+hDYZs1+nht+bhA/33xYdOF6XIR6OTFJcuqzvGUlqiaOws7wpY1dwOapcPRIFpltrSfnRuHWYIYbYFGG5/+l5BIr3Yibtw4Zv+JAJRNTYDtQ8lkHdISHqkKZdin9v4UYfFFjztEf5U6I+ZxSj/8t1IAvqWKiDKoMTTEhiyqpT6UtjqffCG1V2hcxcNtCDQWWGzUEyyRguFtG0uJowZlBg== 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=TUEROg2UDTQq5LhzAavd4Vw/sWGqA8IarIMmnrPNAZ4=; b=aB/Icd5F5T19wjDbkiD/2UfWrAFeU1kUPgOZ3g+660f1G7kWaHxOg6OV9Z9ip/hCEOIyV/s2zoSUJ/IJFFGhraVHn+cGYMBGZwgI3GE2ABoYvFdsQQqoQDA3N+tNrDIDF5krSuGTEdbwJCAhdTskkxT2MMqzsqHYMBjqWe1k1Hg= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.16; Fri, 13 Aug 2021 06:32:05 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:05 +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 v6 03/13] kernel: resource: lookup_resource as exported symbol Date: Fri, 13 Aug 2021 01:31:40 -0500 Message-Id: <20210813063150.2938-4-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed368a08-2203-4a96-3de0-08d95e24111b X-MS-TrafficTypeDiagnostic: SN6PR12MB2718: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JSl1y8LmsF0MDUnrKYz4sK0LovH2bCsYEuGs29cc2XU1vPr7TdJm7VG+JwVgbZ0SNxAcj34uExPTK9vIQCEi3wjoZCu+lwDR4dWRa3cyRX4EiQRvEmMeHdjELd3kzEzoMVJzRj9QQhmY8QDjV09bIyVu8BTALyE0nClISFylxSdPUDoMK6Ze5o9eqZr6YEy3xN9udwjYaqg1nF0+YNsH35Z/qXSFxciaVravozzCc/3pBiUNqWHcdLKHQSyNbah0xU2XC7ZB+35MiaigglH+KvvH6m4IQEVwj+3ehoLWMXrEB4X5bqbrj8vhDrw696l7RSEq1tSFtxGs1hVETlsAfFrieolCxRwT0HkTolBsBkWhKJ26lY4Lrf2rB3ST/QVq+ooMwFSxxTfYQ3vCXBCTt321UteSoheeXQ2r/TYnO4uTbHB7UY+2wcSx72DYrd+gBPYORmFTNei5oT2UvJhL2Vg18CHbq5v9MSea/nD+SnkaVRsRiToaO7sgN3du758INmzTibAfcSJPlZ0SehRzH4xgzvBJXP13AYVdvYoRXEyaPvTnAlquaBYLV5uVnA1x4GWq+fj5PbbPCqVGjrTPBlQjqfPhvDlm5cJ5T/Tka0ggvipbg+Nog1ZGydy5nv3vVBtwkmYPWKnzj7BzjUwVRmEEYdOqnd0RKgXEk95jT6cYdTNrm0Y1ZDVmX5d/57feam8BSuy/66XK4qJXeAKp7A== 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)(366004)(396003)(376002)(136003)(39860400002)(956004)(44832011)(2616005)(6486002)(4326008)(4744005)(86362001)(1076003)(5660300002)(478600001)(8676002)(38100700002)(8936002)(316002)(38350700002)(7416002)(2906002)(66946007)(6666004)(36756003)(66476007)(186003)(26005)(7696005)(52116002)(66556008)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YrTkPXnRKUidADlzdXj7gJYeoRZKektg/zp4xb83SJfDnNyLuN591A/6gF/vQZ2q0UbINzanZ91xAFbXio2zyaKGhwCg2uuhg5Ob+juzuezyjL3NWMwJE2ahcdR/E2fMEG/g7oxn49Hf6u0p345YH/KFUSLf44Gy9ZSXIJCUQ9PlqS1uPygLMuYG2JooXaxI4Fp1yzTE/1iL3ImTgoccnwYSwYmhkdLVpkJrKUPZj/c7iorA/UtNiRS4fQ4YViUGJQWYC16yM0SVCPDgv/yYKGvCMXisD9VS7kepomKHmAHkBoq/upf9NxyTHkARbTUcRRNqoORb2BOg64fszSsPql7tefMk4KcN02/wJgNlh8l3YTgpdUbRtD3KVxbZdZrsHfBqokYevmTUwCYNfn8VOni7Ro8jKQuUwxtPeltmgV0z1sYdnmDJxMYnGwDi/E7MSjS0xo/u6RLuIyfqJWrUKnnE5TLlmEr9n+hKC+hE+26VGzuKM31ENQ/NZVJ8/Jl3L1xLTSE62dP9xK01/YEjwTZFtYnyczxnmaLCbzqPfZQyESA5bc/R1XH/n4GSEiAr8xXcACRo7C93OiKGp3YfVnZFg4dLW8rkBQl1SHvt3imTnitoJjOAMmbd662XI8F6bTlBmOl+ig//528ofKEs9Tq7F73l+AgyMqcV7fJgiJSKqR43vx7B0IzlzNkFTPQjirkrOMadfdT45nBlcBKt1D8i2WHjcjJp1bhaFT9Y1reu6QAM/wssfDI0qCeiyqF1XVeDMATib84l7vwrWBV8Mw/zFRgaUa3k3N2PLg0CYwD0eWLyu8gDhCQT3KHcHLVCNcnHKtUlGzKOwWTeSt2Z509Vf++QGN+Vgc1dhGUE4ftGj95JMqJ7T4rwZOi5lV1FKOtJrTy5gycmkzx7sbZ8cVsAkFw7kvss86Y6m+YezO1bNtwPCnaZvSL0l6YVLQQfm6MjPxFcrA9xat8JUI+/mQibmWCDdWSNPz7imta6RlKzpl1y2QyOb11YHP0EWooyvwwSrAI2t3igO/t54xBTp2mMlVCNcNOewQ79SNcn4FoArLt07i5sHTmRLmWI599h/ym46vZiXhKrD9hhz2Vp8vFWP9AILGzAeqkS4OxSzYs4QzN87ZMI3zS7q70FtCTaeFWmrHvgr9mqdRXSXwWlmcvH1+kfkgFAiFANIBOwOg5MNIeAvSttt5PFjnQEmKUF3LjTugjbz40BpzT01JqWCIorvnBWzUzXP48dZga/z4Ofom644x9978jh39uCxRhmuDN6CgjckecH3kv0lf9BkAJ9nx3ec9xCcbIan1k2mgl9q7QVuGS8eyks+N3KaCTb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed368a08-2203-4a96-3de0-08d95e24111b X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:05.0150 (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: YK64d9WEmVwWNTig8PLcffU0yWCg5RybJhihVDE3q0zUNIOZw9L/hGv+pTelQEE7nR2EPuJkkmIpb/IJ/cJb+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2718 X-Rspamd-Queue-Id: 4CF06700BC63 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b="aB/Icd5F"; spf=pass (imf27.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.95.84 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam01 X-Stat-Signature: qs7e8e6g7urcbqdwg3i75zsfcfgnxgu3 X-HE-Tag: 1628836326-722853 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 AMD architecture for the Frontier supercomputer will have device memory which can be coherently accessed by the CPU. The system BIOS advertises this memory as SPM (special purpose memory) in the UEFI system address map. The AMDGPU driver needs to be able to lookup this resource in order to claim it as MEMORY_DEVICE_GENERIC using devm_memremap_pages. Signed-off-by: Alex Sierra --- kernel/resource.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/resource.c b/kernel/resource.c index ca9f5198a01f..227fc9fab573 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -772,6 +772,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start) return res; } +EXPORT_SYMBOL_GPL(lookup_resource); /* * Insert a resource into the resource tree. If successful, return NULL, From patchwork Fri Aug 13 06:31:41 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: 12434769 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 CFFB5C4320A for ; Fri, 13 Aug 2021 06:32:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 77CEC610EA for ; Fri, 13 Aug 2021 06:32:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 77CEC610EA 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 DB35D8D0005; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9F308D0003; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA3828D0005; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id 7A67B8D0003 for ; Fri, 13 Aug 2021 02:32:07 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2A793180ACC3C for ; Fri, 13 Aug 2021 06:32:07 +0000 (UTC) X-FDA: 78469087494.08.B9AD5EE Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2084.outbound.protection.outlook.com [40.107.95.84]) by imf27.hostedemail.com (Postfix) with ESMTP id C4C1A700BC63 for ; Fri, 13 Aug 2021 06:32:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hk8Pn6bZYZjnpcGYqjGy12GVxYufK73oSaDUTrsh1Go+Tlz5LQsSDFdUzaADRDczuIoHgYatLamlpnbJAADzinw7GbRiux0surg1Co6XJl87Ah5YxpV1B295KKUEGJCs8vMcQIzRdrXHs1toDgsqlHWm26/RvAo8nF7aX+SF/aq/io3924LI/5PnvWxR2w1xr5+WJmWRSLhr3Lj7dMytR1V9i9oc1l0nkTOfco7wPycZgp9WtvhIQbDdzk/rAJUa7Lc08DA8JJ5t+Uidtp22zbGUZwLHHhm1I/9sfQv2ZOLoiWqkidGO9AdVV+tZFqaczc7OClELlRdfNjC1JZJIPg== 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-SenderADCheck; bh=qLzQP0Q2sVgjkO1mJavmGwqXRZqTbEiduZyle3KpBGc=; b=LqlfLP4rdnGQrvkrVs7Z7VWQHlPaW3ZQd7N1bOmc+hvAhmTx/61Fwb/17jEGjdww0jlXSZTQQjBW9IzMCiHMj/hWW/HbMMBk9ycvP07nRNMFEers/Ytqgv4m30gny+fU9FwzA5UD+4RRbUaAN9d5dYMr4h8Oo3Hc1PnVHQZMeFMf4sBhcQ5fu/YKF8fn7B7PBOSJhkZh6eXTitYPkaAhfBAtI9jof6uXmuimLIknQMGavE7iUKo/hX5SZZvgu14R4+jTDBcgASIrmiPxhFXWTBmtyU/M8/nejDOo/K0R3rnhC6esP2exkQZ8LXD/xjBaYRr3tjApfoxsHSzw3p4ttQ== 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=qLzQP0Q2sVgjkO1mJavmGwqXRZqTbEiduZyle3KpBGc=; b=cvQhIkuhSmF82AVHaD6tF5XN9DGuh8bC9iKz1iKzJioeK7QTlMVtE0sYieMXpuyI/1FPnsgIu1/4mTlkYq+L4DFz3yHjdT7S5HsSWlxSn5mhTWto99Kra90z0XJXggs0fQVocFh97hBwxCQKejtkSdfVswmMMvwnzu/HEqmiv/U= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.16; Fri, 13 Aug 2021 06:32:05 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:05 +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 v6 04/13] drm/amdkfd: add SPM support for SVM Date: Fri, 13 Aug 2021 01:31:41 -0500 Message-Id: <20210813063150.2938-5-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 88c3f5be-9326-4079-7fd0-08d95e24118c X-MS-TrafficTypeDiagnostic: SN6PR12MB2718: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K/psTYsG0EMeqKnKOnHiv9md4U47pS2wZYswuqI8A5mwzEwQ7bRt33eU65iwJ8C4VWAWx42anVxHtyX9FClZOf/wIGyr6xHL2oN0pbfnnFDAM/i/AzAwuN/8jQTO34ipxUFMFaPaA2WyidQhsEwI2J03NdvPvuEw6Mfdh2fX/3kfQlAPkxurCWKqjpdtIo2dffvIc/LbAF+s+ub0Znu74c94A314GMcCZyDU4/h5+z8dpOPZZdW59Mh4wPl1RdA2n9jzYIQwM8NOIAYHv3uJzuZ0EXy5u6+YLqD8DlMxXOgKNp9ph3P58n6jr2qJO+X11X90Op6SRETmkCpCRJk2USjHAPb4tpL3eSPf7uGZMvadR6oGgw0UjKuoBmDpwqN90rKznif6xNGeBTsdmgPTLK4wKieUtg2LsxW4dR6H7X6nyNsfnAfX/bXA3s2hYGPjk5GnAnuUzx3MGbQErM4fWegYkRyx6D895/mdnIiUSq4tuCbKuRJCr8ifP4wuLkfggJIJ5dP0wUS1De4QAXiprdwqjg8AO7VY2WHabRErJNrsaFmtOE0YJS3V6PXJJDenjulHr7Cla5GxbdfrZAlu1YB1051RI/ARcj2x5SOTo3odXVIoWRpW7Fs+XTxiW/V1nzQXvtmSpo1vVIYCGQkXKX5jsjbpWoh34NUY/Tj7vDCyNvmYiT2fRr2tBhzUeK3TH4l5N+omck6goYL1SPEdNw== 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)(366004)(396003)(376002)(136003)(39860400002)(956004)(44832011)(2616005)(6486002)(4326008)(86362001)(1076003)(5660300002)(478600001)(8676002)(38100700002)(8936002)(316002)(38350700002)(7416002)(2906002)(66946007)(6666004)(36756003)(66476007)(186003)(26005)(7696005)(52116002)(66556008)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t+YuQEph7RFqcTuhLol4nNn21A6lV4RCGyNe9vkD1H3xe54E2dZuhBk2j1au2yVRf6WbCL+S5KB9aX6z5yEtomogOC/Ubpru+1DUoqGduGVGts+l2x5nT4iMs+Uy2vH/54swKBI/YS2QzLwQjjJmMBnnVCPdVNCl8Wr5y6IIujZwnn8c9iCqeyzk5AzeriBDqnckuEgIpGbF3am3E9xT2r8Q/HzYt7PubaCpaWGAxZ6wg4U+I0+ENhVrkylW/hWkk+1NymEEbMvKgfGrzhAl0+TaYEVqljoLoU0R68Yb+5jzUCfV7i0MoZw6jhxWXhlTKWGqStS/RTF5e8kuJ2X9B8WG3yvZNL64os6EmQe3RMHggQc2Fy0Yxb8s9Zg8IvX9z04uzKUv5t50jQAljv3eK1e+FRmsh+paV8Rc7FneJTM7gNIJtxKd20VxxBvzMjzrVE6n0JkaG4uarWB6ubWFyyu/wgOmO9sp7/P88P6orCmAv9YUh2SICBdCyv7UpdBvsMeR2HgGo/y57l40+nK0roremKhQ9YIDmsUikrzm9bpK6NwoqMHsbIwrXU0w3lISrjl6NQ3T3sSCkEg88xOJs+BBSjpSAL/mKn70/5T0qiNXQkeAFRZmIx7sQQhZ5rShpkMpK+Cp9Ed0NUJ3OnU5bgAJY79QciKnLm/YfJsysrlodS7+hHzhQMOdCUdlbFMZ390VG+OCij0i9A6HSTsUtrP6uxfRDCTOTRNjPlfKjUgL9CMuX/3wkri3kwY4+j03QcGCpylFmIlPci2LLxF7kDbdAtZpXLnGabXP/bElmqy+JPgIbwWU387ILG+q/C3So6vrxsMrAqDCE06E/L8s5QyOonFjEPz5k4n5MavENafeDfo1gabk10eoNIhN4rIIkXpEHDtAWMAVLA49zSH5eilPIwI3qZieAj2IMRtmgpsresddbScY2ai5pjRaXNyuT+kLCWFci38uqv/hvmCIPmxEZItoJXU72pmSilpTlCSMnLHpCL4CpwI9dwDQJOvPu0dGEyFf2Jir3fxk/yTJ82wgqhi0QD5k3gM2N7lng5szIwOciuNE+msMqlUPXjfofPj0ourlzQd3vn+rsFfDwdUFZCS2sVEQEXUYLh+4bu6V+t+rDg5EpI6UsR2I9k9ZkGIyv87Iv5b2wj2DXfAMl+aaqoylMnqRqRrYGcZip0AcdYbMfgOU+KcV9z29j/f/BxSvue/lJFH5vCKNpPogxfMqfIfmLOgBhDFxq6Vh5rrtQNcJHJQkZZpIxRU5jkWp5ZwFa4nmO3DLv0Pv2lNrJIkQlgbu61ykfGPkFjJVY9jMKEg5thq1C01DIYZMeNXa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88c3f5be-9326-4079-7fd0-08d95e24118c X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:05.7248 (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: NQKCazYIExa1Wh9Ctjg8XABWxVWJDRH69RPKe/s6bGtL/zbMRWwikHIARrxpZYEQjgk9+jogSpkdXTbf1rNR7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2718 X-Rspamd-Queue-Id: C4C1A700BC63 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=cvQhIkuh; spf=pass (imf27.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.95.84 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam01 X-Stat-Signature: d5hmtqd4anwqaaia9tjxqjpy3p4uw7bu X-HE-Tag: 1628836326-959597 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: When CPU is connected throug XGMI, it has coherent access to VRAM resource. In this case that resource is taken from a table in the device gmc aperture base. This resource is used along with the device type, which could be DEVICE_PRIVATE or DEVICE_GENERIC to create the device page map region. Signed-off-by: Alex Sierra Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index dab290a4d19d..24a8b6d4f947 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -868,6 +868,7 @@ int svm_migrate_init(struct amdgpu_device *adev) struct resource *res; unsigned long size; void *r; + bool xgmi_connected_to_cpu = adev->gmc.xgmi.connected_to_cpu; /* Page migration works on Vega10 or newer */ if (kfddev->device_info->asic_family < CHIP_VEGA10) @@ -880,17 +881,22 @@ int svm_migrate_init(struct amdgpu_device *adev) * should remove reserved size */ size = ALIGN(adev->gmc.real_vram_size, 2ULL << 20); - res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); + if (xgmi_connected_to_cpu) + res = lookup_resource(&iomem_resource, adev->gmc.aper_base); + else + res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); + if (IS_ERR(res)) return -ENOMEM; - pgmap->type = MEMORY_DEVICE_PRIVATE; pgmap->nr_range = 1; pgmap->range.start = res->start; pgmap->range.end = res->end; + pgmap->type = xgmi_connected_to_cpu ? + MEMORY_DEVICE_GENERIC : MEMORY_DEVICE_PRIVATE; pgmap->ops = &svm_migrate_pgmap_ops; pgmap->owner = SVM_ADEV_PGMAP_OWNER(adev); - pgmap->flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE; + pgmap->flags = 0; r = devm_memremap_pages(adev->dev, pgmap); if (IS_ERR(r)) { pr_err("failed to register HMM device memory\n"); @@ -914,6 +920,7 @@ void svm_migrate_fini(struct amdgpu_device *adev) struct dev_pagemap *pgmap = &adev->kfd.dev->pgmap; devm_memunmap_pages(adev->dev, pgmap); - devm_release_mem_region(adev->dev, pgmap->range.start, - pgmap->range.end - pgmap->range.start + 1); + if (pgmap->type == MEMORY_DEVICE_PRIVATE) + devm_release_mem_region(adev->dev, pgmap->range.start, + pgmap->range.end - pgmap->range.start + 1); } From patchwork Fri Aug 13 06:31:42 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: 12434771 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 AC83FC19F35 for ; Fri, 13 Aug 2021 06:32:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5C9A2610CC for ; Fri, 13 Aug 2021 06:32:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5C9A2610CC 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 CEEFB8D0006; Fri, 13 Aug 2021 02:32:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7B6B8D0003; Fri, 13 Aug 2021 02:32:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7DAB8D0006; Fri, 13 Aug 2021 02:32:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id 86D3C8D0003 for ; Fri, 13 Aug 2021 02:32:09 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 31465180ACC3C for ; Fri, 13 Aug 2021 06:32:09 +0000 (UTC) X-FDA: 78469087578.33.03DDA06 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by imf17.hostedemail.com (Postfix) with ESMTP id B8293F005544 for ; Fri, 13 Aug 2021 06:32:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dN4FDsqGZj0Vua7rPwkKUd6Rmm8DgR9lct9xSgc/63SufNOwuRkt9XKE47MdxSgQdDFuhFxjtEZZf43XXvSgtxGq5ZDo1Rp+Vc60ooxUWtCiDqlVBx+3hHIDgb7BIY0getn86lYiQOQzTE2JvrAzO/rHMeZ3anTUco2y1ddvxnFhBhgbV2eRuf8g6iBNuviesu4iiVsHKTipssrSf3lmpbkivmGhrSCIW/BNGVzmZBYXI3Hmo121tvLgtp29GDmTehKXEGMHVLoTbPhBmyLXh+/QKEQBRGiCg9jrVWhmVEgwFuANmSfmBrypgi1WKX3doIpj0XKNJBwRdgm+ImOZVw== 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-SenderADCheck; bh=X3ThOLGhVWnDkKgI8BE3aHhWyP9mVZRtKdRj/+WuuuM=; b=jj2KQZc/i6WrOGvxyMrGx5WlOTb5cv5dAW0BCibPpzgAXKC/pIqPw1e6O4WHzF98Bdg+Jl9/jiPafNQ8BRHUkyYtXR1ZquexbflwthWPOJQmSsatMm9o7IrZdWU3Mv56rzYo7e1noludH/kdyq3KatnNHh0sb8ardqMuXUu6DuicmGHZqNkFt5CTRmIXUTKQgX6JI1NJ+vDHsmUKuzU8tdNMoiYqzTUL4yWev7rPKgTL5aBuha7VtMq091WZrtrYtKOKuKlYjreHkoGTI4DyxATdf/qQXUyL+Pb5xPhu/GnBHcIq6vjz466QOYlxjHbBLimh+C6fS7GiaWx2a8YhAw== 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=X3ThOLGhVWnDkKgI8BE3aHhWyP9mVZRtKdRj/+WuuuM=; b=Owg2f9c4wD6N+qsgOA24tOfzwrUMBvkE7CyTk0bPuk2VUS4qDhHsS/UcgVq66H2RJXDYvwlJfdRSF1m3Qd8ct4h6Tcfdk7exNl6mIjz94j12yrHsiHZeYjPO42z8pKtPp10KHizVzow1OAXheo4ddp+CUtmLQGfyo5DC8bzsfzY= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:06 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:06 +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 v6 05/13] drm/amdkfd: generic type as sys mem on migration to ram Date: Fri, 13 Aug 2021 01:31:42 -0500 Message-Id: <20210813063150.2938-6-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71bfe2f9-9339-4452-9aaf-08d95e2411f7 X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 41BSe1ceSMYGsk1V4tQNttUVH1V4vToWcnmdQNbGNHZlpX7e8yWk15clQUtV82M1X7wdqoqcxmzFlhrBqt7ZosI5/EmKTXptLjXkQdebgPpodE5DoA8iastOFFeSKETXMMP+77IgdbentRCezgTVusvztcp1ilT18d6BV+eh9pB++0/LBV7qxD95gWrVuCK1gcMUZ4f1Tw58iTOBU5F8hEUQc09faLVmk3n4hSXabFnbFInB8yNZhhjFj9wPwx7hiL9VysCpYY/Z4iAbrEzLfEVKrLk5sl5iA/Pbufm/a+nW8DTQeZvJkpu84PvNzjI04K4Fxp/bmJHm333+kyrPAChTh5wqmrhx4tAeL66j6uHKF8c91VJKYDfg45CpDQhoUHyCgzXrFxFaDoJbEwsO1M76k32/eoc1VUzTOiKdpzx1UbNMM1n4+EyPuSbPP9GZe495G6oN+fKKRnVGTgTJqLrkQexmrikBqvY6d5V9LQv1wCgr6a1ijgFH52UtxyyfdxfrpYRRd0G/jWSxKzD+ge1MbNwUNm7SzSHHhrQhL7sq94VjALEi4l93ICLnefEFRBPQQiWJhLxhYSjFfXJZg60PqjbE8n/Km/gh2dHCZ9KehOURx1S7B/HhMzMb9dybqkuVD0Ae+Ch5GOSJTKUVnKoejrKaPQLY5t+EwVCHu8DHEkVqbWXO71djjYvjB8MQ/qk3W9UsgP2KXTulOlGhbQWptnl5+oEshgyzBT/uMvU= 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(83380400001)(44832011)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4v5X2vns6d8FFuY4aH7+923wOI6+3ZD82bGck7OTW4YzAZF7jAhoNpOWZLkUheBV1BMx6BXoTNQTSatGqTFb3clvsooLYyFaC7KrK7aAMeElCJ0JNhIrV07o35y8lwqF9Mgk0fmjzWJbL9tpNZRSUkeA+961vHjriw6FgMiJhErDDOVy0Hzv7trMVpKipMA6IQpiqDCAHeWeFT/k6i3RfM4RRrwerIgKvUVi+k8paHbjoI8oEqEAV52BcR9A9g9G6lVFwEAqSwsHfA7zFJHZ39GhO+gWefR4nNrRWEO8mAlSLuqv7VJnV6eq7XCx7d/+X4L0YW10daKwaax94kyv18gQa9Rhzh0rr66kzdVIdIUREQSANdaxEUgtpt8EpSMPZxTTv0sbOwLFna3MfayRhVAzsXLzu/TDGrDtF0xwJ7bzr6kLBLubhnxD6j4ed6yjQ+zevGkFBPB96rJpICTJBIGZRK4UoEI0XYosH2gV2cjrxc2b8eJs11BqmxjX84sIMqzUveRhE5HGd3RMUeneJl9x9cuWgbxO29nv7lFSrc+iEURjfp6rv7v5W1IOXWfr3HDsIyZo2FhzOcTYp4HZuSSlULvrXnZvyvrQkYkYT49dDs2xcOSGySH/e7lyA4aD0l5eN0Wa/6ugol2m+ZQZXfNn/PFWWEkl2jd71TU03fO1ZWG4+ZPW+I5D/8KrU9EORXSQFEcCOtJ8poIB6Uv4UklOjKqIbNdC+kaLLA9StE9jY4oDZK+HZlS3xt3QrPGERD9rPHM2Ju6Hcf+dMUl+u1bK68flvY0/n8HYeAMMK2DLw1ovV5Gak+V5lcw6WXwUqPmfuou0QvyCaysFCPGw94vYxumKOuDol4OcDj5cQorNS8/iN4ATcOBorr3LQXR6PsfE4nuU30rzBT5hTR24OyOI2D/SdElEmhDFSBGoLo7FB4hpvC0FdT9YB5XGd/6gE+4rIMRky6j5v1clZKak0p2FahT1I+jVw7HK4DXPcgtQJdCixGwWS3fWC5SauxrEeU6u79+Cyo2cWr2cPHwk6QMXZK7gYJ/fWlslvcmBLrM+UlSfS4UFbt8fNypIR7WvkzpYF1F7B6TiQ71c7XtKAdKMOj8qjofht/9ASQgwbKcje2cGGrWpwGMevjyVDsWHuKsh9AD3t/C6AO3K5oBZyhHeBpUm68mPg/3uJ8N1R/ULjGXVaV6KmUP4xvpJH49+hdRjuJqAL+IyKnPSM1kosezLSuD6toOK8WNBhrRLZOoHED41TIWOw1aueUcsSb6Cb+eHPQATByLYYrjAP/64Ogvb3tcSo8DCCpH3ZpBbqGAvwU+SRR3lR8G5XLPV1/YA X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71bfe2f9-9339-4452-9aaf-08d95e2411f7 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:06.4168 (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: 1mHUfx0r9yFmAgEGDCL0e2//lYys7pLCTjMubmKVfl1U4AHmSZkunD0oeivBBzm5UeMz3uNO8nCa6moZuOIVQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: B8293F005544 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Owg2f9c4; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.87 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: 5u81czez4gzx56rnwraouzpu85h7kayn X-HE-Tag: 1628836328-947308 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: Generic device type memory on VRAM to RAM migration, has similar access as System RAM from the CPU. This flag sets the source from the sender. Which in Generic type case, should be set as SYSTEM. Signed-off-by: Alex Sierra Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index 24a8b6d4f947..e5b10de83a5f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -616,9 +616,12 @@ svm_migrate_vma_to_ram(struct amdgpu_device *adev, struct svm_range *prange, migrate.vma = vma; migrate.start = start; migrate.end = end; - migrate.flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE; migrate.pgmap_owner = SVM_ADEV_PGMAP_OWNER(adev); + if (adev->gmc.xgmi.connected_to_cpu) + migrate.flags = MIGRATE_VMA_SELECT_SYSTEM; + else + migrate.flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE; size = 2 * sizeof(*migrate.src) + sizeof(uint64_t) + sizeof(dma_addr_t); size *= npages; buf = kvmalloc(size, GFP_KERNEL | __GFP_ZERO); From patchwork Fri Aug 13 06:31:43 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: 12434773 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=-13.7 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, UNWANTED_LANGUAGE_BODY,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 60097C4320E for ; Fri, 13 Aug 2021 06:32:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 13A5B60FBF for ; Fri, 13 Aug 2021 06:32:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 13A5B60FBF 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 529738D0003; Fri, 13 Aug 2021 02:32:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 464858D0007; Fri, 13 Aug 2021 02:32:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23EB68D0003; Fri, 13 Aug 2021 02:32:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id EFE228D0007 for ; Fri, 13 Aug 2021 02:32:09 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A582219B12 for ; Fri, 13 Aug 2021 06:32:09 +0000 (UTC) X-FDA: 78469087578.01.449E8C6 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by imf17.hostedemail.com (Postfix) with ESMTP id 46191F0011FB for ; Fri, 13 Aug 2021 06:32:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AS+E4QPRx4PfBWQG0qMv/+tb3nLsmbSwJoFJeweilgB40Sm4LZNFsp3Yu3gxkh9ZdvVkgas2NaVqWFOGVmILX+EL1XNYK3FxbR6G7Lhr+0fYV3unSpbUyyC6Tb+RPLZQHjk0ZaUqZj1772q2bGflPFl3rj2I9Pw3JWfBtuXE+Qa6BE6RKoUCdiKRrB9qerbGrofc0fr3pYTLmyxMIQBcNoNqhJ9zDBHch7E3FTvHgy1S/82R+Ameho5jS2k8IQbOF5cvp3u1AvFNBpBeRWk0FRB5NMqJ6UbUkkvoQEVZqNHJKkH7QTdPfD0RIJjIGQUFr6ADcvruAXqxmpSbmclo+A== 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-SenderADCheck; bh=b4DDiFWynkpnJt1h94Bfq6HqdNu33C5iIfG/fWH4BAw=; b=oN/EgSGA6IHLL5b8qyKt5++pd7MzwkjTAqOsVwFuUeB1WH5PPUBmv2xrl4oQi4dNAFpRozg+cexr6lZ0Da7GXrkZiwatpBeXPdHNk3XWTBD86axth6qvA/FUdS6hMCTmtQZnfHn2339S2DIAsLSDvPTGen0ty3btXvT9RXAT1DqEl5TPIV5PxcAHJkYlPEUZ1vS/2XK10z6X9f9NiWJCxUKnWU/2yceuI7Gc7ZLxbSk66LX0l40lr4cRo/eUIBPMkQh4YePpec4jYg2ZML0wzOFQWyKX/iT0hkEDb1sbITAXKzZupzxY2arNO7k6s0K9qhqKnR5EozwoqMJwNpYUhA== 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=b4DDiFWynkpnJt1h94Bfq6HqdNu33C5iIfG/fWH4BAw=; b=YR4YpLQp7jqrLJAFl07bOf577q/ns1MIcDzUSvorlitYhgFZEiWzlpiqQmRVCJER/4FrFvvFvC8hjYz9e+5R4wzdCKKCi6OJlOT6MRba7/jCbE/suZ5S5XY6sToX9tIisGL3x2tThMShzh5Gx3s1Dl8P+FphyLUW8IJF/ZiadB0= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:07 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:07 +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 v6 06/13] include/linux/mm.h: helpers to check zone device generic type Date: Fri, 13 Aug 2021 01:31:43 -0500 Message-Id: <20210813063150.2938-7-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4b7c39e-3d25-4f17-8195-08d95e241260 X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:156; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UEzkAzJX6FPrAXt38j0Y0RLoryVT8gLXoIbhYHYF2F9f6jhidRlaaptSu6GDtv/E3HGoZmHtx9+gFRgCna+nnDhrX5L2bmDbPEV/tsX/0/VfqxW8n1rWQSR3GWY7FWFi8XLs7Zl1DGjlJjNUX/4myDNPkZ3WROYz6GS0yryBmVm5DIOFlSiTWafiSyYPUGtTt5htUpDDmBfdruVmQgbVzgE9AixQ5edzzpfL+sVsNbHN1o+3lEGcK+tmShCObYdf7KGMCDy3zAIEuWOgssTdS7cIIaw44uQ/rsr7NqR4BsMEv6/OXC0cX8a8Fk8FiBzmhwqC1BVb2/rtefqLixfuJPaslMF6o2XVx54LDQoROjDWX0AUcaTb/hF/A9VDjwntmUwHCX08eCyg30jOyQWZF7GNBzcZJFilya8nZqf60OluthvRCpXfaJF81LWxbfSwYCIoki/L3AAET4mf6s0wGfcXJMxrHUbUocBDmTvFn4qbzEWhAOPuS/lSy1Ylj69LhrYXc/RPwsf0LtJzdF0vWNiZNYtXbbRjwddwAEQPQM4pgpEx8m8v9OXaSHVTy+dPv7WSTAtwXK4gqdbaoYoMrzn5E/22YLQLcFSHTttPggFNUOCXSKoi9BZfp6nBWhXyUkElqnvQDXlw0a7Vyo4r2pjM0r53C6ReB57Yvf1sEHAsuUBAbLt5LpNX+V/1d8KgT62ci23GcP6q3HvgqC+VjATTPk5xPqwHjWbBfKLdSYs= 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(44832011)(4744005)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H+4C2CEE3x21UsbFUkVhEAP9IE+U/3jMekzUcWVYF/1SAAqaql8j7bm1HMn5bHyxAmowf/LnOaS9/YeIsxsEutLnRTdofSeltNeqyxZSaj5H6Lj+cM+Ucd1TK/IByo1joyth7YrkXugUzLc2/dn+m22a25lrt0UOxclgyVh6R9Et/8nhiOIQioX4VqGYabeybilIMXj8AfwGacWklSzsCBnWuMGsUsPM1W05VPfi3QcMObu9NNzYmgqqwahTTTT626ZR1wp81BymmZ87+f49gSDogTA2JtZBi+T6vkXmHNjltAd3zXjhm08xmKO/j+pvRQv7BNlrW4Pkuty2FVHxrae0IiuC8jens19PI8kCKVtHKVCWCl0gZ9JBYHQEgNMLl42fd6SlMZHYTvT8OslW1YVxcTXsoaOG/W0tlavSJIhFXESZWf48rp+o+6M4F5n3q7bnwAtdINzCyiuL7Ai5w3QRBuHmXfz9TQyeX8nyNXHWXOtX5m4fPNZkNxD6exZhd+sptXI6D/G2UV2ih8xtlPXNPjpR+hgb8vHxjAxKI3LhjCuFcTe/uuNPgeV3GEGwsEdblJsBf/zPiwCSlpSFQ71deDYUYLSkoq5xlq2Bdmznjypc+mW79IaIouw8wUdXXLZYDiBLCQ8d9Xl+AoYu0MYIFAhEqzfCyLlQg6RsN0rrhED8nYWSFmUcbE5tNeVoclHLukli1U7icYkA39dZBTGrEXjpR4Sut0NtBrd74oYebHhDHzQYg3gor/a7EO8DqO5X8JBwNMQbH55J1PmMTgtIIe93jsOs2aYq8KOxAAj6I2ekM8TyTm/WzZBH0/dVcH9TAA+2gY056bmiVVFP4UvIfHqph065MWYxOn1IEiBXDaHmIF9lQb+lhT1vqMX4M67stm0zKwA3u8sKut5hgAiC6kAAYev8Cd9roTlIGPMuWv4wnRoQZHX0vDHkoD22TdxGgbtDh6T34OX2JczUDEKRx4GlZY+iXVBA2M5rU9Y9uP14EW88a1CqRKxs5J3RJvxIJT0tXKFodHXUCYPIn/EpGDtcen38WMeqNWWhRkD15C04qDFv29CwSACZkwlXA/qd0gOD1ARCCdeN+fGNNhpqC7l/XJLXmm+tCN75k8aU0wtCF4aMipLvbC2on9sf46ysYj75eYYx84b0nefJ6lVn2h/Xn4dkkCBrqyItZaup8r/YVVv+0t1kZQMDde+RZTFTcl8hisZj1/dpOan+argxfRE34p1wyK9Qf6JyDaTiwPL3pOVe1fcn0xiZs4vj/AH0Pp/KB8uUAVLBZk8NtvvpQTaeY6+hefUX4rPZbg+BvUL8ZGTEZg+IzHyz4X/X X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4b7c39e-3d25-4f17-8195-08d95e241260 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:07.1073 (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: 12LE+rj580zneHsUum2R80wzrSe0oqOle553ibJ6g2bB3gYaBsDkkxH5H5f0nTbdVmekvkVUgR1YAjWK1kDjLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: 46191F0011FB Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=YR4YpLQp; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.87 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: 6ogdmkqgjeeuq1per3f66ktmiym4rzrt X-HE-Tag: 1628836329-853084 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: Two helpers added. One checks if zone device page is generic type. The other if page is either private or generic type. Signed-off-by: Alex Sierra Reviewed-by: Christoph Hellwig --- include/linux/mm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index d48a1f0889d1..c25cdb92038f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1187,6 +1187,14 @@ static inline bool is_device_private_page(const struct page *page) page->pgmap->type == MEMORY_DEVICE_PRIVATE; } +static inline bool is_device_page(const struct page *page) +{ + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && + is_zone_device_page(page) && + (page->pgmap->type == MEMORY_DEVICE_PRIVATE || + page->pgmap->type == MEMORY_DEVICE_GENERIC); +} + static inline bool is_pci_p2pdma_page(const struct page *page) { return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && From patchwork Fri Aug 13 06:31:44 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: 12434775 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 D0FA9C4320E for ; Fri, 13 Aug 2021 06:32:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8159F610CC for ; Fri, 13 Aug 2021 06:32:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8159F610CC 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 0E44F8D0008; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F391E8D0007; Fri, 13 Aug 2021 02:32:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D15D88D0008; Fri, 13 Aug 2021 02:32:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A53858D0007 for ; Fri, 13 Aug 2021 02:32:10 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 45A5319B12 for ; Fri, 13 Aug 2021 06:32:10 +0000 (UTC) X-FDA: 78469087620.29.CFD4CE7 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by imf17.hostedemail.com (Postfix) with ESMTP id C374DF0011FB for ; Fri, 13 Aug 2021 06:32:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QP3rt7Oop0Xy1FdCC6/UdJOJ1qYzFFN1adUeI93ujDrtt6HqijezhMVxZhtNe4zqQg4bDI0QwkPTs5haeEb5MjpvOqeaPaDivcKNPvwxHeTO0Kd8jiHcDmK1zpAFtzZLydkKma5/8RDKpy6BA6tarZLSFu+NDaGUm/5SU1QIEWmCa31lUsw5WbPeOeIfpbzRi6ltYEW7jQysthYdCWhq/4OS+oTbFfG0UOmkR38CNg3k3VwTKQw0GeZM1r9DyFjbGabxJu6fk+sWZ347wjGWi9ujvBKf/T1KFfu6r9FqMWVnjQ9OZe3AHsEOEp/n+sGE/bpacoyRnSbZ5iIPz8ZyIw== 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-SenderADCheck; bh=NkgzVl+/WajoOylKd+qelb4J16WUJoVRVM9petSZXSQ=; b=MQJhMlf7+Ildrwg0txriWFrC7Fz9XOQY+JDZRprZvT39L8vWMpDmAZL1+zBXbVHetOAhidtmUtaOjwK1lAIM0iCjaKgMhZ31z3NLZ3K6Rhf7H5qcaPAb4/i4a4hVZMNYD6LoUgJOmWfILsiBvfTPCZeoN8eq/wcAiTqwL5ri5l58xea6PNylknrarlqHw4Y2M1iLuJkgY8nSK0qBjHvmyI47hudVM02+diGsi6xLyyJtLeL6PXatPsc5YpO7LAtRd/1eBDk00Bgy1qik26wfzlDhChKIpWxfw/V9tx6+jZlNuRk0zKnm3kBKbpgfshP4zszmMl2P32YfjtfI+5HcHw== 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=NkgzVl+/WajoOylKd+qelb4J16WUJoVRVM9petSZXSQ=; b=xWO6N83k6diXu2c5KGZSWXveTEwIAF8zvE08cMlycHLdlqMU1IemS3j1LLQ1CsKFdiUeZcCWmojgFd0n9j5EAeQK3oxgd400FbcyG5R+IZF3IkMQe0IaSB333c02sVqmk7NaDomn093IlCIlyWMOGHa9h+57IofuoAUD6J4khXA= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:08 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:08 +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 v6 07/13] mm: add generic type support to migrate_vma helpers Date: Fri, 13 Aug 2021 01:31:44 -0500 Message-Id: <20210813063150.2938-8-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed1e8986-ae07-45ca-d386-08d95e2412cc X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rg3ShFueTcz9lEgjGgUWfjDqWVnsPBLRZlKums/Weo9h73PgG6lom36q4RqX1+HSaeeQp/4uDau/pyXD5fL6jOYwuwv7un5RfU1AV013uwo2YShIuLbETLZzfok64Li6QF4a4mg9dwZGiIrYi5ZscpHnwps+NnKKaZE/ObULAPPFsHkvfArRZKuU+Ha5h/LfQFV46dSxfe5xl8S0fIkx3AbaCtTxYv6uYU/Bg6uEyFhEkmlBh85jhB91Fr7TJWxsyaZKMaqehYSOjnw90ZHIhuVslBPEVOsyMxKh6CpWalOxX4RuIuJpWGC9NzR0FntlXnD5T9DgAVYangBpie7Z5JdvDFZXaUFAyzYbe5tTSrRIM5OBoHUDt5z7QazWOfsYpIQM7mdRddqwKjO1+wa7ugqgBK6dsz4ZHjTEVrRodG09kncCBrKjSyFMJjgSN5RYE5LcApV5cR4tEjW9UeKzwFqfQe8hKeXXRTbpI89l7kBYAgW0AXLGE3Imj/BC/tqvhBqzuN+JJrBAqSZn4E6K81SyqCTPcH+exg3GMJdGtNH4KFawF8Ol7q5IVFhd9lL1p6iO788GN9CNwTSAKeJMVK9IMyHVwJtGKHb9HIYnPUvNajDgmsHLlH7j4PIwf1tR/fEC22rcgxJdTmPhLwxHzMFkCLWFThLQQRY44xJ7vIySEUqQ9mChwKEOV+/Xsnh9FyuNX/6Qk6LB+7kEtGu1j4Ag+1XsufHoaiOtUmOwEa4= 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(83380400001)(44832011)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dplcw4GvGkSCMdfXZsn44I2BvKy2p7xaL7d498iBEniu7E+zntdszuKT/AlNAd8pqmxfsm1ep6+GWJcHhfwwocrD7hsEqp/f6+FcdUMnfpTvh4Jp6IZw+DLwhs7Tp9hRH3EzDEbazTaUW+u5RPXaYYMuhZWZGmsOLAvIcxmmR8oGg/0NGLZOaigzkqr2OisEJ+2FmksUmsG7cTxYNZljgMWngS4bUv441cj3N5rHodrW9VJeSythjzo4pl3++sPZjBqb6jqwZPXJn1BHp1M4IxKK+uSUQ6jM3euVtzFnfOQmLFsV9AjWdIz5wW5qUpLlAzwxgx6NfPGrYVcX6IToQjkUsp+w4G8R1Foy88UMk6jYbNM5Icg5IEQ8IhNZv/ZLZesM8JH4/nMx+Ji/jW/NbzOshuyorPZyBctaScz6UQK+Clg/Fmo3jtD1fo1TAGpk/gezK696Ov8qvt2ni5PhuJwBeFidMlH4vcrFjH4GvmvqZMUBfhXUr22RIn2HBVcewQ6c+suAfx7QB5qOMtCM/C7B1sVHTrNHiELKo7vwCTgvUMacxYbGEQ81jFdqSTHIoqwyV0MbCI5BfeYyVZQxD0floDfGCVkHUNdJ1shedIswNtXOpTSAHijcXQGBEbwOOcH67qN/oVljIK3uJBwHJOMreLaPWQmeg9It6GHgerJ8HWnEqtFHjwmra4ifoKRkovjohEg9glwFamPnBjsp1gUrfzFitriSqfusVJuijpgkZE0oDGgvmq+t9r5ktabgabXh07eoUJXIMVQQImdX6rNqhIBhaO0JEEH263QzEegdqMW9UO+HMSWzxpgBegeRPbQRAgxHeoqbzyrYE5shIGGhM12QxG45Y9iDY5XH2kHPfMx1m4ZswUKEDSzUFzPGaLSeW9e40zT0rlCFn3YJlcDT5wKYdacumZOG9Erybq7yH6vTyF+ZpupQmV+pHd3UqSINMZNf8uCHFbigQCmfC5/OTQL15+J5giZF3utHl2gB4bpQn21h4zX4454WiN82uyJCJyUZIxcTOS2uABGCmoKpDKOtZW5DMMS5tojJi5EfKmb1EY4nRqmPXBy6MmBuyl7sfg+G50emrKJexfV2FleCYXitNEsmZHkuRSFSU2whEH+tr5+F0K9KNZR+s9qGHOFlXRNHG0crAYOxJ7flmzgk+JK+Ic5G8tUU/cYZACnVIgBFYMOhCg0SNfphhZhMZt6f3EW9NUuOpgahCiwH/4T0B0d+MWLBI9e5aAB0cF8EQeRFdDZgkrPEpVfYVgpjBcBzbU5yADaZ8ENluW6W2TdUV3qQ3lfWUrlNUwhL1k/5TANkf4e53W8M+g9oI10H X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed1e8986-ae07-45ca-d386-08d95e2412cc X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:07.8396 (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: Iy6lqwV1JSzVhgsn/JpiZBG9en2UTL//aTqbI5G0P7bkCK2aw6OIaocblNpDzqRWXfrbBb56oRqNqvTHviXHSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: C374DF0011FB Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=xWO6N83k; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.87 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: 9qifsmyccn53dw9t16bn3afq71sjcst8 X-HE-Tag: 1628836329-575220 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: Device generic type case added for migrate_vma_pages and migrate_vma_check_page helpers. Both, generic and private device types have the same conditions to decide to migrate pages from/to device memory. Signed-off-by: Alex Sierra Reviewed-by: Christoph Hellwig --- mm/migrate.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index e3a10e2a1bb3..f9e6bfa2867c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2565,7 +2565,7 @@ static bool migrate_vma_check_page(struct page *page) * FIXME proper solution is to rework migration_entry_wait() so * it does not need to take a reference on page. */ - return is_device_private_page(page); + return is_device_page(page); } /* For file back page */ @@ -2854,7 +2854,7 @@ EXPORT_SYMBOL(migrate_vma_setup); * handle_pte_fault() * do_anonymous_page() * to map in an anonymous zero page but the struct page will be a ZONE_DEVICE - * private page. + * private or generic page. */ static void migrate_vma_insert_page(struct migrate_vma *migrate, unsigned long addr, @@ -2925,10 +2925,14 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, swp_entry = make_device_private_entry(page, vma->vm_flags & VM_WRITE); entry = swp_entry_to_pte(swp_entry); + } else if (is_device_page(page)) { + entry = mk_pte(page, vma->vm_page_prot); + if (vma->vm_flags & VM_WRITE) + entry = pte_mkwrite(pte_mkdirty(entry)); } else { /* - * For now we only support migrating to un-addressable - * device memory. + * We support migrating to private and generic types for device + * zone memory. */ pr_warn_once("Unsupported ZONE_DEVICE page type.\n"); goto abort; @@ -3034,10 +3038,10 @@ void migrate_vma_pages(struct migrate_vma *migrate) mapping = page_mapping(page); if (is_zone_device_page(newpage)) { - if (is_device_private_page(newpage)) { + if (is_device_page(newpage)) { /* - * For now only support private anonymous when - * migrating to un-addressable device memory. + * For now only support private and generic + * anonymous when migrating to device memory. */ if (mapping) { migrate->src[i] &= ~MIGRATE_PFN_MIGRATE; From patchwork Fri Aug 13 06:31:45 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: 12434777 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 28700C00144 for ; Fri, 13 Aug 2021 06:32:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB528610CD for ; Fri, 13 Aug 2021 06:32:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB528610CD 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 721C68D0007; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AC818D0009; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D9AF8D0007; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 292AC8D0009 for ; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C6AFE180ACC3C for ; Fri, 13 Aug 2021 06:32:10 +0000 (UTC) X-FDA: 78469087620.36.8A6EA80 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by imf17.hostedemail.com (Postfix) with ESMTP id 626AEF0011FB for ; Fri, 13 Aug 2021 06:32:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LJ/A7U6Njpn6UStzDYM/axYfiN020U0KKs5k+8tcuMNWT+kWWoEhrm9aQpnuedeVNozi7Byy0td0wmbJuCIbdkYMvfUZOEUeB90DHGpydhU8jCC6UbQP2eJdJ/b+4GI9/UWY6Z0vc8tsjDWOYf7P1qI90YTHiwN9UnolbqSc4XOJUG9YDcB7K31QbTB9bIBjTQ+NxUz0aeiQowCPQe7tM1lLCVkeYoiFK8EG5fuZ5AFasXovV1+Jc9+0Uh3iMFhilq8RpoWlL/RetfUJTAPHwCpdWAU/I5BVtEwkqgcpaYh/ZEx3dJ6zFtbtZh/z4bGBr98uk3sQrLWM/v65nPFt7g== 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-SenderADCheck; bh=RE6mJgdreAqBJ7G9HDx0FYbyAtuQCQ+niVvrBBIWEFg=; b=OMWvxM/pD3/akRNGUfHhXIjeSd35En9SK1gQdzEGXajoYp/Q713RjwAR3+a11sSnlCInv7OKuaRuYMuICg4kJT0Frb9PBZfxZo9Rq2y4ttCLhinIDznIvuHtF1dfbGdCt4GnulidLu9Q4tM1J9rOvWfvqu0Ho/Q8s94I/hW5vvn6e5lbb8X6Ch7DwG8geNi/tgHIjeyrVtl/ZFO6PYrGJjuXOawmPBd3VC/kaRLLrI7iAKhwN6WqNmplBNmeTJk9GnrrE2BZGufAM2TGUvXaTICwefKq3jPofi42dTE1griigsaZAZAt3l6zKNmpItQ298DPqJj/Kj/OjWrTbp3pkw== 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=RE6mJgdreAqBJ7G9HDx0FYbyAtuQCQ+niVvrBBIWEFg=; b=Ir4hxU/ZA1P6x2D4o4q3YjCXZD2pG9lAqIRcPhTYob8JpdCyOhoC+pUQuPsXnwfEWdbkQhZcEYYgA0VTeMd+lYoKpK8V6rBAdOTb0w9mWsg/SsVNa95Ccb8/yIfMbnpKvoBa6FxhN8DtKSqp6eIZ9vmaWmCocpM6iduSyDwn2VI= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:08 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:08 +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 v6 08/13] mm: call pgmap->ops->page_free for DEVICE_GENERIC pages Date: Fri, 13 Aug 2021 01:31:45 -0500 Message-Id: <20210813063150.2938-9-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd334d1e-b834-4780-a3ff-08d95e24133c X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:418; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PKU0bvNWpJkLhsNkHyJmKznyMGnQ62vTJ0iroZLuLQD465s0MdCoobltvE4NrH6/l3fXBevUM6eEDbPH1DxRbs1APIwmk5YfI8C49NOvRQfP+TJpP+YNMiYJvfgP77rUniAFKdffV1DJpjlMf8OE37dlOfs2tjgiqD68oxkUL9HyW2VzN4E01jIZHRqgU4I4vLfwQVUP9GuP8f20a2kfsaMDRySxTjMImTuqg0SmYTmeVRlTHN/xSYMu56RguB4qLiIghWP8Wp5fzXAkOQnQ9zqkh7haPUluyHpqwDnzdBbVxdqIDx0BnuJuZjiVIFlhpAfx03FR3LM0APiJ5cAHt3wb5MX5rhuc81UepW+INEoQyNHNTjKPMp15ioLFe1yipRJ2gid7psZFTcuZLFr2yqm46h56MLZf853NYizJMDjcZAJfrDxz9AqXWXAR0Paf+NzzeVBV7VJVPBScSGOw3w0Vlhd8JNra6yvNBskIp8v2Ng/NvHNfkRkOMfEvMeozIVMH/NehSD87KTAiiFmAjpbkTJGshYaYiAM4bMSrbXK4fTHyyur2u+GGqYfFmll9ZUyefO7eFvjtFhqPTCCAOpx+BV2mPmc21GJ5T7mX85OsyrtqR4EwQvF8eKU90B9nHfBd6TxJy3vMJgyrmm41XefwtS0Ru9z29l77l2QXfDqqP3hDoKYIFfmrUKTgN/IciPVa1x3FtYMCWebPrGRvYYm0bBGtmlHRxVQdrxF/70Y= 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(83380400001)(44832011)(4744005)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZP7Mx7e9/+1mig0T1gYlMuLmIj/K85kvZOWGa78QYuz2yFnBOnlZ+80LN78ggjlak7mEWvlcG6jsNNbbciEjYk/1NUduwm/plJUEgK9r+plY2PrYAweoTDeCKXPPwSWXEzrvmO8YPoDlkHXXle9QzkR1+CLQ52V/entSwUxJQywIC/mlVwDYBPknODl7LFpoRa6Vt50U1pY6pcwcOzA/5sHFu9RE2g5Howh5xsvAGmFtjP1E/rU5pcK/5ZfAXL8gbtd0X5OD+X3JM6N6jYCc6f4OzdYsJnzDPJnwpBS58j4QM9z9vESdrgsdtdcePFHZrvHU7sqkY8MTiJDcwREAnWsJ3aEyGimbhFyqk/1Ho5FZ953KCZNWDO7U9MXfSTm0sJZ4nHTE/yA+OgS1eE0h1HGY4yjXqqBGsRL4cbkvZCoO/do8ItXsT0/At6UmqZv3G9C9TjsPG3BQx4akizAYtvJ9oCcixlg4LDhzdJ3ACh191j4FiTHCHg5lqBCSrxkeily0WQyfZfx01dJpVtxCo7wRuQ7ZaWGSfyeACCgkJVdBGp3NyRKpVjDB3zqZqf6lRGgQC7WHxefHEFWqq7bDp8v0Sny8FJmHBKHO1xt5kQeGol1kZk4isYYmvYvP8i4P+gLSqz8GH7qQ3ltj6jaKiltChafRuSAyu6wdG9b9ZA2quuwtI//B6d3AWLFmCw0IZJ0EY8wa+h2qL4fCFlCFiquzbPwi+zwjBBzxB712UczmPUuXOn7osvsBgavt4FU0TSCUMQqjreRCS+KjsIatSChpG6zwFDm/QFSvlxvD9wELe5AfKyRRVZTdMvGKGFWIOFHQMc8CeEeLmnvQ9sN6P1z1zDN/htpvJkP6LraNS51Xc1kvgwn8DyxkhmxDDG1JPOCEzYualH00Hn2j51vxzqLLB6s7gANRbL5hv5iac3prbU9kNDuQGyp15TNLFT28w4pMiHUA16Q/OND0AYolPJPGKXGWw0qPT9MP//xav6R2FYL1KRfqyISLSGdbh7sSrKEzDAOL2uWRrF+czpCmORq0BxvDePW7BwMN0Sq6YUnGBGNe7fDrmsQmO6dwlC8T3tLNDS+uhxBI8v+EfD9pu6raNqSOqxBDnqyBtNfaiSIqGTC2aF3x4vAecTR2pKeogG86/VRHZ6uESl82oeeYKXR46jA1mV3glp4s+P7l5IrBrHd0NP27BHr8RAa8bYEi4ViGKUsaIkwSWJGcTl7oKTcmdQpx31SfiyvosMGMfoR+3w4aRqW8A5G9g7B6A9vemZADQcZ9AyUxC4ZfcZvG0UEyVHBtyUjNh3ep8MKmD5haJq7bx9YU4ijB4+uRoKih X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd334d1e-b834-4780-a3ff-08d95e24133c X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:08.5619 (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: 35V4+9lyfgFCXmZcLDw5FEYU82/srf5qdcaPailVw++3HaqT2Q+uHWvF1P9Qf4bEQ9aGRvDzk3bOU/+lE5zvAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: 626AEF0011FB Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b="Ir4hxU/Z"; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.87 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: c1zoigc5jnscqiyr8tki7xs73tdfz7pa X-HE-Tag: 1628836330-393051 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: Add MEMORY_DEVICE_GENERIC case to free_zone_device_page callback. Device generic type memory case is now able to free its pages properly. Signed-off-by: Alex Sierra --- mm/memremap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 5aa8163fd948..5773e15b6ac9 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -459,7 +459,7 @@ struct dev_pagemap *get_dev_pagemap(unsigned long pfn, EXPORT_SYMBOL_GPL(get_dev_pagemap); #ifdef CONFIG_DEV_PAGEMAP_OPS -static void free_device_private_page(struct page *page) +static void free_device_page(struct page *page) { __ClearPageWaiters(page); @@ -498,7 +498,8 @@ void free_zone_device_page(struct page *page) wake_up_var(&page->_refcount); return; case MEMORY_DEVICE_PRIVATE: - free_device_private_page(page); + case MEMORY_DEVICE_GENERIC: + free_device_page(page); return; default: return; From patchwork Fri Aug 13 06:31:46 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: 12434779 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 C416DC4320A for ; Fri, 13 Aug 2021 06:32:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 75F7D610CD for ; Fri, 13 Aug 2021 06:32:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 75F7D610CD 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 10A718D000A; Fri, 13 Aug 2021 02:32:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F39308D0009; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D621E8D000A; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id B2D6E8D0009 for ; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5A95E8249980 for ; Fri, 13 Aug 2021 06:32:11 +0000 (UTC) X-FDA: 78469087662.36.62EB437 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by imf17.hostedemail.com (Postfix) with ESMTP id DCDF7F0011FB for ; Fri, 13 Aug 2021 06:32:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k/yqxzjGKKMtxC6SKZJxq7t5GnBNBnypbmW9UlA0uiyoQ9F3/KyCg6ZfawM7Jm3Ohhvhz213WjvJ4OnxCzwhChrkuyftW1U7WFE1ZitTxX5KE1vKRc7y+fbnAENZ9YarUT1YzgkXreembg6hhBRKFojudCYKrU2Ra5AQ7GSWNkeoAUagE6wHl4JFJ+vWIH/aW5gtAy34sG+M9JMiNanHNNpmxyDbhHYyAzeGY2FuZBSIZ/Hehsgr25gDEr56SLw59+uNtvxjdjaPCzrd77vOi1YuIBh0ypRnp6+SSRwSl7ysoN/Hi3RjyaM16H37oZ9L+VDKHqGNhlyaxRLlzaRFQQ== 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-SenderADCheck; bh=/JYNbIZyT4GsemXLmS0c1O12FNYR+CKGj4BBJeppL5Q=; b=h7FF5dyhPABr32hykHSR3soaAyT+4YBOnOTOaV/PPA1SyYSsrsUEyYMmHDKgwWJRsGGUSwBGQluapKrrdz2XqCTVTIfHAYa0Gp4mQtG7Gdf4F+6WdqqwjcYFELsaRJMsJYaeAhlpAvW29fNP5v4NK/0AxLPv5HpiXdbsrqxIlWilpAFtxR5Qtfb2xjALZa1KyDurRuUUPbyJFZwUYn7xSRXfHC5D1XF93ebNFWp7j9W9+Cg0LUgI9bMA/iB2TFZvW2VlDp7ozTYaaNKDEcwBi0P/aUdrGFH7M3NX046XHFQeqGFqBuXPm2pjZGrrPi/Wph2QzAXoLV9BBFeYW/o1SA== 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=/JYNbIZyT4GsemXLmS0c1O12FNYR+CKGj4BBJeppL5Q=; b=B4VhvBwjKZNqq8rqOAKc33YE9AAKN2hXPrVMmZeY4llqBnCHOTbvYkVl6gcdZXg8gmY7/Bfl6DDbnI440+HLdumD4VAA4vakOXgU1tfEsxca8cZVfThnWUvUPZFLKr+q7gelFbtVNXpCdz8ZEC5YsWXPEYhguwaI4uFuvfSmDmo= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:09 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:09 +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 v6 09/13] lib: test_hmm add ioctl to get zone device type Date: Fri, 13 Aug 2021 01:31:46 -0500 Message-Id: <20210813063150.2938-10-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7950325f-1441-498b-87ac-08d95e2413a6 X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xHMFYiIYJ4XMADOEx3g/HpJ3N/Ac43Ib9Y3pK62P3bynBpqOEyZ3oAmHj9ymRleAeVFghC1VVX+KcKVwI11T3Lb2Jdks9PyB7RCHrjGg6CO4/uApJddKmU6bP7Iy6iTZecqP0FGk3RfzzwtR2clOMgLD+W29Bw9OgA0V5Lnfdnr7Ahp9be3eeouovSUxmAZDxA4JJvCH7XA3/q34DYUTmw2wP/J+fWcET5mwSQhA4xXGsRHs3afiKj+k0ayGoTN3QhgGL6cSAbDpHc5whE3o7wRl+r/v5+q2UbqSEp2ZwCeBh2v0c4nrLoAoiyAoLTWE5WPZFTz96Ld7qh63PkhA1b+f9+uRKkLrixjZY20EL4le9WunRvHtE5vUlq8Yq87rKVJ8tZkSKefP8JWUP8PgKHVoNKfQS+zDHNyCyBZivlgmYEx3kfvcUxuNNaxC/hsr79i8FV6r+l/8avJcxa4+3eII8zAL0Qy8vMe7wGr4OguaMsYFGRk4OMdjuzQSbyApyk01TOlNMvUBYUXVPK4GgAhZhRLnIkacwruwUgV2rTHaey8dcMoxKibCtXAskAUAuMebWPlcObFS0ZW7spIsQZ5bpa3PCiu8SOAikpkVaiDGwcf8+imH87zq9alGnP1HMVyPXSjG2CR7lWThKzZkda1siy98KSngyDfOUoI+Zn01+EAtdmmyLGiaW+tHn123 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(83380400001)(44832011)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YaTcSpaGInWmNGP99O6ENAsCr3IlaSsP1TRYCk5Yunq1zzCyhP49AolG7f8ozaELPhR4RSABnjH4NKGrwIoXitfqW7b/DjCh5v7BrficsLjC8oSOVD/yBgD/QIE/IdSXrdQPDx1yOAXJ9yYg2IhE2AnLPGYgu9VRHpIkdlks4a10KRvGlMqJlTR6ZKHPo2oF1EsFq79a3GXnTPKks96Qs/rhSJhaXLeg8eVZflmmUpxdkZZuzvxYOCA135/vO3qu7NQpwPhb+md1Z2Nzr4GPJy+oaxd62Zk1dTFSLDeqnjdnCwHPvdmGNUQn2fi1gGMg+IDtAKGootesr6A1nCxcYif0If/o6AZlWLZz6TWDzmw1PIuRqCj0W44RyEhYLTt0SoroBArV5u1Q9lXdQQj+/eJJ7wru9TfpXvn7s3l2pppp8ZR+F2Ox9d0iyWRD7Sf8DHGT0Ripy2byrkbDKn5FbqlO30Jigd2Xyguj0HtJE3nRfGYwftk+CEv6IAV7vIttdN9QDv/eYxfE5+nvt7kQmQ7Xi9/B3HMkNEqcXvKiPHe8TX82xVe55XcBWRRHtEO5CE1OrpRXQuRT+tU6fxodiXGU5wzyVTzNbF5xYlM8CVhewQZwg8Is2Nvk4CFf0d+NUwcitMnMdBjrp/mNKU0EcB/2kz1O5rHek25bDUli5gY5wF5JlSTJ+bIcyb312oXW826R4+J8LyvllItOqUYObIkai8UrKaarEPmw3TIHMhPq2OJa9E4ZSFGDuL5LAqFxWzLmnxEH0GUBgZ3orjnOBQwWbc4g8KJRGMkp7R3GccL7J6lux4lcwRo5n8BzZR/bbOnbN85EIekRVTK27kSnXfwsvjVewm1ONyvb1yz8WPLjd/2V9gh/USgggRNFhT678GkAzF1czjz0+uDLvACCOV3J50HmmdZpP0RnHtmqVKywxZoSGnE6joIVYHUYaYgRZHfHT9JKN2NfBQCkDjbrbC6sMNYJ/FbER2MtOaK7X4aZr4oBWsO0INk1X6gjURLT/VHCX0v0dh36D0+QBzMdr9w0S3uA6ga/0ygvLz3Sg6iMopyOGZI5jTubBCziBTI50cNVbN2kzlbAQOyecgWgS0tCLjKkRiVpNdigdMubIV34n/aalD/oc9aue4iO4LDbLPcSCK/EwRIy8DzrVVL8Tqtgf5+TnkTeON4PWsO+zus7sYQH0jpqGVXCVIpuLbxo6SMM89Eeknq5A4AQb7xPbpLGCkCn7qKFDxk0xw+nzw1hTnIwNp6e5c/8hhE+7C0B1nzlaJbAB+OZVu+jx3iLXvpyDYToiTo8v4Axr+Xu0JCjDgEQ6qDM+np5r+B/NP6I X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7950325f-1441-498b-87ac-08d95e2413a6 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:09.2305 (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: Se+77Pgv4nwaXO0ni4QWQwVe551eqtFH/83Ant/uFuckdZmZyRoikpIEmpTtyJLNMwD+ivzPDxwItB3uEhtrIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: DCDF7F0011FB Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=B4VhvBwj; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.87 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: mtdfwsep7d5gb3in1hz3347496yp5qtm X-HE-Tag: 1628836330-223268 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: new ioctl cmd added to query zone device type. This will be used once the test_hmm adds zone device generic type. Signed-off-by: Alex Sierra --- lib/test_hmm.c | 15 ++++++++++++++- lib/test_hmm_uapi.h | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 6998f10350ea..3cd91ca31dd7 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -82,6 +82,7 @@ struct dmirror_chunk { struct dmirror_device { struct cdev cdevice; struct hmm_devmem *devmem; + unsigned int zone_device_type; unsigned int devmem_capacity; unsigned int devmem_count; @@ -468,6 +469,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, if (IS_ERR(res)) goto err_devmem; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; devmem->pagemap.range.start = res->start; devmem->pagemap.range.end = res->end; @@ -912,6 +914,15 @@ static int dmirror_snapshot(struct dmirror *dmirror, return ret; } +static int dmirror_get_device_type(struct dmirror *dmirror, + struct hmm_dmirror_cmd *cmd) +{ + mutex_lock(&dmirror->mutex); + cmd->zone_device_type = dmirror->mdevice->zone_device_type; + mutex_unlock(&dmirror->mutex); + + return 0; +} static long dmirror_fops_unlocked_ioctl(struct file *filp, unsigned int command, unsigned long arg) @@ -952,7 +963,9 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp, case HMM_DMIRROR_SNAPSHOT: ret = dmirror_snapshot(dmirror, &cmd); break; - + case HMM_DMIRROR_GET_MEM_DEV_TYPE: + ret = dmirror_get_device_type(dmirror, &cmd); + break; default: return -EINVAL; } diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index 670b4ef2a5b6..ee88701793d5 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -26,6 +26,7 @@ struct hmm_dmirror_cmd { __u64 npages; __u64 cpages; __u64 faults; + __u64 zone_device_type; }; /* Expose the address space of the calling process through hmm device file */ @@ -33,6 +34,7 @@ struct hmm_dmirror_cmd { #define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd) #define HMM_DMIRROR_MIGRATE _IOWR('H', 0x02, struct hmm_dmirror_cmd) #define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_GET_MEM_DEV_TYPE _IOWR('H', 0x04, struct hmm_dmirror_cmd) /* * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT. @@ -60,4 +62,9 @@ enum { HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30, }; +enum { + /* 0 is reserved to catch uninitialized type fields */ + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1, +}; + #endif /* _LIB_TEST_HMM_UAPI_H */ From patchwork Fri Aug 13 06:31:47 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: 12434781 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 77EC3C432BE for ; Fri, 13 Aug 2021 06:32:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A5F3610CC for ; Fri, 13 Aug 2021 06:32:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2A5F3610CC 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 A31358D000B; Fri, 13 Aug 2021 02:32:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B85B8D0009; Fri, 13 Aug 2021 02:32:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76F2A8D000B; Fri, 13 Aug 2021 02:32:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 4FC098D0009 for ; Fri, 13 Aug 2021 02:32:12 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EE8148249980 for ; Fri, 13 Aug 2021 06:32:11 +0000 (UTC) X-FDA: 78469087662.30.94A35D2 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by imf17.hostedemail.com (Postfix) with ESMTP id 797BEF0011FB for ; Fri, 13 Aug 2021 06:32:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kdq/7hh996NUYmjU+DIwV9AwdY8A0QX1rAX7P7QSdlJDs2HOFaNXYeWMEqylLduG9HtDXrpyxL54jmI91oLF7potepRViFqPuix/2haaDW+6k4DmvUnHxvTFDdkEp2wWAxmZfm7S0A/cFHevy0mFnvpjkkd8LXXzuvf/mp2cjvBjyVYxbg5OpP97ugRe/EKzcYrfz5VACzV2+zpaOWPs177B2pakxc/NhY55XPLfRQ59rsw+pDV4XAZCkbMFUHk7aIwSNSKlvIlR4k+68we2HiOPNZARDAVGTjnf+F4dEP9npejmPrUapkW/QB6kJQqrkmxSdLL6IA4wcNmDFk1KHA== 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-SenderADCheck; bh=JsBEIybxLlWQ1DvvPR9uO9H1ffiY515x5QP2dx6aNZI=; b=IkmUV+jFm6EvaOZUXH594FrlKrOtc5iejyBc87H335kPRVtSwtUIwoVD4c6typOaKF67i4GP3ildiYkWHmdC8iMwSPGC4vqkYZ7LXclDpueD7T6zm4tOpXAT9whPp8CNCmZ/JlV4lBN6/IRHKgf1RzNVJK2x7An4IR4CuSNUVUz/Kve1iS7FipUpLohJyICV7PPJmH6U898ldkTMqNQ9RGhv8+GxjxjWPW0LgJjP2K5+L6xLMC8UcRZlOPVrBAA0aajlXJVN1KXBkNEssICPDMUemdF4sTL7KnMk9oGjXiNOSdjQ5EUDnvNRdFBk7ZbhqWkXyR/12pQMxCEeJuBrCQ== 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=JsBEIybxLlWQ1DvvPR9uO9H1ffiY515x5QP2dx6aNZI=; b=Aff3Km2+yPEv8lQyBgURpfX0gY84b6jq7Dv4VTZRCOMvXs1brNNfVebm2b4rr911EHj81YxF9BbTCa7GhEWMVziJ77pUhv5o7cFbNXwCtpNLxgVFH+xoBiX2DoPomM4avQkFgNjimh2sRa6S0XeLklcZlkLz5r6t/wMJaW6X5+M= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:10 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:10 +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 v6 10/13] lib: test_hmm add module param for zone device type Date: Fri, 13 Aug 2021 01:31:47 -0500 Message-Id: <20210813063150.2938-11-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d37b7bb-2d1d-43bf-74f2-08d95e24140d X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZAGYzmakKvvJk2m3v8GkmMj9aifzCiTHgLxu+/w1olG6eI5wK2+O5N+49sNwuH5mG3vGxg4/r9dQdqoKKlQxzsDNxdQIomEfhVblFsrgX1VZhCtSpp3pZInZMAY6o5X+QMrIo2rrz7gLGv6Mchc+M8Fgr/R0du7eB41HvqfFX1M5rouxPFwHDsFgwzQmaZGgIfEcl8dfSFd40ZpUN/uonf+kdw4xtPYVOFSDoOyk+lF9o/sCSxXsVueyy9deN9oOnHPJWIUeV7I7fiCXI378FIkly3EGIUsb6pSb0sMkNgfl1S1U481XFV9jFEwHnMKHYJRlGKgsRfW03AdPUIoEw6AOme1p6G0QLCu/2bK878k5hgB/VJww6xVb2PWC7APbNhm3a8c4T4tXXOoRb4YqJ8txNSG5kSygCaLC85TKreVU9LBeAQAIag37CJ5JP9GrShRD7+1kreBpjb4RTb5164vcrU0vcaQWr7uMqTKf0ql8Kpvudqnf6hZD+3D+v+TrMu9BwCxcsHydteGQDVhDYS6WuivpOP/emD6dl+kSwYVa7DIfR3Ve8zVnoRRh5HIrp6oLcP722MCgaPlpEPWYFKWASmFJ5FZJfZCO1S9cZHHK+P69Z0k/nq1jG4xyRCttWtwJjgLegpPHD68JHs1utvMQZ47LpPBtxzGb2Y16yexRk/hlPr/QAFfekPboWB798sy6g/NI09IF4lkg4AosKQ== 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(83380400001)(44832011)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wnDOf6PA8Kd4Y6Nx/ouIhCZkKUjds6ONup73Mw2PI1TpIrYUZ4K0XKL9FdQqPI71gRCMH2EUHtRcmR11tOJltTHyOCSDYjFooo8k80cZTwbPBzEBweFaMp4RtdEXHqlekjsAunLk+k2akiRq/Hfgn7a+4VY2fuTpL2BZ92tT86Dxo+fBUiTmFetoW02f6X5FrGT1N8+Pg0/zKE5RHxWGYdiQNzcUWo4AwoOBKSuKQquxOs30O4eBnyW7wwbiHWb8LwOpasoMmpE78w1DZksRAXyqddi/EMHTKFEz2qYTLUFkwRjZszQ16eCGOkh5q7nS3Xg7eZKRGRJOoJ5Ie5deY3ZGev1xdW+9+uA8105ULNwUW59Fs5a3QMeBhdYwKX9/G90sgnJcNGPYJGos5NFEtcYA+LY48LnsD1Vx4zgohdMOoS7Dm7OA++IFcjMbviLNg68ThXKSB7cyJrUira14NqTRG4x8iqjeSTNj+l4EMtS9TuthEalf5VsLdReCqMZRrGbLrwDqfrkY8c8QU4l22DAzry9A2cAcayezOdcyMiefIQgKkdT7OhO7SW+CfG6HDrR5mByKNVPyPgu+udBYyedzGBnpN8ctRXoIZZjYLHD9+8l6AXpcP8udU9x+z94IXVSCbTZXvTkbJ5qyoSFIMvoEOQQoTqjUkIVZvHMnQJQRUat/37Cg6kEemPwuZ4jn+oc45eReEQ9FN9r21WndRcvdSJmczD8WYCmuMhL7zqX3vdaOhNVQC0FcvPqTuTabAiG4BHDK3vxjv/MSdwwP70hEFK7npLB+jUddYQHFdvg4Me96YiulhHzJsEOL9llZz4jnxfjct2+SibpISQxJH8Hpwm1lM1ghY+GtffkFyvhn0P9W7I9jKy+whamWHqwE5ebcoQ0Q961LSxl3zcu9azBpvzTXCKBzQyjwfpelC4uJcEmnH484x1p95urtQhkghDSzqHh9UM6x07uPKUCa7Omxuzn1AIQLTi9Uq76214EYSEPRttK/1izvNSAibkF/G+DzyMwHPwGuKGMhErdHXpVgUYgV9XHxeHB3dWZcr9nf5W3zYGKFJ/F1i3Zm4PxKAyaGDsD1O4UajQMNltmgdMsmk6hKezob+X0CK/L19LP4tfOI3NQAUjkUhRQfKf6ogwJyvifmm4IocWBd/EZQiX1MFI/BsZ3JFtsvioh2/Pi7ZyR6BankQlOHHd47DuzYAq5rlyyaUQyxprGktoW/i4Lp7teXPl8rzYB68IVcNKHQSK9YBD6KOXzfDdxVPJlu1uQRcH6SuBNSpHorJ5zP9jpPSaphXgxOa42DpjJwIcDCyzsmzzT6Um27rgORkP6x X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d37b7bb-2d1d-43bf-74f2-08d95e24140d X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:09.9339 (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: 3g/BXQhqIqEXqZSBmnSZVI8/WZv3RNJp8djrJB+Ml7/ZGsLI+/GsLz8843NDjFL88G3+CI/g73+5EP/oAYyXEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: 797BEF0011FB Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Aff3Km2+; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.87 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: rdhosdao76ritr8fc8wgft5ec7jtunko X-HE-Tag: 1628836331-449735 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: In order to configure device generic in test_hmm, two module parameters should be passed, which correspon to the SP start address of each device (2) spm_addr_dev0 & spm_addr_dev1. If no parameters are passed, private device type is configured. v5: Remove devmem->pagemap.type = MEMORY_DEVICE_PRIVATE at dmirror_allocate_chunk that was forcing to configure pagemap.type to MEMORY_DEVICE_PRIVATE v6: Check for null pointers for resource and memremap references at dmirror_allocate_chunk Signed-off-by: Alex Sierra --- lib/test_hmm.c | 56 ++++++++++++++++++++++++++++++++------------- lib/test_hmm_uapi.h | 1 + 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 3cd91ca31dd7..b4f885c6c6ae 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -33,6 +33,16 @@ #define DEVMEM_CHUNK_SIZE (256 * 1024 * 1024U) #define DEVMEM_CHUNKS_RESERVE 16 +static unsigned long spm_addr_dev0; +module_param(spm_addr_dev0, long, 0644); +MODULE_PARM_DESC(spm_addr_dev0, + "Specify start address for SPM (special purpose memory) used for device 0. By setting this Generic device type will be used. Make sure spm_addr_dev1 is set too"); + +static unsigned long spm_addr_dev1; +module_param(spm_addr_dev1, long, 0644); +MODULE_PARM_DESC(spm_addr_dev1, + "Specify start address for SPM (special purpose memory) used for device 1. By setting this Generic device type will be used. Make sure spm_addr_dev0 is set too"); + static const struct dev_pagemap_ops dmirror_devmem_ops; static const struct mmu_interval_notifier_ops dmirror_min_ops; static dev_t dmirror_dev; @@ -450,11 +460,11 @@ static int dmirror_write(struct dmirror *dmirror, struct hmm_dmirror_cmd *cmd) return ret; } -static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, +static int dmirror_allocate_chunk(struct dmirror_device *mdevice, struct page **ppage) { struct dmirror_chunk *devmem; - struct resource *res; + struct resource *res = NULL; unsigned long pfn; unsigned long pfn_first; unsigned long pfn_last; @@ -462,15 +472,26 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, devmem = kzalloc(sizeof(*devmem), GFP_KERNEL); if (!devmem) - return false; + return -ENOMEM; + + if (!spm_addr_dev0 && !spm_addr_dev1) { + res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE, + "hmm_dmirror"); + devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; + } else if (spm_addr_dev0 && spm_addr_dev1) { + res = lookup_resource(&iomem_resource, MINOR(mdevice->cdevice.dev) ? + spm_addr_dev0 : + spm_addr_dev1); + devmem->pagemap.type = MEMORY_DEVICE_GENERIC; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_GENERIC; + } else { + pr_err("Both spm_addr_dev parameters should be set\n"); + } - res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE, - "hmm_dmirror"); - if (IS_ERR(res)) + if (IS_ERR_OR_NULL(res)) goto err_devmem; - mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; - devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; devmem->pagemap.range.start = res->start; devmem->pagemap.range.end = res->end; devmem->pagemap.nr_range = 1; @@ -493,10 +514,14 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, mdevice->devmem_capacity = new_capacity; mdevice->devmem_chunks = new_chunks; } - ptr = memremap_pages(&devmem->pagemap, numa_node_id()); - if (IS_ERR(ptr)) + if (IS_ERR_OR_NULL(ptr)) { + if (ptr) + ret = PTR_ERR(ptr); + else + ret = -EFAULT; goto err_release; + } devmem->mdevice = mdevice; pfn_first = devmem->pagemap.range.start >> PAGE_SHIFT; @@ -1097,10 +1122,8 @@ static int dmirror_device_init(struct dmirror_device *mdevice, int id) if (ret) return ret; - /* Build a list of free ZONE_DEVICE private struct pages */ - dmirror_allocate_chunk(mdevice, NULL); - - return 0; + /* Build a list of free ZONE_DEVICE struct pages */ + return dmirror_allocate_chunk(mdevice, NULL); } static void dmirror_device_remove(struct dmirror_device *mdevice) @@ -1113,8 +1136,9 @@ static void dmirror_device_remove(struct dmirror_device *mdevice) mdevice->devmem_chunks[i]; memunmap_pages(&devmem->pagemap); - release_mem_region(devmem->pagemap.range.start, - range_len(&devmem->pagemap.range)); + if (devmem->pagemap.type == MEMORY_DEVICE_PRIVATE) + release_mem_region(devmem->pagemap.range.start, + range_len(&devmem->pagemap.range)); kfree(devmem); } kfree(mdevice->devmem_chunks); diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index ee88701793d5..17a6b5059871 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -65,6 +65,7 @@ enum { enum { /* 0 is reserved to catch uninitialized type fields */ HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1, + HMM_DMIRROR_MEMORY_DEVICE_GENERIC, }; #endif /* _LIB_TEST_HMM_UAPI_H */ From patchwork Fri Aug 13 06:31:48 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: 12434783 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 25FD9C00144 for ; Fri, 13 Aug 2021 06:32:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B41F2610CC for ; Fri, 13 Aug 2021 06:32:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B41F2610CC 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 500A08D000C; Fri, 13 Aug 2021 02:32:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 461FC8D0009; Fri, 13 Aug 2021 02:32:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F1508D000C; Fri, 13 Aug 2021 02:32:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id EF97D8D0009 for ; Fri, 13 Aug 2021 02:32:12 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7E4361A4D5 for ; Fri, 13 Aug 2021 06:32:12 +0000 (UTC) X-FDA: 78469087704.38.0E0FB90 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by imf17.hostedemail.com (Postfix) with ESMTP id 13416F0011FB for ; Fri, 13 Aug 2021 06:32:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMB3pGSaq2RPLrtuengTPN2enuKVs6VJKOR8NrRXoTYiS31Ir/iyo8JG5zAiOL+1JLT7pZtS4jfeMPT5ocwQ6btIsa78n0QK0548SnyM5nPWvHm9uv/yDX0oYZspZmc/KwGnZ7WpT0+NFam/pjwQHEdUzzKugcqXzAmzRdeyG6dQ7PbOTX4RhqAy/qrrEzmy0KOO/qFYv1G4mmdG+vBukA8jt4DXR6/UfatlddpeVc+pOCJPKy9GvM7/LaMkfYmxNTKETIRL7mUioUZlO9xJUTNm1zQ5p+Ib9xuyrGBUniv0VQQbPlTxGgoa5Q1jT1mGRPa7ee3oVSulyq7mdqH6Tg== 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-SenderADCheck; bh=aTsY0Edyc287C+46pU0ijUSzFlT32FMEIxEGIF8WG4o=; b=fM5dQAHzXQ0LQmSQ1LCh3xmTXLnWMGCUzg9pz5UAvHFEpzH+FshBJG59bIYVt7YVfSbqW4h4zORspS6cVeVilo3+6eOU2ZcbOww+gBRSxgECy3zZa10Zb5Jek/7+fNRGvB+QI4YmyWbDmfKZ3haYaJ+8+9jLw8itRYfyb6WErgD839ZJNI9vFSUAuGnIVxf7tyQNYrTN8vQNtx4BgtsYv1fGWDUc1+x6lHBtjIH8CGLJiNL6ekePJ3fXUyhimREbE1cQHLYRSvY1gd6BI86sODveYX4uif23irZDACNQ/AR7xiHuwXKe0ksEM5wdfv2wuoPcaEF09A5cumppCDeCHw== 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=aTsY0Edyc287C+46pU0ijUSzFlT32FMEIxEGIF8WG4o=; b=f5plEv5Q25WWdFwhBgUi+O6m4AcWrGCFg3iXETDzoaaSgdkskMQScQuvQEEdUbz3gHS1ljte07y+5UlmuwSb8gDFVHjMCQ6mywe3jGNKRtACDPAUm+ZmmjRXsmA6htMC5kCMyklX3/BaRZnx5uhm476ZQrh1922+PgLjrc4qgEY= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:10 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:10 +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 v6 11/13] lib: add support for device generic type in test_hmm Date: Fri, 13 Aug 2021 01:31:48 -0500 Message-Id: <20210813063150.2938-12-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 08269e7c-1ef2-4b71-eec5-08d95e241491 X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I1cr1lCoyiRVeJyC/FB5vuVxJh1NJ//D8YVn5oyUcy4/ysGVZRSqhiI/v+itwbvAKTCtip5y3hBRr1UMKXTD17LU0lMA5OJxGOlyyay7NssVzk0/U3G9XX5Ubrw91cW4zy0n5DBEcvQyxFzD5bwUjgw1UXSuPuQiWp4WFFjd/5IuDZonL/YX7JM+8OBZ1hQHqBjb9DtFaoUcxcVS55no/X1/1CJmfKaBCMuTXGgIhD+rwdYmavhzcggBy7Ho+Vu7RnuoZ6zmhgSYZvnxy8gwB5hluUoRKG7pB74unEMq1c674Fr5NDbPxtxGJ3Pj+i4wuFCJi5CNrT5f/GDDa9ecN1gYpsQ6b6Cx5uzfvyMqtIOIl0yGNgI/oL1eZq6Nx728/2em4WH2xaSFH/D8OppXL7PtODomLzZG8iFx2NLvMcwggLgY14DMkNw3YOmQaWnktxkIeoW1Ms2Z3hGpvXRNzapgxPHN3rzB7ZkmIA+yZbYH5mt+rhs8/k4VlE+ZurKfH3CQLCnwp2XapD9mBSBz3uh/O4Z3LMG60Hah/S/P9a8Ac9HHz9tjE6q1hjubJh7ZyDSCDBARROeDaIIjOKXs49j/MSos6LUWt/tNbcXH1+QYYqDcGAd3e/orE90ze+3lPGLKFl/CqcTFjp1Qj/JPoajmfTkUYCORcVA5WLGnOXmBzTQdnjtxC5BxucWXhmWge4nLvyXe+iFefHBoRGJffdx1ZL6/EdoTQOjfVQPyidU= 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(83380400001)(30864003)(44832011)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j4d6xXKqrmMKnOViNazJZCVLkw1LM3rNpTEyaegSPbhbhTkXis50vRVZ6L3vWFr1jGn0a2oQlwDA7T0ExU5qdz9FVnE5a9+cCQM41q01+MUQy39Tm4JQQzV4ZlIo5kq3iJlwPfOyS1x7owQBUKwfkPaWvL3YGXZvUA9HaYG6rPg9B3r4dB6JcWmjrKIAVQftkHSQKDSX573udh7kx+8ObBfvWTg/HyjMCwU8DXUIjrwoR6MbZDSpR68vxiynwMhnPv5+8q6kB3WsvQbk+g6Uh1XCI6NLBMSbH9+uDqOLwraBmfxav8wMmfvvPRdW36ECMXPbdeHW6mcN0O7VcvAS5Z3RRvADqzke+R2Sf2K23zRGZ1GQb/fEsAmqTzaBYLTEedmjZAPTxmzJ0vXceWmf2NeT+pYjLqOe9OZIjTP5mS5TTLxivJORzEjo43pt5HTbdtQi0LtNpZ1A9lxK4ueUu5weVU1/cmwPAsv9xmjiVX9OOoYgjYJ5POXzzNCRywOLWek0cBkF4Eyix6dRa9fAWCfgiX2o1lv+t11FLgJsxnJIaSJGiHbKaF/KCSosUQeHQDxJecYbcuw8CYmDInrc/j0PDKxP2+ClXjX04UzPjWwE4cHvAOiWYaA/tzqpZcOwEY77N466r/yUwTzO4VjuUSskO7n0PwdPFYMHXcsEmtgWDIyBzjja1cuUH9VmS6+mqS1kRevMzVo9Yf6Sq6CAliYnbi2wjg6biq5VDCIaPBeQZa8jSUfP4vsgelqSiABu6I2gkpT2AG/7/noq+ud/CMkXfIAEuo6ml028rFOwFOzfh0SD7NdenwM9HTQyl5Z/spZWS+y7dRSCgDDW6gWXjeVDGRZaMdm1CDI3tThCKjKJct61RompmC8dI4UpDjs6M+35PG7EWq2qCwD9z1/fqrgjzzOiw73IFcV+W+IX1dqg5DOl1PnXpIEnC4X2IXrEZoqFDjOEclw50t7mmLdktse7Pn5/JJx9D9fC+zkBAsgYwc3Nu8TYzUrxod2qgUbZglSzMgL4sOkbopuR/85mOsHfLL4GwvEDGmTNQ3e2vt/eKLjxUP5ov4NuV5AdmIhPQo7F8vxEaCcx+2WReK5mu5ui3MgLg5G3bBVISC39D16/fTLmvStmWP/3bIS6xLXiYwtrjP4PjDE/UI8xnImMadIAoKO1mVvq6Mb0iE8SaN+pmq8Fpk9SRLYJfTCCmHeNbJhvVhkrmLenweftAvmkh8FznI4B2Aho6rXCG9BTBVNlhtA3JPsh9/WIWTjCrlI//TestugEtuPPyhlO7TFYzwe+14mlMITGXc6PsGbKqu+6aaEVAQXSAqXUxzb0ag1S X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08269e7c-1ef2-4b71-eec5-08d95e241491 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:10.8081 (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: wpPkVlaLCecIDoBk9eSerApwcGWC0KQjRGeqt1A1yoEClXqtnVi2i81Ll/uzxhrjh28MoRf0g6N1xowHxrKG/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: 13416F0011FB Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=f5plEv5Q; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.87 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: fmbm493qcoh9qzts4uybpa6gjz44pc8t X-HE-Tag: 1628836332-466954 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: Device Generic type uses device memory that is coherently accesible by the CPU. Usually, this is shown as SP (special purpose) memory range at the BIOS-e820 memory enumeration. If no SP memory is supported in system, this could be faked by setting CONFIG_EFI_FAKE_MEMMAP. Currently, test_hmm only supports two different SP ranges of at least 256MB size. This could be specified in the kernel parameter variable efi_fake_mem. Ex. Two SP ranges of 1GB starting at 0x100000000 & 0x140000000 physical address. efi_fake_mem=1G@0x100000000:0x40000,1G@0x140000000:0x40000 Signed-off-by: Alex Sierra --- lib/test_hmm.c | 166 +++++++++++++++++++++++++++----------------- lib/test_hmm_uapi.h | 10 ++- 2 files changed, 113 insertions(+), 63 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index b4f885c6c6ae..42edcc8eaad2 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -469,6 +469,7 @@ static int dmirror_allocate_chunk(struct dmirror_device *mdevice, unsigned long pfn_first; unsigned long pfn_last; void *ptr; + int ret = -ENOMEM; devmem = kzalloc(sizeof(*devmem), GFP_KERNEL); if (!devmem) @@ -550,7 +551,7 @@ static int dmirror_allocate_chunk(struct dmirror_device *mdevice, } spin_unlock(&mdevice->lock); - return true; + return 0; err_release: mutex_unlock(&mdevice->devmem_lock); @@ -558,7 +559,7 @@ static int dmirror_allocate_chunk(struct dmirror_device *mdevice, err_devmem: kfree(devmem); - return false; + return ret; } static struct page *dmirror_devmem_alloc_page(struct dmirror_device *mdevice) @@ -567,8 +568,10 @@ static struct page *dmirror_devmem_alloc_page(struct dmirror_device *mdevice) struct page *rpage; /* - * This is a fake device so we alloc real system memory to store - * our device memory. + * For ZONE_DEVICE private type, this is a fake device so we alloc real + * system memory to store our device memory. + * For ZONE_DEVICE generic type we use the actual dpage to store the data + * and ignore rpage. */ rpage = alloc_page(GFP_HIGHUSER); if (!rpage) @@ -601,7 +604,7 @@ static void dmirror_migrate_alloc_and_copy(struct migrate_vma *args, struct dmirror *dmirror) { struct dmirror_device *mdevice = dmirror->mdevice; - const unsigned long *src = args->src; + unsigned long *src = args->src; unsigned long *dst = args->dst; unsigned long addr; @@ -619,12 +622,18 @@ static void dmirror_migrate_alloc_and_copy(struct migrate_vma *args, * unallocated pte_none() or read-only zero page. */ spage = migrate_pfn_to_page(*src); - + if (spage && is_zone_device_page(spage)) { + pr_debug("page already in device spage pfn: 0x%lx\n", + page_to_pfn(spage)); + *src &= ~MIGRATE_PFN_MIGRATE; + continue; + } dpage = dmirror_devmem_alloc_page(mdevice); if (!dpage) continue; - rpage = dpage->zone_device_data; + rpage = is_device_private_page(dpage) ? dpage->zone_device_data : + dpage; if (spage) copy_highpage(rpage, spage); else @@ -636,8 +645,10 @@ static void dmirror_migrate_alloc_and_copy(struct migrate_vma *args, * the simulated device memory and that page holds the pointer * to the mirror. */ + rpage = dpage->zone_device_data; rpage->zone_device_data = dmirror; - + pr_debug("migrating from sys to dev pfn src: 0x%lx pfn dst: 0x%lx\n", + page_to_pfn(spage), page_to_pfn(dpage)); *dst = migrate_pfn(page_to_pfn(dpage)) | MIGRATE_PFN_LOCKED; if ((*src & MIGRATE_PFN_WRITE) || @@ -671,10 +682,13 @@ static int dmirror_migrate_finalize_and_map(struct migrate_vma *args, continue; /* - * Store the page that holds the data so the page table - * doesn't have to deal with ZONE_DEVICE private pages. + * For ZONE_DEVICE private pages we store the page that + * holds the data so the page table doesn't have to deal it. + * For ZONE_DEVICE generic pages we store the actual page, since + * the CPU has coherent access to the page. */ - entry = dpage->zone_device_data; + entry = is_device_private_page(dpage) ? dpage->zone_device_data : + dpage; if (*dst & MIGRATE_PFN_WRITE) entry = xa_tag_pointer(entry, DPT_XA_TAG_WRITE); entry = xa_store(&dmirror->pt, pfn, entry, GFP_ATOMIC); @@ -688,6 +702,47 @@ static int dmirror_migrate_finalize_and_map(struct migrate_vma *args, return 0; } +static vm_fault_t dmirror_devmem_fault_alloc_and_copy(struct migrate_vma *args, + struct dmirror *dmirror) +{ + unsigned long *src = args->src; + unsigned long *dst = args->dst; + unsigned long start = args->start; + unsigned long end = args->end; + unsigned long addr; + + for (addr = start; addr < end; addr += PAGE_SIZE, + src++, dst++) { + struct page *dpage, *spage; + + spage = migrate_pfn_to_page(*src); + if (!spage || !(*src & MIGRATE_PFN_MIGRATE)) + continue; + if (is_device_private_page(spage)) { + spage = spage->zone_device_data; + } else { + pr_debug("page already in system or SPM spage pfn: 0x%lx\n", + page_to_pfn(spage)); + *src &= ~MIGRATE_PFN_MIGRATE; + continue; + } + dpage = alloc_page_vma(GFP_HIGHUSER_MOVABLE, args->vma, addr); + if (!dpage) + continue; + pr_debug("migrating from dev to sys pfn src: 0x%lx pfn dst: 0x%lx\n", + page_to_pfn(spage), page_to_pfn(dpage)); + + lock_page(dpage); + xa_erase(&dmirror->pt, addr >> PAGE_SHIFT); + copy_highpage(dpage, spage); + *dst = migrate_pfn(page_to_pfn(dpage)) | MIGRATE_PFN_LOCKED; + if (*src & MIGRATE_PFN_WRITE) + *dst |= MIGRATE_PFN_WRITE; + } + return 0; +} + + static int dmirror_migrate(struct dmirror *dmirror, struct hmm_dmirror_cmd *cmd) { @@ -729,33 +784,46 @@ static int dmirror_migrate(struct dmirror *dmirror, args.start = addr; args.end = next; args.pgmap_owner = dmirror->mdevice; - args.flags = MIGRATE_VMA_SELECT_SYSTEM; + args.flags = (!cmd->alloc_to_devmem && + dmirror->mdevice->zone_device_type == + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE) ? + MIGRATE_VMA_SELECT_DEVICE_PRIVATE : + MIGRATE_VMA_SELECT_SYSTEM; ret = migrate_vma_setup(&args); if (ret) goto out; - dmirror_migrate_alloc_and_copy(&args, dmirror); + if (cmd->alloc_to_devmem) { + pr_debug("Migrating from sys mem to device mem\n"); + dmirror_migrate_alloc_and_copy(&args, dmirror); + } else { + pr_debug("Migrating from device mem to sys mem\n"); + dmirror_devmem_fault_alloc_and_copy(&args, dmirror); + } migrate_vma_pages(&args); - dmirror_migrate_finalize_and_map(&args, dmirror); + if (cmd->alloc_to_devmem) + dmirror_migrate_finalize_and_map(&args, dmirror); migrate_vma_finalize(&args); } mmap_read_unlock(mm); mmput(mm); - /* Return the migrated data for verification. */ - ret = dmirror_bounce_init(&bounce, start, size); - if (ret) - return ret; - mutex_lock(&dmirror->mutex); - ret = dmirror_do_read(dmirror, start, end, &bounce); - mutex_unlock(&dmirror->mutex); - if (ret == 0) { - if (copy_to_user(u64_to_user_ptr(cmd->ptr), bounce.ptr, - bounce.size)) - ret = -EFAULT; + /* Return the migrated data for verification. only for pages in device zone */ + if (cmd->alloc_to_devmem) { + ret = dmirror_bounce_init(&bounce, start, size); + if (ret) + return ret; + mutex_lock(&dmirror->mutex); + ret = dmirror_do_read(dmirror, start, end, &bounce); + mutex_unlock(&dmirror->mutex); + if (ret == 0) { + if (copy_to_user(u64_to_user_ptr(cmd->ptr), bounce.ptr, + bounce.size)) + ret = -EFAULT; + } + cmd->cpages = bounce.cpages; + dmirror_bounce_fini(&bounce); } - cmd->cpages = bounce.cpages; - dmirror_bounce_fini(&bounce); return ret; out: @@ -779,9 +847,15 @@ static void dmirror_mkentry(struct dmirror *dmirror, struct hmm_range *range, } page = hmm_pfn_to_page(entry); - if (is_device_private_page(page)) { - /* Is the page migrated to this device or some other? */ - if (dmirror->mdevice == dmirror_page_to_device(page)) + if (is_device_page(page)) { + /* Is page ZONE_DEVICE generic? */ + if (!is_device_private_page(page)) + *perm = HMM_DMIRROR_PROT_DEV_GENERIC; + /* + * Is page ZONE_DEVICE private migrated to + * this device or some other? + */ + else if (dmirror->mdevice == dmirror_page_to_device(page)) *perm = HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL; else *perm = HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE; @@ -1028,38 +1102,6 @@ static void dmirror_devmem_free(struct page *page) spin_unlock(&mdevice->lock); } -static vm_fault_t dmirror_devmem_fault_alloc_and_copy(struct migrate_vma *args, - struct dmirror *dmirror) -{ - const unsigned long *src = args->src; - unsigned long *dst = args->dst; - unsigned long start = args->start; - unsigned long end = args->end; - unsigned long addr; - - for (addr = start; addr < end; addr += PAGE_SIZE, - src++, dst++) { - struct page *dpage, *spage; - - spage = migrate_pfn_to_page(*src); - if (!spage || !(*src & MIGRATE_PFN_MIGRATE)) - continue; - spage = spage->zone_device_data; - - dpage = alloc_page_vma(GFP_HIGHUSER_MOVABLE, args->vma, addr); - if (!dpage) - continue; - - lock_page(dpage); - xa_erase(&dmirror->pt, addr >> PAGE_SHIFT); - copy_highpage(dpage, spage); - *dst = migrate_pfn(page_to_pfn(dpage)) | MIGRATE_PFN_LOCKED; - if (*src & MIGRATE_PFN_WRITE) - *dst |= MIGRATE_PFN_WRITE; - } - return 0; -} - static vm_fault_t dmirror_devmem_fault(struct vm_fault *vmf) { struct migrate_vma args; diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index 17a6b5059871..1f2322286fba 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -17,8 +17,12 @@ * @addr: (in) user address the device will read/write * @ptr: (in) user address where device data is copied to/from * @npages: (in) number of pages to read/write + * @alloc_to_devmem: (in) desired allocation destination during migration. + * True if allocation is to device memory. + * False if allocation is to system memory. * @cpages: (out) number of pages copied * @faults: (out) number of device page faults seen + * @zone_device_type: (out) zone device memory type */ struct hmm_dmirror_cmd { __u64 addr; @@ -26,7 +30,8 @@ struct hmm_dmirror_cmd { __u64 npages; __u64 cpages; __u64 faults; - __u64 zone_device_type; + __u32 zone_device_type; + __u32 alloc_to_devmem; }; /* Expose the address space of the calling process through hmm device file */ @@ -49,6 +54,8 @@ struct hmm_dmirror_cmd { * device the ioctl() is made * HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE: Migrated device private page on some * other device + * HMM_DMIRROR_PROT_DEV_GENERIC: Migrate device generic page on the device + * the ioctl() is made */ enum { HMM_DMIRROR_PROT_ERROR = 0xFF, @@ -60,6 +67,7 @@ enum { HMM_DMIRROR_PROT_ZERO = 0x10, HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL = 0x20, HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30, + HMM_DMIRROR_PROT_DEV_GENERIC = 0x40, }; enum { From patchwork Fri Aug 13 06:31:49 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: 12434785 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 11BA2C43214 for ; Fri, 13 Aug 2021 06:32:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A571E610CC for ; Fri, 13 Aug 2021 06:32:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A571E610CC 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 01EB58D000D; Fri, 13 Aug 2021 02:32:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE89B8D0009; Fri, 13 Aug 2021 02:32:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9FF58D000D; Fri, 13 Aug 2021 02:32:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id A6F5B8D0009 for ; Fri, 13 Aug 2021 02:32:14 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 60E348249980 for ; Fri, 13 Aug 2021 06:32:14 +0000 (UTC) X-FDA: 78469087788.40.EADDA91 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2071.outbound.protection.outlook.com [40.107.220.71]) by imf03.hostedemail.com (Postfix) with ESMTP id DD3083007593 for ; Fri, 13 Aug 2021 06:32:13 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eE5Ryv4CshcTDh/2mu2RwARicpDS9iVn2BDyLzcj/vOLE9hFLOxejH/iPlow6B51h85ax0zWRQCH9K/ZzJfuN27HNSM9QDdSt34UNl5SQiyJGIHVMkg6yWzsslQPlCDlMjgsRXeH6Zjt5/B0xNJgA4WCOFcIWug9+vlTsW76Ct1PaeQH9p92NyM52K/iVlOYH40eMKE19JOxdyBrDAqswcr8N0fPN2CVxf35at486BgHsFwzLhplM2d0mWQ5yDhqWf85MCn/pQmUtTjxNsUBnWLAnkZgr5orP52fAR/Cuq6qijZZYlzgl2DhWmx+/y2E8Gbj1CBJlEITDksZDCBkuw== 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-SenderADCheck; bh=m750G1HruRY8e0UdQp9kGzjlljIQJX1uEk9lQNpHmcQ=; b=kCcC2qeQ1nDWdxXi6puRkBe3NpSTd942PvDSaKnz/KI4c+17nD6e+BCy5FBmBTxFhwxLs+E3ZJwdMZiSHqwUgNO69ivLqM+RWQnSTJRlaG6o8gwtbUIjjZLlwc79EYgMeB7k8RUVQFHytDfTqJU/yuS/NMo7xp724ELJCt/0vZssYHwf8LFCcFLx/Hr/hOnxiVVbU4V9eBlY3wD10q6oFKCTKbE+3nldgE82LQwhBqptu5cwOTo9yD39cSylqL5OlXDThe/xClNjCowz+eT6WeuYLJ1r3yUs1FtSyFMYjSqVqoOspIr3sr1VOFcdAmleh/5h5zLZEtex/I2nCzB5hQ== 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=m750G1HruRY8e0UdQp9kGzjlljIQJX1uEk9lQNpHmcQ=; b=foVTs7QmpNnxpET8ycMpM/ZY+WH7jCYMzabqh54Rg6EnNhuJ+muDKy/ZcmK8OkEZdlvyxOIKGxJ+JWBFr6MfRIxRNhBeBKohDe4p2RxvKiaLzyB52nXfpTfK3usOwH+PX51h9tafTmj8RkOTSJUO2mi23tFFo+XTnOuf2YOSXO8= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:11 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:11 +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 v6 12/13] tools: update hmm-test to support device generic type Date: Fri, 13 Aug 2021 01:31:49 -0500 Message-Id: <20210813063150.2938-13-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac1d92a4-c959-4f47-5e33-08d95e241507 X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TO05hNAd8tssUOjdOgS6ZyFCOZe44ZmMao6sHWbNYbbqX+tTX207wQskE9x9JZ+LpsiNfenQpUK3B6DQSqkHsCWTe2An6aQZHgdfTO5qF2bj+MZun94H84gHM40HkZEc/y4E5tAPJD9s41Tv1D1tYFZio8nLbC3TLfet4+uyennJ8hrxmhRQXdWJu9VJWDAQ/evm33G6JtGrl3dHdhhAyDAUWCN6W3fMDWAzXrfRtoqeTf1D/8Nmai7BnVKVAJXa/i9lMB+euY1bIJgpIzbJC2RMHq77e+9rzaK+ZEB9QrB8xl4Cyglx8Pm7Tiqgs8+L59ilyEG1AiNZ9yt5+cc1ZmmAMNwqcUPyBlkPBATI5EgTG215UTE0NN0laQuuuUQLdIY/FnS5rPfKkNLQ+9YtM6ktZ0cxCxs7MhW3bj7UvbDJhINiA4M0RzAYP4VVXV5p5vaq1DzVDatBz6W7xzlUpwvMut4+fpnuzh9SmNigD4uogLjepbXgD+MejS7d2DZsL4e3VGDv8kPsZAYDhKnwHy0B/aMuGMskaPXsOrNr4kqLs5+b+nCD+g+aL/C0xrJ/Us+usOK8NVNj8m0Zd2tGdhiIBvufIMQVjym67KKzIn8EO1lD0R4sKM1z6E7Byzpbaphy1b0K/lmJuPG8uzkAcNlUG5Ka85cmZdq61VmJhWALHS9CLXf8fIyyMro7uwl7MNMh3SQa85MLKm1/vipS3VxWHDew4qwYhcTTdI3Dfdo= 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(15650500001)(66476007)(1076003)(8936002)(5660300002)(83380400001)(44832011)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GOuBv7XINGGgrKbJ8VA9PhrTAKPYYe2lFBGWy9LmrOn4EmWolM6+Y54aXry8lQR+Gsy/+sSzF/xApLFHnb0fDzgIg0/ArKW7uXAlBHtSmnptqPByuHg48sndIRL3REhAVM3ZboxHRntXPn/yyBLHWovuyjPWobCd+qar+R35tcCZKcxaNuyMJGJFbl99pbu9UWajtABxKfDjbECk/LuLz1lMEcG8AxhORDMvayggEi+WeZFSSZGqWn8gNIl9sTpGaP4C/m6Rm0FYyxrGPiH80oGbayR+igBXJrakAiYYsOE60cyqMTXe8DU0kYqATClUIrNyhhOYWgTGa5DdSimElPvdbdpG2oHExIWh3kioSLzg6W/s8WY0eKTg8WqvL9bZAx59oBEiqa6m1POgEnePZUwJQ67rhx5T8KogxNdArcq8H1FmbmKGBDxFlWRCav2u0j2dWmg29XQevs/TR7ffQl3hlz5Kvz+sdPqTrk7TWBFdOC89txSsG+npYJUwOVwKLtDvSNR3PI73Zkce1GlOMNuoWFEA8A3jzPK5NlbamKhw0PGRrgvNpQkGUVrkWg07A70f3P/SfCeKUn5vBbHFk/DZ+bOhXP5EpTemnKhfZ+/1BtRm4YVTCP4Sg1ji3jA1wccj8UeHP+7EHI5h8NLnYo7jKCROg3YEDvWipVu0tkM8c+0Wz+6AQxpcg6Z38vixAlTMY8pbMIPFKQzVL49eKdnHfxV5Jp3Ti9XEPck1LUm2XA0nxdOXIfOYhd679qTTJsGWzZBfoaU8LpgrIkXCzs4sCSJifVb/95BJT/VJFx7dcVwbw/MVAyqe10ckYheQn+6ZmmVnrG33V+pAv5H+4aUDYX00O/cxNfo9Ks5s5Zh59+bSbbRTpY3hCWUyJblUnSLnLWl5RnU3F5tkxaATek5g6LHeurGN4NdC06bDF/zN3aq5WUWBSzU3hryQqhu6kvIcEoNIJLp1TNGghvX+OTmCpE7MvMgMin/+QiHmV5OMApp/GislkNl6Nm6pnTkkZsUZv9orPwpHYnePM9TNXULSLCrvyyqeH3fcx2B3rw/eDIGrRbN7pOUWC3p6bUhJFSVcwCzpA8HvvFRzd0rI0eTTzoRPqdbJZ+qYFyoOwgUIf2XTyL7mtxdEJ7dIuEX8dCYxtwtmylhScaFMPUaTjigblFHHmTb+GPl282f40+F/9pUMD9puj8EaO4o+gB9dMFFjt9wXnnIQU9xnggqbEfjCGr2UhX/azGhxlfAdvSWpazWpKlfWVUU4mMLwG1aElXg6Hnfdy/nesJeIjM9Cl20+eKIdy8115C31wgrLr3ao4zbBFezl2j5zarYlQQKU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac1d92a4-c959-4f47-5e33-08d95e241507 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:11.5822 (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: NeLxZSkiyHywc92j0VTKmTBPj8ZPJesHRybBUCpLrrkOhG2dTeuj2hNaeHyMF6jxhWCJpSQZEHrDEAlzJn8KGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: DD3083007593 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=foVTs7Qm; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf03.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.71 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: youy89fmyt71diom8ws5ekz4bs11g6sy X-HE-Tag: 1628836333-941210 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: Test cases such as migrate_fault and migrate_multiple, were modified to explicit migrate from device to sys memory without the need of page faults, when using device generic type. Snapshot test case updated to read memory device type first and based on that, get the proper returned results migrate_ping_pong test case added to test explicit migration from device to sys memory for both private and generic zone types. Helpers to migrate from device to sys memory and vicerversa were also added. Signed-off-by: Alex Sierra --- tools/testing/selftests/vm/hmm-tests.c | 142 +++++++++++++++++++++---- 1 file changed, 124 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/vm/hmm-tests.c b/tools/testing/selftests/vm/hmm-tests.c index 5d1ac691b9f4..70632b195497 100644 --- a/tools/testing/selftests/vm/hmm-tests.c +++ b/tools/testing/selftests/vm/hmm-tests.c @@ -44,6 +44,8 @@ struct hmm_buffer { int fd; uint64_t cpages; uint64_t faults; + int zone_device_type; + bool alloc_to_devmem; }; #define TWOMEG (1 << 21) @@ -133,6 +135,7 @@ static int hmm_dmirror_cmd(int fd, cmd.addr = (__u64)buffer->ptr; cmd.ptr = (__u64)buffer->mirror; cmd.npages = npages; + cmd.alloc_to_devmem = buffer->alloc_to_devmem; for (;;) { ret = ioctl(fd, request, &cmd); @@ -144,6 +147,7 @@ static int hmm_dmirror_cmd(int fd, } buffer->cpages = cmd.cpages; buffer->faults = cmd.faults; + buffer->zone_device_type = cmd.zone_device_type; return 0; } @@ -211,6 +215,34 @@ static void hmm_nanosleep(unsigned int n) nanosleep(&t, NULL); } +static int hmm_migrate_sys_to_dev(int fd, + struct hmm_buffer *buffer, + unsigned long npages) +{ + buffer->alloc_to_devmem = true; + return hmm_dmirror_cmd(fd, HMM_DMIRROR_MIGRATE, buffer, npages); +} + +static int hmm_migrate_dev_to_sys(int fd, + struct hmm_buffer *buffer, + unsigned long npages) +{ + buffer->alloc_to_devmem = false; + return hmm_dmirror_cmd(fd, HMM_DMIRROR_MIGRATE, buffer, npages); +} + +static int hmm_is_private_device(int fd, bool *res) +{ + struct hmm_buffer buffer; + int ret; + + buffer.ptr = 0; + ret = hmm_dmirror_cmd(fd, HMM_DMIRROR_GET_MEM_DEV_TYPE, &buffer, 1); + *res = (buffer.zone_device_type == HMM_DMIRROR_MEMORY_DEVICE_PRIVATE); + + return ret; +} + /* * Simple NULL test of device open/close. */ @@ -875,7 +907,7 @@ TEST_F(hmm, migrate) ptr[i] = i; /* Migrate memory to device. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, npages); @@ -923,7 +955,7 @@ TEST_F(hmm, migrate_fault) ptr[i] = i; /* Migrate memory to device. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, npages); @@ -936,7 +968,7 @@ TEST_F(hmm, migrate_fault) ASSERT_EQ(ptr[i], i); /* Migrate memory to the device again. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, npages); @@ -976,7 +1008,7 @@ TEST_F(hmm, migrate_shared) ASSERT_NE(buffer->ptr, MAP_FAILED); /* Migrate memory to device. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, -ENOENT); hmm_buffer_free(buffer); @@ -1015,7 +1047,7 @@ TEST_F(hmm2, migrate_mixed) p = buffer->ptr; /* Migrating a protected area should be an error. */ - ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd1, buffer, npages); ASSERT_EQ(ret, -EINVAL); /* Punch a hole after the first page address. */ @@ -1023,7 +1055,7 @@ TEST_F(hmm2, migrate_mixed) ASSERT_EQ(ret, 0); /* We expect an error if the vma doesn't cover the range. */ - ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, 3); + ret = hmm_migrate_sys_to_dev(self->fd1, buffer, 3); ASSERT_EQ(ret, -EINVAL); /* Page 2 will be a read-only zero page. */ @@ -1055,13 +1087,13 @@ TEST_F(hmm2, migrate_mixed) /* Now try to migrate pages 2-5 to device 1. */ buffer->ptr = p + 2 * self->page_size; - ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, 4); + ret = hmm_migrate_sys_to_dev(self->fd1, buffer, 4); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, 4); /* Page 5 won't be migrated to device 0 because it's on device 1. */ buffer->ptr = p + 5 * self->page_size; - ret = hmm_dmirror_cmd(self->fd0, HMM_DMIRROR_MIGRATE, buffer, 1); + ret = hmm_migrate_sys_to_dev(self->fd0, buffer, 1); ASSERT_EQ(ret, -ENOENT); buffer->ptr = p; @@ -1070,8 +1102,12 @@ TEST_F(hmm2, migrate_mixed) } /* - * Migrate anonymous memory to device private memory and fault it back to system - * memory multiple times. + * Migrate anonymous memory to device memory and back to system memory + * multiple times. In case of private zone configuration, this is done + * through fault pages accessed by CPU. In case of generic zone configuration, + * the pages from the device should be explicitly migrated back to system memory. + * The reason is Generic device zone has coherent access to CPU, therefore + * it will not generate any page fault. */ TEST_F(hmm, migrate_multiple) { @@ -1082,7 +1118,9 @@ TEST_F(hmm, migrate_multiple) unsigned long c; int *ptr; int ret; + bool is_private; + ASSERT_EQ(hmm_is_private_device(self->fd, &is_private), 0); npages = ALIGN(HMM_BUFFER_SIZE, self->page_size) >> self->page_shift; ASSERT_NE(npages, 0); size = npages << self->page_shift; @@ -1107,8 +1145,7 @@ TEST_F(hmm, migrate_multiple) ptr[i] = i; /* Migrate memory to device. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, - npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, npages); @@ -1116,7 +1153,12 @@ TEST_F(hmm, migrate_multiple) for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i) ASSERT_EQ(ptr[i], i); - /* Fault pages back to system memory and check them. */ + /* Migrate back to system memory and check them. */ + if (!is_private) { + ret = hmm_migrate_dev_to_sys(self->fd, buffer, npages); + ASSERT_EQ(ret, 0); + } + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) ASSERT_EQ(ptr[i], i); @@ -1261,10 +1303,12 @@ TEST_F(hmm2, snapshot) unsigned char *m; int ret; int val; + bool is_private; npages = 7; size = npages << self->page_shift; + ASSERT_EQ(hmm_is_private_device(self->fd0, &is_private), 0); buffer = malloc(sizeof(*buffer)); ASSERT_NE(buffer, NULL); @@ -1312,13 +1356,13 @@ TEST_F(hmm2, snapshot) /* Page 5 will be migrated to device 0. */ buffer->ptr = p + 5 * self->page_size; - ret = hmm_dmirror_cmd(self->fd0, HMM_DMIRROR_MIGRATE, buffer, 1); + ret = hmm_migrate_sys_to_dev(self->fd0, buffer, 1); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, 1); /* Page 6 will be migrated to device 1. */ buffer->ptr = p + 6 * self->page_size; - ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, 1); + ret = hmm_migrate_sys_to_dev(self->fd1, buffer, 1); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, 1); @@ -1335,9 +1379,16 @@ TEST_F(hmm2, snapshot) ASSERT_EQ(m[2], HMM_DMIRROR_PROT_ZERO | HMM_DMIRROR_PROT_READ); ASSERT_EQ(m[3], HMM_DMIRROR_PROT_READ); ASSERT_EQ(m[4], HMM_DMIRROR_PROT_WRITE); - ASSERT_EQ(m[5], HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL | - HMM_DMIRROR_PROT_WRITE); - ASSERT_EQ(m[6], HMM_DMIRROR_PROT_NONE); + if (is_private) { + ASSERT_EQ(m[5], HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL | + HMM_DMIRROR_PROT_WRITE); + ASSERT_EQ(m[6], HMM_DMIRROR_PROT_NONE); + } else { + ASSERT_EQ(m[5], HMM_DMIRROR_PROT_DEV_GENERIC | + HMM_DMIRROR_PROT_WRITE); + ASSERT_EQ(m[6], HMM_DMIRROR_PROT_DEV_GENERIC | + HMM_DMIRROR_PROT_WRITE); + } hmm_buffer_free(buffer); } @@ -1485,4 +1536,59 @@ TEST_F(hmm2, double_map) hmm_buffer_free(buffer); } +/* + * Migrate anonymous memory to device memory and migrate back to system memory + * explicitly, without generating a page fault. + */ +TEST_F(hmm, migrate_ping_pong) +{ + struct hmm_buffer *buffer; + unsigned long npages; + unsigned long size; + unsigned long i; + int *ptr; + int ret; + + npages = ALIGN(HMM_BUFFER_SIZE, self->page_size) >> self->page_shift; + ASSERT_NE(npages, 0); + size = npages << self->page_shift; + + buffer = malloc(sizeof(*buffer)); + ASSERT_NE(buffer, NULL); + + buffer->fd = -1; + buffer->size = size; + buffer->mirror = malloc(size); + buffer->alloc_to_devmem = true; + ASSERT_NE(buffer->mirror, NULL); + + buffer->ptr = mmap(NULL, size, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, + buffer->fd, 0); + ASSERT_NE(buffer->ptr, MAP_FAILED); + + /* Initialize buffer in system memory. */ + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) + ptr[i] = i; + + /* Migrate memory to device. */ + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); + ASSERT_EQ(ret, 0); + ASSERT_EQ(buffer->cpages, npages); + /* Check what the device read. */ + for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i) + ASSERT_EQ(ptr[i], i); + + /* Migrate memory back to system mem. */ + ret = hmm_migrate_dev_to_sys(self->fd, buffer, npages); + ASSERT_EQ(ret, 0); + + /* Check the buffer migrated back to system memory. */ + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) + ASSERT_EQ(ptr[i], i); + + hmm_buffer_free(buffer); +} + TEST_HARNESS_MAIN From patchwork Fri Aug 13 06:31:50 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: 12434787 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 E4331C41537 for ; Fri, 13 Aug 2021 06:32:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A118610F7 for ; Fri, 13 Aug 2021 06:32:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9A118610F7 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 A31BF8D000E; Fri, 13 Aug 2021 02:32:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96C788D0009; Fri, 13 Aug 2021 02:32:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 798288D000E; Fri, 13 Aug 2021 02:32:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 57EF78D0009 for ; Fri, 13 Aug 2021 02:32:15 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 00D5519478 for ; Fri, 13 Aug 2021 06:32:15 +0000 (UTC) X-FDA: 78469087830.20.D2DD62A Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2071.outbound.protection.outlook.com [40.107.220.71]) by imf03.hostedemail.com (Postfix) with ESMTP id 7AE983007593 for ; Fri, 13 Aug 2021 06:32:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BQtmYqpTSQzvezbTRvfuI5nTBSLtzpUFl2i0utyDQNntWXtUiFYnjsnv8+K9d22YUJ/kMRdxLOORKza+3VfWr02/tPHGP53sJ/uApBS7JiUWe4PRPYSCV9nmt2/PymbVvmigH2OjtlUQfffmzh66J/KwjJs5vd6PfZbuCjPS62EobfJaW8G1NcsxvbY/vW5NdPakFov9Icu0zoW11S0tvda4d+kiMzlAaKS0T1/VEXpAnR2fXuocugHiF4GANN67dLC0FF5Lr8nd+EeI1TWpaRjO0gvMBfY5z0irYdrMZfM9j2JPwPMzeeWPcG15teXtcGarB7e/LQcQh1AxWZ/vpA== 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-SenderADCheck; bh=707xnJfuFhrp+6dAh962xzl7si469vWZYp4BZWlrkTo=; b=fdZD7io8YMQegbYTugegIOTi7ApvMHU3iq2lKpeissgPLZcIItKpOgjdjvnNwluV3wAPUBAv9gfYWt/CMIBnuJhIFDdH8aZLOSAr/UgWdzpVXalVkygWiZmc3H3TWiQtt5OhCw6HgjW/1Z31KWRq46DE92WO/Wk12Is+MADhANtO4tNEp5+6Jh3jkWiRLwy9BsOCshOqgB+rlaAlRQ1VkMSd1yNUvJixaUK6t+N2K6DYsz+Fl4QyeenFuPhH/yiE7NLMOCsOeUy6IALDPBjnGn06KV9dGYMqXuous0srgHlcEqNdFhhjDR+Bt5NvVKhXEVx+1AfeEvoidsmugPTzZg== 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=707xnJfuFhrp+6dAh962xzl7si469vWZYp4BZWlrkTo=; b=fpW8BLEwpgWWtlfRcrTVzNVhzbMQ0spoVFk2wyiBInqYcsLHKN0cqAdHwXvGi+85kxy/bCvl4OyyubyU+FnqFnYq38/461PL4gF5MeHd83NxFTNG47xzt22JNgIGm9X9O7W4o7YvMt08kbL29MyQfMY10grWR3wzxfHBavTjkII= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:12 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:12 +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 v6 13/13] tools: update test_hmm script to support SP config Date: Fri, 13 Aug 2021 01:31:50 -0500 Message-Id: <20210813063150.2938-14-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbc613b7-fd90-4022-2b83-08d95e241578 X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fqUx8InZgJW3SeYwMhysI5cqy+nzGKCWWfNe8LDRiXglXHUbVfIMCyrd2FrwjOTeTZvO5+dIJ28RpRfupKmXQQj1+FS7HZzyA4irKrMU2VnMu/7BNQJQzzTeLD2ndL+0sHSEscX4v2W+o9T4CBCJ68kh9knWLTExDm7G/l1bbaypAqfPN3daNkLS4YhLWpE4lGGGGzROSq7mjzDcKKZtAT6qRUz0nIY4NSvpOv40Zf1M4yfMQ/FNwAkdm+TUpPnGEN8d7SCmbfaxZ15kdhCZkS9+OLOebtIRvrisKTPwLNBaKTYkutWRHO2xWgsXtDVk0pnikObogE2ufEUDhUeTwiPWUgN/4Fgk5wKfQbtUXv+nblAFCSY+rxgMmTZ0nkCGlhK6m9EcJHzPzjjBIHYGT+TBxh7PwcDBgd+iN9FzgjTJzGEzAKp775qaEUqcUyQmytxFwOoGibvs2xvbz3HxxifwvF4o+vsd84VTjp0Fmh65+arqjxRd8jUqcTu1OZf6D7vr3sBgfNT/sGBmgamyDnLW8fCuIixTtOuSskLAN0drZkbmepM1oBQXKgXJKS+GqUdIJ3/Xi140gmJeHaXHN5SKNqStjBp9RmTvbuwye340FswigFy0Ok+RDP0fUUaQr0I3QzYCVh3IZFSvOe8vqZ41gwr/dvTVKIh3FUFfC5KikE70nMcQUk2RT2ca2KHy4aqRmDkiQ5iKf05cPDu8ow== 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)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(83380400001)(44832011)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /DLyPltnd0X5UHVcuS8gwiErkNpPn3arf/K3bjMNmT2iM/+VRVWuv8IkFEXmVkRpt5u7DH0YFUBERuPF9fRKXaeBAE1HaQoPpLt1zNNG/468gSlkYhE4vHqSpeT0lvovmhTx9gebGAdhW6E8PGjfQ63253f0wueH9Me5war3lrhMzBvlkWq297SuwRwoXIvCanudDeuZ43RIJEWEEiJJc1Upbh00gPh8GAGeCa86eZNmhGmaUDs9Zw/WrDPkU4Lv+DANAYXiKVNThi8jTtlk5XGRK1S6imSAGlXik6XQAW+nkBTGM0KFB+Dtc8mOrnpHkWMJkOI+XzMIqBBFAIlU0qVSoEKcezd/El7Hsq3GUQCY7xlfyDsAQHFQPIjPbyNWqwIh6cNXAHIKJsER8FUGRM8fZChWwVFULhO2smI8O2+C84uR8k+WZUiZ3R67OrjRH09I70PugxAAGfsFnDxCC9DbHEeXjmA8AWSCeQWKUKWgAwXOr4UgWUR2bUw0ad5BobLoqVg1J0LkyPN2VV6KnZjZFTznEKxBX2O1FaqvV4cxTP8AB7zNSmHzYHXT8L5WLM+svYxY401uOZDXpZR8Gmj/bx6JWAlfxmmXMXojGuxsK6iMft061/qi5sKjKf4ORS2/aEM+DutX1sjF0VrWWipmUm9IJ8dYdz/hUJjD379DWfAY60wcCt4tDQ74uHaQi+QCG5f5eqmz1cqjlWcz8nkiZQ37ro23rMzlLXSU1QJFC2CdbHHQhD2cZiZi+NdBVv/MGuFH4cqBAEDRGC7haThSwg7mf41LqRvVddr6FTrHSCjf3gg9IuRZ0sSKCAQuKOpCOoLsvlaNcKokJIdBu9Bp66CwoQmPktRlsWvRv4rzQBciNzY/kJtld1yNHgD1uY6pOLSzsHfBGfi8+DNB6t4zoCYgdAsP0HjZ5enNpA7EhNBnNfwtCh6zUc7Rt6KdgpEr/GppezbStp9pnPSpw4XwkPqSGSbfWGbsUvBjOBzHTUrTU4T2PmctsHJ3wjNkviQyYOKnq7scMs2swPKER6yoZOE7rj4Fhd+UEOQ5eZ4Pke+dZDMhGlfYZgxp478VjOZXyRv0Jxb+YqhyK/Nk0k6Orm6e2L3sm1bjYeTu6L33oacbSkGLBdvQO0HRIS4oMUVoc1yjpUc3I+NXF31dBSpTZil2CGZ89bvnZhBuYjiU5Pal4x6UJihM01Y6pFYZrIm7k3OgCZ0Tiwpi/QV68dZf2tkpwn8iwFWYJ6Y6iO93OG2pnMWqVG5cskhm1ZtdzIVg9LsT+pnLcZQR4DfVXErCVkMtvmfqwpHrYKzqmdGj4KL9goW9/udroCuqxY7n X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbc613b7-fd90-4022-2b83-08d95e241578 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:12.3239 (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: 2kMm0Wbv1G2Ufb2sh7T55sjDzjjkCFnPzWolDo5tNi+lXGqmQnCYbpFUDOTPWmk8sCh1f1h/3AHdQ8iIhDBFpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: 7AE983007593 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=fpW8BLEw; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf03.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.71 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: y3ucnfiurrw3u64wcrt4xwn5zey5ob7h X-HE-Tag: 1628836334-617575 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: Add two more parameters to set spm_addr_dev0 & spm_addr_dev1 addresses. These two parameters configure the start SP addresses for each device in test_hmm driver. Consequently, this configures zone device type as generic. Signed-off-by: Alex Sierra --- tools/testing/selftests/vm/test_hmm.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm/test_hmm.sh b/tools/testing/selftests/vm/test_hmm.sh index 0647b525a625..3eeabe94399f 100755 --- a/tools/testing/selftests/vm/test_hmm.sh +++ b/tools/testing/selftests/vm/test_hmm.sh @@ -40,7 +40,18 @@ check_test_requirements() load_driver() { - modprobe $DRIVER > /dev/null 2>&1 + if [ $# -eq 0 ]; then + modprobe $DRIVER > /dev/null 2>&1 + else + if [ $# -eq 2 ]; then + modprobe $DRIVER spm_addr_dev0=$1 spm_addr_dev1=$2 + > /dev/null 2>&1 + else + echo "Missing module parameters. Make sure pass"\ + "spm_addr_dev0 and spm_addr_dev1" + usage + fi + fi if [ $? == 0 ]; then major=$(awk "\$2==\"HMM_DMIRROR\" {print \$1}" /proc/devices) mknod /dev/hmm_dmirror0 c $major 0 @@ -58,7 +69,7 @@ run_smoke() { echo "Running smoke test. Note, this test provides basic coverage." - load_driver + load_driver $1 $2 $(dirname "${BASH_SOURCE[0]}")/hmm-tests unload_driver } @@ -75,6 +86,9 @@ usage() echo "# Smoke testing" echo "./${TEST_NAME}.sh smoke" echo + echo "# Smoke testing with SPM enabled" + echo "./${TEST_NAME}.sh smoke " + echo exit 0 } @@ -84,7 +98,7 @@ function run_test() usage else if [ "$1" = "smoke" ]; then - run_smoke + run_smoke $2 $3 else usage fi