From patchwork Wed Aug 25 03:48:15 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: 12456313 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, 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 67B4EC4320A for ; Wed, 25 Aug 2021 03:48:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E89B56115A for ; Wed, 25 Aug 2021 03:48:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E89B56115A 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 79AFC6B0071; Tue, 24 Aug 2021 23:48:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74BEE6B0072; Tue, 24 Aug 2021 23:48:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6129A6B0073; Tue, 24 Aug 2021 23:48:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 471676B0071 for ; Tue, 24 Aug 2021 23:48:43 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E140E256FD for ; Wed, 25 Aug 2021 03:48:42 +0000 (UTC) X-FDA: 78512221284.08.9C291A4 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) by imf01.hostedemail.com (Postfix) with ESMTP id 6C77D5030FEF for ; Wed, 25 Aug 2021 03:48:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GXrfV66KJq8DhU3zYbsdN7/FpcMye13axAap6z47/+IgK9G7jjlyLlGo+AQ7RSrH6xgJepdsbdezsv/Z5/CAbMHoQeK8T7U/OQRg7KaYFhwcPyVdaQTdW9MMHUaS0TVB3Fo1NOil4H7AeyldjmwWstAPrLOh4vvVOiBJcVe2QAN+TzxRquUsQLRvSkF4pCEUUljFORA/cBGhItH4JlJiNbFkARY1BQMG/IjG1+/Px7wh6orh24DlxqyW1rICt51ejM3fQfZb7mZG1svKha+Nac5q+RR2QH/bOGKA+Kw99KcVBULLlmZ9bNry+M6lAs3HdlJwAgohrkWA2Ox5Lo1ntQ== 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=oEZda3N0gN3l94uCMFd4GDGKH3IDMGBhCvf/mWWcE6w=; b=Ja/ZDYA8QkE2QSJLUYssOeAX1Paog6/r3NiT8o93N1F8mGmBYju9Rs8M9WfZQfJZjrNYSE5UCeM8Np1yp/3kU9MJHw/VpIreekJ2L6kKlN5UHqEBrzqSKuUX7RIaLGF+L8DbpeIkvJqdngESHDdozC2dPQp2l6yEB6pwpT+T5Rxp9gwEXtBaWNORaJuUnS041E9kAJ0Ie90UkQsmfyfYuTEaCZIaH6WjmrgQWMx/PPEu5U1DO0ZKB5O+Jf+S6lyZI1zNNYwQ7RAJVhIuyzK0JWk7hvqAeoHAZvYn9ah+TeVTXIY5+po/VwzBtlHPZCWgFNKVLknFjCP4Aj+tZOTkug== 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=oEZda3N0gN3l94uCMFd4GDGKH3IDMGBhCvf/mWWcE6w=; b=olhA0fC0Z90j3XpSV3yzP0lVoR0w0ixpyEXdiV6zNTf4E78oQFd8Nt7QDMCFcjA3KYCHwg0cN36kr8/b0TK8fJljNQJq3Lw3YYfJFYJe5M7FgajjU9tG9yaKyX4Wvayv0HSZ8+R9nuJZgRRdQ/mMwrwhMr3XdhWH6jA1g/1pIjQ= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SA0PR12MB4511.namprd12.prod.outlook.com (2603:10b6:806:95::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 03:48:40 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:40 +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 v1 01/14] ext4/xfs: add page refcount helper Date: Tue, 24 Aug 2021 22:48:15 -0500 Message-Id: <20210825034828.12927-2-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 580deff8-bd94-4055-3207-08d9677b3a02 X-MS-TrafficTypeDiagnostic: SA0PR12MB4511: 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: 6JQ3OkvkN5ttynpL/dLf3nB1tfSJwIJWvBL4vEijhy1WJA1JtIKdyc0El6V7uDQdG1Dbwyari2S9/QURpdU73rkl7BngIE/IsVzHCaB2ba9v9cdjQITSU6oF26ecZA+cQFv6yIcHxED3fb1C+cm6s5yf6Mmh5knKzEPeiLIT6iUTJBaewZC9XyZQ9bkE+APzTcEab7vjrCywGFVTV7KhT2u6hKxgXpWBvY/EsSsLzzKn0Sbs1Ocr22TMvrghDbfMuvsLe898TdDqJOmSLU8Wqt4XLwNF403UYCVjwTh7i2u0o/8XnRyqiFmcV/H8h/ndFJ7L8158MMGEvqmVwsp6jVPogJP5VXy94D7EyCFoCHg/PZWG9MxAs4Y660XP9lgMT8PcCFk0KL15QscMQpiUxhyRdNtmL2MRyWkCoY5r2NSChZOzxCa3LwxzE2EyoA8jlqfDPp4k8E5dKuy2xRgnfZDMvlxRbsRChrmkor46g3DwLOCAMSpNIPcc8y9cJoPHnQJ5v8/rTkKGQN9HjitkAaQMytp+4eqytAaVacuUpms5jAvC6XdR8lhDU9S1uClRw2/ixOCQslKj3F1qZuUbII72EeytpKOBcQmmVPctzXxwIgGuW0IGK4W0IUu9+AMkZfPHi8yZaAWCKlYIOr9sM6q+laZifHUv24WeJ1wXK86Z/Xs2Q21IhFeS51HQEDiBXqRWTdbh9L642BrFUzVf7g== 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)(136003)(346002)(376002)(396003)(39860400002)(316002)(478600001)(186003)(1076003)(83380400001)(8936002)(38100700002)(7696005)(66556008)(8676002)(66476007)(66946007)(6666004)(956004)(36756003)(52116002)(2616005)(4326008)(44832011)(7416002)(2906002)(6486002)(5660300002)(38350700002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xSB3rLv9V0FjYEooDrWLrCd9eSMnHu+6o7T0g3w34payI9Hv1dz93XcIIopAncV24rsr5QSjov/fqS6N8AMekXxEhSQOIzOBDppSGkZ3sdDxSr9oVRIQukTLAzTdE0ssl5woejI8vllbBJmYMuAltD+rJISgRNRBpV0hzvg/7HXChGli7cGBLBchXmmozDv9/A0swoTgkSxxINYXTwvGx7OnjhkJXmcvLgWtV5WovdjEYLnlcRype+PCfd/f+oO/T4PM6PFlN5wGNYaBOoX+26cHThMhiVkY9GySFItVMUeIZ8T+kdxzbey7xGer1JmnBVWsWC0oiA1hldCkl3h3IcRpe8ma0BYAt8/y6dr327ydlvPbGbT5VfXEZ43aHBQTOAPl2OTJeTt9/Dj8vUjTZGXqTc169pCG04K08cBf07Xxl9Gd62Z7mu18j8HFEnIuGXDb0ov5DXUKEV81QEwYD/leGv963MfkU6mUPaMPj4bJCWeWJXACK93gWuiCizp55sjyFmLW6NAN3O1D4pQ+ApZaOixcrlQR9ooEcYcFUVKc2XSitN0RMKF8QhPuVUgtRGapCwxXdr3fXMqjMe6qpY/OijqH6vIVQibKMS6odWxUBrxwo5PBrfSBaGV9+yJY7Nt3Gk2AMHALWB+Lsf3Ze2kAcWjmidyqBcq4UEs789+y6YNW8sROho1O4CnzjhJfUnJA6ZNX8pWMENQdVs6iEWpZWP2fmPOHwbhh2wnldwJK7Hy1ZVbANK0ow2SaWD0x/LGMTSh/DpBUbuHrBvZ78Ce3z9IK/t0kk45qvQNijoaTNSyzYVZWcZRpTc/k9YBcgv74FvkSEmXmo0iKbZxYZ6IXC3mgKIvc34xvCb4QckVhFbcTuqZ2IhpHWRRvYU9t2TRzS/ThlD8u9G/nE2x0bQViIgBpYc7MMTTqHDckoAPYyzZQe0qlKrTQHEVVwHVHVvkhMk0dNxTmiucF063ZYJbjtTt1jx0qsd2v1d9VHNS1Hu0S+orcY7VuAXJvBIcjUgc883csH1OW4GE8FA+YHYWoscZkS1KtoVAWsn8aW6vMyTXgHEdsbQbgj9GrkvatCstD61X3H+nK8g1hamO7VQNYPNjzJSqsciHA9rvICRdDB9lLzqyXKpQSzQTxlUASJ5tXG5PDNkIxav/oCaiCq/w3BGc6+0o5EEA8vFzFHYTLW63WnmAgvKb37/zEr2xFZvJo17RrsGITVoPjXga1VEVk8xw/VHs2xZLoSp3vqXkorpK98pURq0d3Vk8uQUMq46/IBEankmlX85t9/iK5CE+xCIduSAy90d4ky8NTy3zEGfVfaaCrj6s49SKH4xr6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 580deff8-bd94-4055-3207-08d9677b3a02 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:40.3149 (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: w6RlHS+Wlx5EiwUMDxCbbiCDHOGud3g+1NOlLASg0UFhhxw0jXym9/GECkmblZkMpk0H8zldczHFRwGAi6nPNg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4511 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=olhA0fC0; spf=pass (imf01.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.94.89 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6C77D5030FEF X-Stat-Signature: q1ig4fhaoiekw7xwb9ketujs1s98peud X-HE-Tag: 1629863322-319334 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. Signed-off-by: Ralph Campbell Signed-off-by: Alex Sierra Reviewed-by: Christoph Hellwig Acked-by: Theodore Ts'o Acked-by: Darrick J. Wong --- 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. --- 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 Wed Aug 25 03:48:16 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: 12456317 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, 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 34965C4338F for ; Wed, 25 Aug 2021 03:48:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7BD3F6103C for ; Wed, 25 Aug 2021 03:48:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7BD3F6103C 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 48F426B0072; Tue, 24 Aug 2021 23:48:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F0D16B0073; Tue, 24 Aug 2021 23:48:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26A068D0001; Tue, 24 Aug 2021 23:48:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id 06A666B0072 for ; Tue, 24 Aug 2021 23:48:44 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 89C668249980 for ; Wed, 25 Aug 2021 03:48:43 +0000 (UTC) X-FDA: 78512221326.02.B0CAF0F Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) by imf01.hostedemail.com (Postfix) with ESMTP id 0AD445030FF1 for ; Wed, 25 Aug 2021 03:48:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7ADNXGP4gjJaCxj79EYXEgE3G5l6NKBwy2DwfXKs8qe17Qvz4zkXryfz7yd3XR+zfxCpFYPEkHsH4xoPGE6bEe4qcK1zCP42Ikrnm/bn5ApJ7nUp6odJUleSXhc6Mu7YuUXruDC08CPT0HLxHFMt2g+9zXnsxc9Dsctb0PFtbd14AWwi+Z0JZIisoTXE83kHhb9+mo4hHpzGXkbhq0mnR9+XSldv11Rl5nbB7hGgeaLG6SdIEpYnd/Obwrdk5SIeCxOwXTbc4rSVpGDFUZPuTfdJpC5osI9EUk4ylngxBsWxPCqJnXsVD2FEyHHBsoiPagfmZ3z4bNYCWq8OYXDRQ== 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=bwvtA8B1inLdni1msjeqDIkcCa9b5RX6IH0PSLMNQG4=; b=US887SQotGA+eRD9MVNPD6bvx/uBqM6HjFE50UNRpHucLIu/w/qmmESkbZ4yHhNTCOje5KILN+hVLdBatHaWWuBT3Y2TVG7hMW8TXcG0bQBkdssYYzCbPcgXUA4H19LzPMKHWksE9y9uOkdyBfTt0bKgTMOMpRrcSKA4tIjGhXcLP3EzPBFFd0JApkzQbmOHUxi/F9kavqHdmSq6ISGMlU1zz7Eyfwjs+GqMf9xWyhN5n84UI6bN9hpl1IAnzvYkDy4TEXHcu9F2rlKQJQSmF8PTNc2TimssV0stA+buYPHO/6iCeQv+xXm6YBr7zZNJyB9BaV/uIwoTj2tswUfY5Q== 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=bwvtA8B1inLdni1msjeqDIkcCa9b5RX6IH0PSLMNQG4=; b=tEAtUxDIlhfnQ3EywdPnFZo7SG3sD2i02bEs/iE9bdEJ2uJurd2ztuGrXey4mlw3hQwmirL5sjbAMoRplZRsQlL9KQ0cFC/IVXqvrlTADDUyIyr5g9Iox2KHiX6dklTEyXe9hD5NkDfc0ZOtipUPoV6zsy5UYdDeHCKLeXlKJek= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SA0PR12MB4511.namprd12.prod.outlook.com (2603:10b6:806:95::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 03:48:41 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:41 +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 v1 02/14] mm: remove extra ZONE_DEVICE struct page refcount Date: Tue, 24 Aug 2021 22:48:16 -0500 Message-Id: <20210825034828.12927-3-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bfc05c35-9b29-426c-97f8-08d9677b3a80 X-MS-TrafficTypeDiagnostic: SA0PR12MB4511: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YwJero7fUXINQMcIjq6JFecOizqnbO3toY+O7YcPeRJm+67VBaA9UmtaaQHBLHobsCQAgsQKXuvbf6dOLTYRyNs1yJ/trhvsKuCQxl0FsLJdMba0E+x/zkQWLzuwcU2bvoVMOwkL0IEP23GlOfF3cxn/B23XZRggetybMIwMHXU18ie92PLT9hrjjGFhJEgLA5EopESRR8Nm50UMS0gSS6J4Xof0ZkB9NV496mml4l/0aUvy5tNpjaOZLtDLdc/QROj2CcSRFFRdM19ngeDu1O52MEnXzUiDJ134UjP1JJWj+U1oB8AT8YPtBP9wkJ7EWNHLN6t56DCqmiVtJDUiK2VtOqiZWdvF3RxOfW0wSfX1dog1v9o0DdT8JVa8VgKNSTv84hRnj74qqFwDZsNTXktSk1QGZgJZafACzLIwJeSkM4whCIyrmN1Iqo77ckGYY03l1mqI895PfxridD4Z4JPmTOugZ7RJ3uDxEchkLtz1Dm7MyB87bUwTmTYeIT0C74qf2SbZpAjs/IW6708cm0X8EiCweHKCiCqEKM5tGGWZmoAq81rXxaAyySS7MfLV/ANbZEODKq/eoikZgjjluc8qxpdeHXIjOP0IwhihAj9YT6oVVcG85sc7mT9A2OEaIRpz9HoVVnnEBrDhFwCyp2KDQi1a6a3X5KwOaAgkdh17dRCOhYsWt5knqoDDvZCVjX8kIdizN+1kLkyYoOJqRD4+KfYv/k/FEU34h5ogY8uK3Kf8801cdzB2fb09vBHorxllc8yHlZXPCjaJi71I/EmuJ8QR8WXtxwHfgkfj7LKC4nyocT+P3BhVNocwi1MjF7v3MPKav883jH5ypXgDoA== 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)(136003)(346002)(376002)(396003)(39860400002)(316002)(478600001)(186003)(966005)(1076003)(30864003)(83380400001)(8936002)(38100700002)(7696005)(66556008)(8676002)(66476007)(66946007)(6666004)(956004)(36756003)(52116002)(2616005)(4326008)(44832011)(7416002)(2906002)(6486002)(5660300002)(38350700002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Kn2nv7diAXQkWu/b9TKmxLL2Mul4zP5JmcAK5ulI4DHVyFAh+lyy6LY/eiKl3dxuavRSWE5kuwrsomlx0VuJtjipssgHpSDfaDyj/RBKGaPDSK+Zs1QqefvDfiUbQnT76g1eKzgeea9IGs0PNm6wjIzSWEAGTWU516fE5vQGbX1nN8aLjQGvUT/J5xemH1g0ROk9euR8lsSMRuzBe/wI0BLW3xBQ0EmSEP/rQAdS9bKlmYzg07mmsfynyoAhWCnaX4/XePufT6YoKH1WTDWyHduObP8cn3xTYXMyBaGfnv6tY3onVruvObIYT5qN/CkOMkf2h69cSo4wRkS1+CFYigCF1gm34MJYxzkq7Xr1plwLepNb6qdJhUT54XYmBzxmIXtYBWVbRF6/1Ew41FEuyclT4zn5efXfse70Ff2fOnc816nFSoGMKp7oh+Bm1f0to2wWfzl6XtQlcDdPpiLIGJAIKcK+OuHgRPfT/v/AzbCx8FiiqgOIK+J04zF5G3SVSO0nHEoGAStPjWOeHFUpAIXnw7xSEiyfzePfJscipgMwf78ghIOTExl3Th0aclvq8Lq//PR9OH2Wbjn8nm3QjCzhmNC9QFHx4snR7DiIY3Jm265njlNHXype4cQ7VC/R8L+jeflnalBxEaudUFIOkJ5Sb6S6dEk9ysh4G5oZaD+67LdTwWCOUwTNHmTZoVNVfxOQqyJRl2bzDIHnqErvSu5e3yfNk1exdbBRlNQpK3ZbrHauXimiAW5HKAvnUT50e0xLqXSTYyRkp+fZ0az969ZuQgESMfmYcepAEetulfqJCU2WYZ9aeipFNgOW1ZsWGKhE5I9lKkYULz5KSJp63o8gmmRho6M9MweNvvAQV551ZWaK+Y57OEwoqeRzp0tb8foFXUow2Iv04/spuCiekCQa1c8qAVN972pOb7J/iJbt278r/mPAwtlCznPmyO6s/XDiCE/jaH+Nr9RQFlRYjKmgAxukg66S9x/ZdTQVumHYcnq+j6rkMDwxjRgzOdZLgqzyu3mRNqNlrNYBLrQIXaK1xTFgDAd0H5ycdP0fRtSlxB4W/GkE696xRtyfw7SbTUYYKu11r7PuaMEv6sXqRyreab0NRR+zhdkCDXIPCi21XxZwyaHPavIWgYWdgIKY1IRFtWrhuIuLs5mVZs9sjt5SBvBEiJDlS0MH5A7eTI91D5sho1XUVwHW7YxAzKV5q0d2DVgK1dQA2vQ4HpI38nJGXeslN+tzvWG91pAjus2CO4d2XKjQZsMD3OB5d444YtEu8HOorR56SMLZ4mbczf2W3KULijp7K8lNmeAtdEQZrFiBE9KJySxTyae7Ul1U X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfc05c35-9b29-426c-97f8-08d9677b3a80 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:41.1890 (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: UJ/krujcQi6zEZQt8Z/VnWN54ef1OWgj2/pITyQdYagPvk1NLXKPePrjofvZErInOZ3U1jOVoY0Dxu5OjcJQJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4511 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=tEAtUxDI; spf=pass (imf01.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.94.89 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0AD445030FF1 X-Stat-Signature: 6f6daa96bjgkx19h14i9xz9kbyftzam6 X-HE-Tag: 1629863322-589532 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. Signed-off-by: Ralph Campbell Signed-off-by: Alex Sierra Reviewed-by: Christoph Hellwig --- 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. v7: AS: fix condition at try_grab_page added at v5, is invalid. It supposed to fix xfstests/generic/413 test, however, there's a known issue on this test where DAX mapped area DIO to non-DAX expect to fail. https://patchwork.kernel.org/project/fstests/patch/1489463960-3579-1-git-send-email-xzhou@redhat.com This condition was removed after rebase over patch series https://lore.kernel.org/r/20210813044133.1536842-4-jhubbard@nvidia.com --- 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 | 11 ----- 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, 45 insertions(+), 114 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 d8f98d652164..e24c904deeec 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1220,17 +1220,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 Wed Aug 25 03:48:17 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: 12456315 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, 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 EA07CC432BE for ; Wed, 25 Aug 2021 03:48:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 833F46103C for ; Wed, 25 Aug 2021 03:48:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 833F46103C 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 B1EC56B0073; Tue, 24 Aug 2021 23:48:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA8276B0074; Tue, 24 Aug 2021 23:48:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D4268D0001; Tue, 24 Aug 2021 23:48:44 -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 759546B0073 for ; Tue, 24 Aug 2021 23:48:44 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 21DEA1803F9DF for ; Wed, 25 Aug 2021 03:48:44 +0000 (UTC) X-FDA: 78512221368.25.F8AA0E6 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) by imf01.hostedemail.com (Postfix) with ESMTP id AC75F5030FEF for ; Wed, 25 Aug 2021 03:48:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MLaOpVOkqdVN8G3ufRCQJytBt8Cd3eDgLwIK6t4W+JGLAx1chL4RQ1HpXcDWLfXzcfZEeyOYikFHrLaBKQ3R79Enn8E4eMgKN+b1DMum+Axq9BVjisSFNn0kSZP4ptp8UFOFyGZyVAn2LRh185w0KlDk4mA8sWLVU8G8LUmevSKs+4PttZF/vWoS7EGZE8Iwd/KOxOJHg9mrnMTPhFlkf52zKvIqzCb7EVoRsgRirNiileD+1Dp5PtYOsgJEaRWFR+aaCYbzTIhQ0ROJI4R4yyHN9+JrvuhjJtu8rXII8IJMvDTyjCroMKcLWrxNfyAHoI06yJ9LUrdUMrNIAlmg+w== 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=8wRbV2DhV8DbE5TzDUTHl0JWq3DdgS2MRaH+D8hi2PQ=; b=dG0tH8LP/+wixoHvv8+n23m8UYmi3AmheQ8ZxHnT6hQM4+bxRjA9CPL07eDBjZs9FVB33hZfZxxQPOQeOqyTGa0ijSA1aFGYGj56HDTDJaOGRYeA4CACjdFcDQZxyRwmVKg5/w70Vz5SVnFaYF9FG44TKUme2PYSReL6vhrw3AzqRtcAdTGZ5orI2qZ35K77NkoF9usTR3mQHe/43qmDYBISrL26JXt0tZR0Eia8yDjMXxuGJBr1tZLjaAxGiOJwkugvAgvdXjO/LupvCNMEtLQA6K9BqJce96SYsJaJvqgJPOT0p09extP2qnrWpHlRtn7z3VfjA8tcuo54aV5bZw== 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=8wRbV2DhV8DbE5TzDUTHl0JWq3DdgS2MRaH+D8hi2PQ=; b=VO1VA21Fef/TSMP6ikLHZ69/W48/NmvAYUlgTEzGRf91mmR/6O4511VFM60FKI4cx1pK2XYTexMUri2JftE5Hh6CfpVM5LIya333fdHL2sRwEc9l3ReTDEELTWmNdakkLRXCiURus0OhkbE9a+TdqcHYsnfhaIzKDq7ZzrVTWFk= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SA0PR12MB4511.namprd12.prod.outlook.com (2603:10b6:806:95::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 03:48:42 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:42 +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 v1 03/14] mm: add iomem vma selection for memory migration Date: Tue, 24 Aug 2021 22:48:17 -0500 Message-Id: <20210825034828.12927-4-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fb6dd18-a0b1-448f-aa24-08d9677b3b0c X-MS-TrafficTypeDiagnostic: SA0PR12MB4511: 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: ecMg3UaGjxV6r6jukGl7zrzu6qc+WHgAGpoGBhIt74g0g4Ikrc5IIOBCnIdpD/8n0o2a6zlVOSkv6wo9+epRAd/K0p9qT6bAMnQldnYdNUhx4pJsSEdeMzZyKKp+0a/XBCUu3oUvC1fbkkGmXaMC0JX14LGk9weqBwk7HSK9O+EuaV2w/a6LX2ZQzx3Gr6e0+j9skxTgZYOH2eZSXjyAbx3y/Sj3/5JMWkZCeZ8DDbH/jCaS7kHEC6zopd3YkJvFaJQkm5Nd26cMPcvmsLqKO52yKPaY0f96RZNN/jx3DoLTfMrHllkv3kRCHoSmYFWqGzAKtMckoaCuDqf5pcjBclvmWcxXtHspUAsz476PTe4TOP8wCiZ7hJsIsK8Qi265iRdq5jVrnR92vQ/OXM3yhY9txrvOnpzB9mn9642EpLI0QyrrmPAPFlXRxk3olE/QtsG6q9JkGeoC+6kyeMAhpynt8Da+Dki+X/3gVCrLytm16dVsUnLvyuTwdB1t/9McKBwkrIIRk3CbjbJWYIU2Xlaxn0ceJh4stx3Ar5rPCx43yEnM0QYDWXSNtjInQmIcqpjKK73MSyGBH/DX9XMYtykG/DttmaiC4jTCaYE9S65x+VpPdgdzxezdM3QyGrSDu+L6LCSSm/vqebiLCGIFfcwNXnWaY/k/QY0VmRCs/Y2YFvNT2xEW6ewiHspKuD+Of3I9+E6W3NUcksfDFXnDZw== 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)(136003)(346002)(376002)(396003)(39860400002)(316002)(478600001)(186003)(1076003)(83380400001)(8936002)(38100700002)(7696005)(66556008)(8676002)(66476007)(66946007)(6666004)(956004)(36756003)(52116002)(2616005)(4326008)(44832011)(7416002)(2906002)(6486002)(5660300002)(38350700002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6NfkD9rq7lw91ZDyR5Qq1waoUiJfPkG/uIQLI/xhXt0Kq5bQCg1LMD3XPCRirIT3vLt5qyVkolpg2WVmw3Fas5RhP5T0t29duZRHC9YmpajwbTh4uFtFk2rD3GV35W0p612YgGsvrnICsu1HOaBK/q1NENNNCg5PJ4MF07bZwqSjs1p0fQJLkrMt+66J9A9MvadNQRKvOQeYtIVQ011nAkP3wpcY9k7C0EpVq81JJ8MBSxh+MJTWtvbqG7s23Ni49w9RRLPAyQ2Xuz6MU0FuTq76Ib8OsLXJGPiGpzf5+2iyCJQt+PWwjzyDrKMHMd7GHJZfVfjE7V/NaKuTL/9Bp+nURy1P+V7sevZjEriRDfWSeeAyIm7kmJUsS9F3/A2XGuQqrnnTQ1c/mj28qrKK4K3YIK8TnfUliR//+KKV/vjDvhhXmgM8ltdihlnSNhkOSrMjNnyiyc0BHU4C3yhcIPe7U6SEebhhgeOzJXjy7f2gjUZBpHN+RfCBKdoLTG4GuvndKp/6uYk/KXA5BjolOQdDqA/IrRaAC2WgivnqeMxv3qXh3G1keQ0iLtHsS3R/AzNyIToTmvPZB5llnQeJVc2g7/V+l+7g0JdnA7O2n3If1QmbHjQGYpSr/R3kcFS/KttwmnmWlDMD2pHFDjypzOPhDcduZOUYld5GA7NgUD8FNuJgSWlL6OBf1rUfYMy83kgGTQD/+0DcGprwE1PcrarUItfKXTOBvFDDHIA2mIHI1c7D9IQ6cBQ/twJwHeQsAIc4ySwtDJqpiKHnGVMBb4Jnq0UYrriweu4mqu6BXH27eKs8POiLPEVpfDeRHM8mjlgW9yYKgofNPF66hoFebCwCKzp1aaoBhW4690F5E3501DiJMqHq1GpH2kRfBqzf3Bpiv2hKJM+ptY0uM8IQID4hVWaj1iU1mGhJoS6USJimg+ACrghWbUhyMj1WLTD4pcV3RRiJ0uewtyuVdc3LpW6/kXjgO7lZPSUIarnObpnbmB69/vyUi/9lJfG85rR/j9LessU98tspS94mD9xUZZTx8hEZz4P2TdStpKnsGs+5gMt70jX0UxzwbEyYyY7tE6lFEI0H2QNp9qUMLpRqQf2I1P2ZsXc83Ps7usfGo3HZBi3vjXBHvMoYxhb0E6sYnIb3qppYXWrFHNx1cfdZBf0iEjsFnKaEqPlMn3tgbDuxJliaEY/gPn08wuENgAb4p3oHKCwSKj51WeMkvxZBMuogT0T9/CnPaukaeew5BMeh6sgwgMtk+zzWNBVFcMpT5R/awMe2LCEdVLrdOPylIy2cxJGcHzyQfh4jl7yq6yoVeHfbwC/gWZLX/0FAigDR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fb6dd18-a0b1-448f-aa24-08d9677b3b0c X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:42.1249 (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: 5yEbHUz2A8M/xPc1ww8ORfcSoq50hWfbE/UOu+DrT7yHg05NbiuNYgjUkCa/nUpW/+vOgAaW1MrHxvFfvf3ekQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4511 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=VO1VA21F; spf=pass (imf01.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.94.89 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AC75F5030FEF X-Stat-Signature: x5xo1fmgaxx5bhawr7b43yy6qbbye55m X-HE-Tag: 1629863323-791209 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 this case, this is used to migrate pages from device memory, back to system memory. This particular device memory type should be accessible by the CPU, through IOMEM access. Typically, zone device public type memory falls into this category. Signed-off-by: Alex Sierra --- include/linux/migrate.h | 1 + mm/migrate.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 4bb4e519e3f5..6b16f417384f 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -156,6 +156,7 @@ static inline unsigned long migrate_pfn(unsigned long pfn) enum migrate_vma_direction { MIGRATE_VMA_SELECT_SYSTEM = 1 << 0, MIGRATE_VMA_SELECT_DEVICE_PRIVATE = 1 << 1, + MIGRATE_VMA_SELECT_IOMEM = 1 << 2, }; struct migrate_vma { diff --git a/mm/migrate.c b/mm/migrate.c index e3a10e2a1bb3..d4ae2da99607 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2406,7 +2406,8 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, if (is_write_device_private_entry(entry)) mpfn |= MIGRATE_PFN_WRITE; } else { - if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM)) + if (!(migrate->flags & MIGRATE_VMA_SELECT_SYSTEM) && + !(migrate->flags & MIGRATE_VMA_SELECT_IOMEM)) goto next; pfn = pte_pfn(pte); if (is_zero_pfn(pfn)) { From patchwork Wed Aug 25 03:48:18 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: 12456319 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, 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 C11B3C4338F for ; Wed, 25 Aug 2021 03:48:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 69F8D6128A for ; Wed, 25 Aug 2021 03:48:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 69F8D6128A 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 5F21E6B0074; Tue, 24 Aug 2021 23:48:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DB258D0001; Tue, 24 Aug 2021 23:48:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 291CA6B0078; Tue, 24 Aug 2021 23:48:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 1108C6B0074 for ; Tue, 24 Aug 2021 23:48:45 -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 B3936252B3 for ; Wed, 25 Aug 2021 03:48:44 +0000 (UTC) X-FDA: 78512221368.29.EECA297 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) by imf01.hostedemail.com (Postfix) with ESMTP id 43CD25030FEF for ; Wed, 25 Aug 2021 03:48:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EgehTIrs7Td55mBJgbmKf0zuDpJ2hDzeWT5ty7Xnqcs9PKu2ph21kK1Mxl5m5Eoy0QY4vGnFUDSV95mJ+Zm8dLhq/ojGpVISp3EP/5bF6vhTny6XzOucNs+G5MzeyAC+Zu6JmJvaCD7DeVDDfRwB2ktZmgMqif9GFkpuGVSuYQF0z1Pyt/R2CPXQaQsDAk3R0uGJDqEa8+CPMd2AcVH9s44gJ9DCrKc3ZBbGplYWIs+bep0FE+nWYDAshb9+8UAshl8DXmYU9hj/nIiCFuQSaBJE6OFPCrXpXYyoMrgPpc6kFvtqFTHpSqTuEK7HDKa+aoTMfku6WTQgqUqFmp+6+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=QRfI1RwCo5hW3AB7rncXDgQjMYTtir4amfvDSTe77GU=; b=DthLw1xAyxTgM4VPHc//gQevosf+uX7jEEfIK8I/E7WJ6u1m5EGANeqRx+XfQPbQasmA5r9608zHk8MwfLMtcElD3FFDa9UXsO5SmM9exTbmbe4u0KaCsJCa4jyUHVss5guuOkUcHpITcJlvmJka1tBVojtzCwJbV0A8qeksSFsk4MbTY510QTMa0QT9qzokOlUJLdKwM5lUZNXljL6FkqBSRhMUt091h/O99/CYd8RP2iDeCLbD29cU4GlO53z9AAXGQJjRIrFmumXKD8LnlEgm8oWFa8RQVUppQmeVuJ9ZuvQo4857KyomsVWUYS8/NpxYZ/mb+oCotH3NikK1Kw== 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=QRfI1RwCo5hW3AB7rncXDgQjMYTtir4amfvDSTe77GU=; b=1FkKvFATRZNrW90lcEehZ6AX9uwSkvPvGxb8gugvI7RVVBw7CjerlFwaljhftYtaFJwUvZLc9rR5eBaHFBD22JjdYKlglUqLALTY2knbGZa06zXJBrtilRaD6+rZLBisnpbam9znl/jTKATayiiN5u5nc9GcQRpLWUR/G+31Wpc= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SA0PR12MB4511.namprd12.prod.outlook.com (2603:10b6:806:95::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 03:48:43 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:43 +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 v1 04/14] mm: add zone device public type memory support Date: Tue, 24 Aug 2021 22:48:18 -0500 Message-Id: <20210825034828.12927-5-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3712ba4f-6dc6-436c-b35d-08d9677b3bad X-MS-TrafficTypeDiagnostic: SA0PR12MB4511: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wGc4n7+PMqpVzWRzaA/O1q3F58DddO1Cc+mN0pZz4K4v6z8X63LGkVhFpWdT0dp/l3eIzWoeS2uguWow2GoVQ4d9vr6wfO8WAvu7ochAnnP1dlkoipOIpXjKpqXV95SpFdtd9nx2XHYMhvJyrt57RQ9ZqrSp+BYK8QYU+/AjYfdgPang04RLaZ8+HRnWcKpmhdre2OzYkc9ZFql68pz6f8Yvwc96sKuLNaFCuGKFCAgcqtPAuzyYdf80JYC5hVKUgptw2Op/GkeaqPP0PlZM9a5i1lcE9DPJGgI3eonqJ5MTF2bONn5SaHot9E3cYYDrwl+l294dN0YFzyd21SiestNHwrCT6sFqU7Rz3LIGgTgURBgwgWtDnUiFUYkR/GkP5zNH9POcheZYbSAcbo9b5zr5FvRixFpTUfmyrwOe4Y+UKeCe0Jnq7FuKgrwgDGLuEb3tpaol9uta9VxlIOX8pSencESkGHDYuOgRrWdmcoQKM2i5L3DfAeGmdPxV8qM2s5stAxmeK3S1rDWSvv7X7kWkVCh3o3odXJcBpuf+FnI8TjDURa1JPY/J2c/goOBCV/bHGROS2pF0G1Sw4xtTFMxI4ay6sP4h3xdcT08778PF8RaRXljDwhkOujDqynKLELeVAY7R4ojr0sb4j4AkT6eK8rqBEAlb0vDzNki7ciufkCXGEm2kZYtjSFzbzF1PKjzdOwTAp0BmWuODaEKaRQ== 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)(136003)(346002)(376002)(396003)(39860400002)(316002)(478600001)(186003)(1076003)(83380400001)(8936002)(38100700002)(7696005)(66556008)(8676002)(66476007)(66946007)(6666004)(956004)(36756003)(52116002)(2616005)(4326008)(44832011)(7416002)(2906002)(6486002)(5660300002)(38350700002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LvSyh4Iau4a+UaTBvr9VEVhfHhAISHgyrT5Q9MTBoA3e7w78aZHKvaSch5DwvFj4zi0DgDW/Ag+FAg8CQUWgaBIyPbV3qY73JdsAeW5rOHgzeL5GMkFNmsIgzD1V+0V60Lqyg3RqEwoZs5bAQ+t6XuiCVpNJOgq5d4JQA8M4btb8WWDGHcykdaIE8Jhc8zSF72L2HPQBF3/bfiv7viovUUrsSkIpP9m2QcJyiYRD3nH6OElcwMtjLOJqABL08+krb27Gx8vywahz9aOtLOtsPj7XUwqVDlkU+T2aFezgUBoBkackAzLycGBi+jPlPfCN7NDer2PwIQl8nkPu/MEbj/d5LgjTfkAaTVDZnJ0qsS52sbg8pX/4HiqpZkbaxf9QcWGPAHQ+Mv+Ei6ryxX4QFyZoHWfdqI7TKuEoWdRIHWijyguWyrDnchJk35HIxrjJbkjLeXGSRsmdCV8sbtmGLDcpwaG+ZPuMXEhL6lbXAOuoaHw65B0YXNqKHKXUuvYwnhmHtmL6bd/FW2MLdW0s2iA7iDD1dJbNpgqnsArRP2PSSH+iEm3ZKV/9IWjjENsE+Dc2uh5QZcdaue4EA6I5QFptAgKuWkbza6f9/mOovnuY3f/W5Yq+2W/ZBt0g1Fm5Jj9UG3Gibs3wnuplmISVNcPFnIMG8GgN8EKDOJgCYIYOsKWyjcpY89NefpBD2WjM3KCBeOKsWRR5IG+v5jkx1w65hD32qlT3tx7JbLcjUJlhirWul97bDw/QMhC2rzGrfySlNAif8oAxssiezsKAF6kYBEUfE+SFwxUzWV3r43i61m4qijbIxUwUefYoxcMJ6/RcrUa7vc00zV1jCC7wu63weK0OJ9aKTwFUGcIVhs0S3oje4Fk3el3Tn7UK1tGdNF+rUrm5gToYEAarrD4UnU9zrgEmW+NNPKytTcac511Jj+m6DIJsUfyf/H3Yra58erx5ragSDZh6Tf1emZynVCFaasM0e6D5IZvn82gaprr1EY1FFJ9gxJ6sBSKrSdUfQ+mG+9iw8O1VRKYy616UdLM7nMNUNBhQsdRcQpATEfJRnv4bLViMkEQagldUC3bDPVqRXv9ZLL33haOhXz6FV9lto1f/PnRJ0nZJ8czSZaMHiKRPUqNl3Jjc2UFf8M568Y86fatdLhkfbzP/QB2zTrTNgeU7OPy6nz4a2xv9sjqjmHlVVLm/EC1gjVgjN70yemvSsXT2M/Uym3SVLe90mNhHbElD6jCQRUWTKK0FxQgXcbT5LDljpO7lPvTJYHzksVFj3PUkZUnsGbclNh6kgCBG+PgOOKhPEKTIr6NKFSVdReCqpR6ap7bIooct075A X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3712ba4f-6dc6-436c-b35d-08d9677b3bad X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:43.0728 (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: U90sx0d84clKRUOyJC7cyg5cmQSogD6ANltfX2JeuaJL3+x0bEt0pyI6/dGMVL3+5QhLI9Ocb6kV2DsFc5yXTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4511 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=1FkKvFAT; spf=pass (imf01.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.94.89 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 43CD25030FEF X-Stat-Signature: fsf1344r84w3n7yp4wzwtheynxf9h953 X-HE-Tag: 1629863324-353305 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 memory that is cache coherent from device and CPU point of view. This is use on platform that have an advance system bus (like CAPI or CCIX). Any page of a process can be migrated to such memory. However, no one should be allow to pin such memory so that it can always be evicted. Signed-off-by: Alex Sierra --- include/linux/memremap.h | 8 ++++++++ include/linux/mm.h | 8 ++++++++ mm/memcontrol.c | 6 +++--- mm/memory-failure.c | 6 +++++- mm/memremap.c | 1 + 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 77ff5fd0685f..431e1b0bc949 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -39,6 +39,13 @@ struct vmem_altmap { * A more complete discussion of unaddressable memory may be found in * include/linux/hmm.h and Documentation/vm/hmm.rst. * + * MEMORY_DEVICE_PUBLIC: + * Device memory that is cache coherent from device and CPU point of view. This + * is use on platform that have an advance system bus (like CAPI or CCIX). A + * driver can hotplug the device memory using ZONE_DEVICE and with that memory + * type. Any page of a process can be migrated to such memory. However no one + * should be allow to pin such memory so that it can always be evicted. + * * MEMORY_DEVICE_FS_DAX: * Host memory that has similar access semantics as System RAM i.e. DMA * coherent and supports page pinning. In support of coordinating page @@ -59,6 +66,7 @@ struct vmem_altmap { enum memory_type { /* 0 is reserved to catch uninitialized type fields */ MEMORY_DEVICE_PRIVATE = 1, + MEMORY_DEVICE_PUBLIC, MEMORY_DEVICE_FS_DAX, MEMORY_DEVICE_GENERIC, MEMORY_DEVICE_PCI_P2PDMA, diff --git a/include/linux/mm.h b/include/linux/mm.h index e24c904deeec..70a932e8a2ee 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_PUBLIC); +} + static inline bool is_pci_p2pdma_page(const struct page *page) { return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 64ada9e650a5..1599ef1a3b03 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5530,8 +5530,8 @@ static int mem_cgroup_move_account(struct page *page, * 2(MC_TARGET_SWAP): if the swap entry corresponding to this pte is a * target for charge migration. if @target is not NULL, the entry is stored * in target->ent. - * 3(MC_TARGET_DEVICE): like MC_TARGET_PAGE but page is MEMORY_DEVICE_PRIVATE - * (so ZONE_DEVICE page and thus not on the lru). + * 3(MC_TARGET_DEVICE): like MC_TARGET_PAGE but page is MEMORY_DEVICE_PUBLIC + * or MEMORY_DEVICE_PRIVATE (so ZONE_DEVICE page and thus not on the lru). * For now we such page is charge like a regular page would be as for all * intent and purposes it is just special memory taking the place of a * regular page. @@ -5565,7 +5565,7 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma, */ if (page_memcg(page) == mc.from) { ret = MC_TARGET_PAGE; - if (is_device_private_page(page)) + if (is_device_page(page)) ret = MC_TARGET_DEVICE; if (target) target->page = page; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 6f5f78885ab4..16cadbabfc99 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1373,12 +1373,16 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, goto unlock; } - if (pgmap->type == MEMORY_DEVICE_PRIVATE) { + switch (pgmap->type) { + case MEMORY_DEVICE_PRIVATE: + case MEMORY_DEVICE_PUBLIC: /* * TODO: Handle HMM pages which may need coordination * with device-side memory. */ goto unlock; + default: + break; } /* diff --git a/mm/memremap.c b/mm/memremap.c index 5aa8163fd948..2c8898ed006f 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -294,6 +294,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid) switch (pgmap->type) { case MEMORY_DEVICE_PRIVATE: + case MEMORY_DEVICE_PUBLIC: if (!IS_ENABLED(CONFIG_DEVICE_PRIVATE)) { WARN(1, "Device private memory not supported\n"); return ERR_PTR(-EINVAL); From patchwork Wed Aug 25 03:48:19 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: 12456321 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, 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 B991BC432BE for ; Wed, 25 Aug 2021 03:48:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A9B261371 for ; Wed, 25 Aug 2021 03:48:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6A9B261371 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 A34A46B0075; Tue, 24 Aug 2021 23:48:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 997226B0078; Tue, 24 Aug 2021 23:48:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85CFF6B007B; Tue, 24 Aug 2021 23:48:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id 6D15E6B0075 for ; Tue, 24 Aug 2021 23:48:46 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id ED14425708 for ; Wed, 25 Aug 2021 03:48:45 +0000 (UTC) X-FDA: 78512221410.32.DAD4BFF Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2083.outbound.protection.outlook.com [40.107.94.83]) by imf06.hostedemail.com (Postfix) with ESMTP id 89EB0801A89B for ; Wed, 25 Aug 2021 03:48:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b+2Umku7vhgBIObqDRq+7aadzvzB+LV6ZTGs70KAREp/763GObHA/YNTvo/TZPENsJEzZeR1Z5xBRN0PnunhL0jfd/QFx1bwafR5cbupId3TRjWup9qkcAOweNzF111e2juxo5IMP5kNzEMAK3XzTzYc6R1Fgy1OSnbt0+nXVIq9D6nkM7fpPLphXQQ+5mTt991dct/67Ke5jiNsG5oENrMd1CwiyR16gI/KRfYapBXtBst1fEjM7MqpUWPW4FF+BusV/GPnrDmdL/RktFQ8FGhEpO/+zTL9IBEq1d4zFbSyWjTK8qw5dXjlhBLAm/usFw806zQvsb9TjxnimfHMzw== 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=gewBIQO8Z68IgfgsrXbEzqIa34U16SiSGjwinCd25vg=; b=OBBaymnlJiUhqaZ78L0xGrP9N38KAIMcZLHQxXOcsosoUy6bwNONmbyO6THYZlaqcj2+3Uv3KdZc5mTLt6C2is0J77DwKE0GyY22ByEJGeTDKoR6bt7bWDGte18HsDYkOIo+G+P8EKjmFIL5lKotemilc+9GyaGMGM72K5R6LeEfe7RVwJob9C4OZokm+4l54WxEDXQXN+ldGZkmPhACMlI68NmiCLPtc+9y8UBr6gszcPuNWCGW3ogabTDSEMDQa+JY+JVgPhYGPXpPN+8m6xFaDngy23zH9+Oyx3yY2dvjaipybgv4zzW7hJq0o4+YBbnsBS7yqFkBEYUKZBKQ8Q== 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=gewBIQO8Z68IgfgsrXbEzqIa34U16SiSGjwinCd25vg=; b=Z4RKmst5+aX+2o5eJDzdyCd4APBvgkP50trb9pKTNn6sK1JP9eBZ4sMhuz3404p1zdErFH0/ovvbZ+oYx0mzQQMqFNnD0yYS2aPEeHIMFonlmr6dQJZSwa+KMd0WuQlN90VKAg6Vb+0E5BmsUdrgBfn3FqITWSt8PSvVNpDEyDo= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SA0PR12MB4511.namprd12.prod.outlook.com (2603:10b6:806:95::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 03:48:44 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:44 +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 v1 05/14] drm/amdkfd: ref count init for device pages Date: Tue, 24 Aug 2021 22:48:19 -0500 Message-Id: <20210825034828.12927-6-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62f48c69-9d95-42c1-3aab-08d9677b3c46 X-MS-TrafficTypeDiagnostic: SA0PR12MB4511: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1265; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j7YAuGS2Jo7J2K99NJqNyxfA7rI+uK44ke6WIUPhpjo2SUJPozTI7f4IipjxxB8DuZimJAAmoC5VmdKq36t0OL/PmTtnmmmhg3DjK0TUDcdITVzzxSYyjx7fP3gqDgTW3VRzqtfBUprDrHY25PxasLwoS/jHn1iMi0dGHHXJkUt8gSrcga64qxcHYFeH0fqHJN6Sq+PnNZY5gPnC7Ru32x5vkImeUugLp66u4eQMsURaLKqiYZitxX1+ywnhyPL5yyijROOwW+YSgmUUNgH9JOQ4UQM8PTBIA2Zi6K8ZTENyTbmU8Mk59DML+iZ+EndyLVbTJF/NYNXmcIpzkzylLuyThO+p4/rR9Um7Lh6F/E7868FqdzH4DhMNNvLZffQdC/eSh9ZjnDJloo5LfsKa3SIoS9OoKobF8YR3v9vCmRpNn9oHNL4qngGUe0fQ1t82WMSCAeeXz6hZD6oEGbmq8MSkaTLidJ8+umu9sPHkB9S44LFq+7FsJoTXNaMLQgg0Hw8JOlDwfQZNe4qnTfvKJJuUJGBeNha7pqxzLTdcGoV9XOyk7CUHgLbgyIEeyhz9ZeKKQyrOhwxCotudGoJbuBpqtYaYFo/FYcppl8rHeESbmZzRGmGpj+rSahPnsT8Z1+bvqFSG4o+Py1zlydBEFHRxzzKmL+3SIeTz05jnxNLXIlKqAxFrnhOekS/dlAic1Gp3GfSU0ht55/03YgvsVw== 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)(136003)(346002)(376002)(396003)(39860400002)(316002)(478600001)(4744005)(186003)(1076003)(83380400001)(8936002)(38100700002)(7696005)(66556008)(8676002)(66476007)(66946007)(6666004)(956004)(36756003)(52116002)(2616005)(4326008)(44832011)(7416002)(2906002)(6486002)(5660300002)(38350700002)(86362001)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RHc/YK9DrpGz+WRV67ZHjvhvUja2p2CgruIQlttjSzkK2+XKmoW6P2325PPhF6M6Eqp1R6XdeNMg6nh4RrvatRu2cEYjrZOGGqTj7JjbVuUW7pG51u4bbIpY48x1CTk+gIlRMIBwSZkgAvgTJn1QLIXmLHkLwIoDKd+tebW/LJbto2OMfjV2fCZYnUeDgPEseyP+ilydKbPqy/2i+L8R4RXedvCqHn4pIejV/q08DmGz6RbYR2FgCLXKGeO664J0yCRlaqoi23kItgRJn2VZ/JuTM9jhsGfhaRVw218tRfo+6w9/mFWppCyCd8MOBzDw9/6YU34ldH1rgJ7JyyExvt9xqCexTQW/iU1dET2FC70Dhqz/lDbh4ZhEDA4FhjyYWwcz9cZeazpb9Umqz1E4I9xS6N9k04yamATh6b7UJrmaPryKCZt89jLjyv27pAS+xw8PH8Le2LtQHGl7yPV0EwA3eHfySHnfBW2qiEx+OBVm7lT+Dv8WyGtDQByr90C3B6XfMAtvvrP0ZJeKzGhGMuxL0Z+RaIfbcG50x+2zShG5mm2MgvCPLUD7G25Yzx0cEqFNod7+Mg7h4R+bXbpvZ1KJJgTalqCmwKhXm80ORLscM227eDiw7EjboFc6u/LICpcCerdcnudAZgApO2Vjx7zIAIbA6+65xGuWxdDDRva6wFr0xfqBtIkbzOdmvoBVPErxlgJdsbKoZh1ZgfHm3roNl/S06bL4LZURhGyK7NLAumaEu1/dE7nbXVv+iSsqaTJjIRIdoaxuiFsAoZwqgpZl6mJwdPpRn5H8Hm9gxDt21PS9KhnmB8HYVsl11pUvP7KcswH4+6/36TvErE5jfyvkGbr74V4twDZRS6TIdCrX3Wvf+6lqqH3rL945wHjBpcYRRvmbNyotLaNK5C3wmGYXkpI/i0VpKtRTk/AHAT6nzkyw7x4mwVn1h/AxwUkGpTzwiN0u+0pt5DC9mZ8+8SVkeyBdq8kb9pG22+Jya09bus0utx+QFBaC3Pr0Hl6YDIer7fRdVE+CxqpVCbEaNe1AHF+wdGtQ9gtQ6A3YX/ACERxbghoomjP0Zz0KeZW9lV6uEgAFFu/suy0tfLtkPEA9xLta7hRQeF4QHJmsYVYcrv7AJAoLmoNNmOeWDBhHpc8CAWqpJJlx/3LbVSHPbWOX1EESImMVtGZmbNujJoffRTwFC+RnCJIB7VGVqu6j+ghHrMsypqHCfMh1Lzai50xhCdY5W6GRbWHAVPVZ8CJbcXUrqh4OPQgLEiigGQCNHnWdhYntuMtLWmXbFuP9/lkm8OE5nkr6jX+A0/FkJtGg+lA7dr+rUjqU438flJQR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62f48c69-9d95-42c1-3aab-08d9677b3c46 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:44.1252 (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: RoUYQAP8YKiUuvE1jHemGQLdo2PTtLA7yalbciS/rjmIjOIX1dbLYPSCQbroUlhLn+lfo8rdlW35EroSaY4P6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4511 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Z4RKmst5; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf06.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.94.83 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 89EB0801A89B X-Stat-Signature: c63ofh8nmcjpjwwnjck83kwmfcyfxb1g X-HE-Tag: 1629863325-703748 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: Ref counter from device pages is init to zero during memmap init zone. The first time a new device page is allocated to migrate data into it, its ref counter needs to be initialized to one. Signed-off-by: Alex Sierra --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index dab290a4d19d..47ee9a895cd2 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -220,7 +220,7 @@ svm_migrate_get_vram_page(struct svm_range *prange, unsigned long pfn) page = pfn_to_page(pfn); svm_range_bo_ref(prange->svm_bo); page->zone_device_data = prange->svm_bo; - get_page(page); + init_page_count(page); lock_page(page); } From patchwork Wed Aug 25 03:48:20 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: 12456323 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, 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 9867EC4338F for ; Wed, 25 Aug 2021 03:48:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 47F5D6103C for ; Wed, 25 Aug 2021 03:48:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 47F5D6103C 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 4B5836B0078; Tue, 24 Aug 2021 23:48:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4665A6B007B; Tue, 24 Aug 2021 23:48:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 305F26B007D; Tue, 24 Aug 2021 23:48:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id 167856B0078 for ; Tue, 24 Aug 2021 23:48:48 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B1C878249980 for ; Wed, 25 Aug 2021 03:48:47 +0000 (UTC) X-FDA: 78512221494.22.0579C50 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2089.outbound.protection.outlook.com [40.107.237.89]) by imf23.hostedemail.com (Postfix) with ESMTP id 572C390000B7 for ; Wed, 25 Aug 2021 03:48:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PZMpd4rgl0KXCAAyYmzjCI+n6EAS39WmezbyQ1AZaaTN4uITXoAcTvoSwu/DJWVNy+29cKJvbjyAbA2FkE3iJ7sWRIWiCglNpXCznxOC220xl4jKDkMth1PJ/kF0lG17YARtM2e7eOuc2St/fczoDah1j7RKiy1wYKZjc0KAIpq3hKZoamtwJYffaT0+hf8JG0zsXVIv9E9L7Wa/0+AqnvTawSq+5s4uEAfGAjRVTREBOA70wAvuPYMmMqfRi5UMw+RMSrxBpPwSj9S8yk/nFC04vZxjZuE0LtQHQ6DjuPmoDiGg4QWDz4gv9TF6qabOmxuiWaj/jblOR1wzYgTNNw== 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=KPRUxG7tsWqwxFr1dU65ZHijp00minGf5doPgxOlbi0=; b=AK/lbu4rEGWSae1mX5FHY/vg26+lu+/4uU5IyycDh4r+7h6d7d5sz2VV63ETHs9pSNitQ1UMNoMOJH/J9eYZOKrxPYhh7hcl+VFDvfDTf8dTOIhggAaDb9+a0AmzIXsobxdWyA/x9XAbcqqWPYJC6va6KSlJpyXUvMAP7VPzSd25Onz+hL3mz80ac6QFLylewMZxHDsjGr/otXyJHSxfwAykNgo3tQoqUzi2EcJww6CCK97LvzGb/dOVpR9gZsY6YslwOAjQEcuG4dQ3pOklx5KeE78OiYFGbPMncOKWWQPsZgQry2wadDxoQyLJbuckb1EbQ/7zmE0ulniCBhjNDQ== 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=KPRUxG7tsWqwxFr1dU65ZHijp00minGf5doPgxOlbi0=; b=AVY2QlNs8hW9u2ijZjqlfyoMtCKB0zmB6vvd0XlqX1PbOrXFPEC0qweOLxc+wOan199ALqdF/JYpFSKR4sDYUi6oWzei1Xjf/JQMd3svi3mlvRktZ/aKoNOV2RGvikzWAoUMLy1V98kfMp9IvGLiRpNFODG96jurIocSuBJBxqA= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:45 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:45 +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 v1 06/14] drm/amdkfd: add SPM support for SVM Date: Tue, 24 Aug 2021 22:48:20 -0500 Message-Id: <20210825034828.12927-7-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78952a3f-647f-46ef-5800-08d9677b3cf9 X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: 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: uv0opxK7utGT4jsfZ/aFThVWwEtHI6OKBCtVymX002hYq6bkTM4KzJqeXLSWBPfzykA6zQ16wX9jOnCLz2AGhodGlSLotESfhjJfVN2mF4LPRjygl6rCIT9NJ6i/ipPAtfgCledRaY7YMi/QPxmCsDLU/Il1j01cBhda5IF6yx04zjii08a7xTzoIq+vQLk3vcgMZ7XsxPLDj1hozXNtecdjYuKiD9BP0PYh1ke0Nju7OW1mkKbayMbvjIBvEFANijSfbFzZofB7CRh47v1XkY5kT5J9u4TXexXdUe1tdQQNxdMngCUBXOMFc9AM7pxcTFFt2/r84SL4Us0JaQqmCXpKjozgQEIfvr/1iRh9XkU2XticNIrrehlQ9f+7As6wWGCIJCD7SxhtF0btGc3Z+ZTWdll5rNmFVVC2hp2wABm0Ru70/P6SS6WctvewGX4KLEKPgzo6EnGrU1UbUh8+XechxA7oUb933yRW9wpAH5e67jZhYqx5PLhw5ezzqAMz+UaBeLQp6UbnonrFki1h0jWziyX/u9UoInAndTT7KmOa9epFKSihNFa/2+mf81ePNfLXNxZXi44BswxZBpcevHIpw8fAwuOlJMlsRmZRU1dGuee4yevL/TlNUwuqIjwOPDKAhHFy2WAvtNLIDxvWoL/uB2pPo2rymwL4YlrEzf5WIoYGyxt2AWwbRHE1/KVRUPNdsTRbMCR4sRIAvqJoyg== 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sY01+sCG6RGFaXDkx/uH5UoNYH8CLyi4tyt5/ZBHOIUMM5sKEOUTM4uQDmBQr0tapLevWnXChZeXMXL1xjh6g0i8mthF+qgDKGE8QD7h7e5V9z0ZwKUNmnMIFfzMj8LBgJDvDVhyGiVImpBm2M6+JhzsiFYm3RdlLzi/siAuVaqy3YA+urCz1E8GsyGbdd6L+aknRCV3H+p+zM5DpysiUBu5b06VHzyXJXMdp1EROBucgApVpUZEbMYTDKS0GFTKrOyUhQRKP+lhXjh9UzuJ0hPV4tnFRhv+SY4H9EvNospmRgFgOMWSaYqyRRS/xYJ0eh4eO23MQSpsUdB8sp3O3KVzvzrk5LxMs/jJlSl9lgenDa9A3bccJlgqBHr8OzqSdl5ZKwIWa8RSrldTjwd5tq7DyHEUxQ6b+RfsIMsnXmbFPsq9IHyVKJatSeQstAmruEuVkZRdMIyMSqCTMLnrR+9LjYEdwnppZKfhq+AQ9l2xX+NhDf/7pqh7KcGgpBxdwRvo61dwBogVtDaXomOMfyy7SPih24bFxyoOsWxDMJsf2cwnGdMQp8Gzk9WMEt61Z4llHJYjSq9PRl7A0h3/3RcNu/X7kYpT44P61hMLcxPolNlchCIEu+pKWOmYiG5YEbmaKrF+PhHV9DyGJ4U+toTxPP3DK4fLXfgBZtElyRyzU4ZhXqX2bMPFt71Uka7NbHVrFTsCmTEec6Sw9cec9WoI1pDbohm8jEjWKYPTSqEtq8l97Jg/6suSNthuMGBtZnfv5FjjYjpvk2ViAynnF9mKrrq4OlIZIcWuVichmqaL18zSgINFDsVKfdV5xZO3Bfv7OtThSuSJziWfHb87HdbdHBEOh5PZ2vqOFRjCdW0+I2kkY+0PNLQvxz50UlqrGMZRzYv7wdL+WpNw7pUNvmeqmqA7kzrVYzvwIKLqFcBOUx0c2BXg9JT8hJ9MscswT55raBYrITM3p637d00z065i8qO+AyiZswDGU+pKPDVbirHjQzxCKgsULiDdVI2X6CxWPqxCk5NoOBEee3sKoYtNEdzXDQNpn5Hk2vWRK2JtJKBVuT9ITCT4p1nk1dWkmVSH7u46v37MhIRpHA76wUHSa3p3CzlcAf2i84oRp9oN6Ns/zKg67KmEgFS5gorURQc872oaRoMuZ0vDa5V4Q1TZP3J6tgC347DB4RM0d6vBIw8iehsMpK9WnIPrEzZkY1KOYzdAqFRKpnIqzhhj/qAXA9Gd1P6bxvl8jfqQiQeoN1+7s4uEOAVgVKrclAwHEi0mxoLBq+OEcnm8rlUzcC0Z8sH7yZeNPjvXWXpu6ZE/mPQthS2ZkhFC9neCmg5T X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78952a3f-647f-46ef-5800-08d9677b3cf9 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:45.3647 (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: QsxScR9YWkhESqAW23pCsBnmqSYYD5J7RqeTU+k2Zz7JfhCFtuEC9pu4NiXWg2A7F5AOWqDG0wVk7PdZwG089A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=AVY2QlNs; spf=pass (imf23.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.237.89 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Stat-Signature: ax9rge7yfh4hwz1nutmrf9k9phy7ms8g X-Rspamd-Queue-Id: 572C390000B7 X-Rspamd-Server: rspam04 X-HE-Tag: 1629863327-363153 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_PUBLIC to create the device page map region. Signed-off-by: Alex Sierra Reviewed-by: Felix Kuehling --- v7: Remove lookup_resource call, so export symbol for this function is not longer required. Patch dropped "kernel: resource: lookup_resource as exported symbol" --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index 47ee9a895cd2..dd245699479f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -865,7 +865,7 @@ int svm_migrate_init(struct amdgpu_device *adev) { struct kfd_dev *kfddev = adev->kfd.dev; struct dev_pagemap *pgmap; - struct resource *res; + struct resource *res = NULL; unsigned long size; void *r; @@ -880,19 +880,25 @@ 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 (IS_ERR(res)) - return -ENOMEM; + if (adev->gmc.xgmi.connected_to_cpu) { + pgmap->range.start = adev->gmc.aper_base; + pgmap->range.end = adev->gmc.aper_base + adev->gmc.aper_size - 1; + pgmap->type = MEMORY_DEVICE_PUBLIC; + } else { + res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); + if (IS_ERR(res)) + return -ENOMEM; + pgmap->range.start = res->start; + pgmap->range.end = res->end; + pgmap->type = MEMORY_DEVICE_PRIVATE; + } - pgmap->type = MEMORY_DEVICE_PRIVATE; pgmap->nr_range = 1; - pgmap->range.start = res->start; - pgmap->range.end = res->end; 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)) { + if (res && IS_ERR(r)) { pr_err("failed to register HMM device memory\n"); devm_release_mem_region(adev->dev, res->start, res->end - res->start + 1); @@ -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 Wed Aug 25 03:48:21 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: 12456325 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, 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 8ABB5C432BE for ; Wed, 25 Aug 2021 03:49:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 36D706103C for ; Wed, 25 Aug 2021 03:49:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 36D706103C 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 CCBFA6B007D; Tue, 24 Aug 2021 23:48:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7DC66B0080; Tue, 24 Aug 2021 23:48:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACE2B6B007E; Tue, 24 Aug 2021 23:48:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id 947E56B007B for ; Tue, 24 Aug 2021 23:48:48 -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 3FEFE8249980 for ; Wed, 25 Aug 2021 03:48:48 +0000 (UTC) X-FDA: 78512221536.30.AFE984F Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2089.outbound.protection.outlook.com [40.107.237.89]) by imf23.hostedemail.com (Postfix) with ESMTP id CED0B90000B7 for ; Wed, 25 Aug 2021 03:48:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BJKdRnW1mtjVyZk+/YMIa+tXeS3xNcmYupfchjiEAgs0dZkWa8mznQC7k2N4Btm6fcvXxj4OVBhM/JdZ2KoikrL1nZTDO5H0l2m3gM8ZIXnucF2ImfNgi1RjtMmLxUiFJeEowncJUysPVn2gsg3HpfDvkmuoET9gyE0HsXEBIgfy1mHgx48neZsbcJn/HPbjctrMfRPC64Y1HbWizn4P9Gy/LWnPerby7wBNmMGY/fOeHBEIlVGNEdDnK8wzyLYjk8RfOpekjqdG+2LQCjn0sI/0utS4VTQM6OMgVIpCBIr/jtQXH545ppdlIFEp6CgviMOkuX4r6Rt8Lc8UjGh2sQ== 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=ytzilRdg7u/L1sYg4tCIUqF5v6yBkwXcMogVV+Xzdfc=; b=Ayj1tp8Q3qjxbA7dgZAoKx9gZlxmsOb3XZ5B9wYvhk9/2+TxhZr0TqxcBiy5kftjC0CEFBawQ7QTvw34VZVlIgmjoxHTRUazRCI6Qj4VHvWdPdWMhvfKm17WguiMD3NP8//wIeWUV3AtwOG657Mkgaw3Hl/IjpyuuufZqFAf55qR6Cnz+HbSNy0LGm5pzmfPvEjmOVeBiTML8/P1RK5jMcxriulCClOvdI5KNCb8fpeHWIL79dWDNRtgtF65KXzizQ2BlKkEEWiDYnVqF26qxEiz2+s/KotAwTixiCAY4AKu8rFTnvl8av3VED/uQ/MdYzb3Ggr/D8p/9Yqq/yt+XA== 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=ytzilRdg7u/L1sYg4tCIUqF5v6yBkwXcMogVV+Xzdfc=; b=KdTvO8EVsVeu4CKU+dj0zEOHQYPQWfBMCvECX5xNEsPNsST+vRov+yM4CjS/A0l0p8zsjDnjFtZX/cbX+VGYsNAAVUN60+Np3K+QWfKZ0tiNg+LqDO0Zy4bgMa2431x8gfmdDmQaxTJ8C5pkc+/+lmc8XIj4YelwsDziI1mhB7g= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:46 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:46 +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 v1 07/14] drm/amdkfd: public type as sys mem on migration to ram Date: Tue, 24 Aug 2021 22:48:21 -0500 Message-Id: <20210825034828.12927-8-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 08e08265-d84a-4eb0-843e-08d9677b3d89 X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: 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: F6whwGGh7uAC8OY67KKSenLN8OyQa0ZuD2qkW5AewbQb9SkGhMoHKUNod4SXPNcwiNcihv2Q3aPnUPP4kqCb/nagChytmu2spxWVLDofoNNg02wZ5WdIMw5aj8pCk3MyztGK0vvmMZ4iaM77lo9omyKYSC3WB9p4ktt2b7nZDHqSRAIidN0D62PnXYTJfenF9qvgikWexUGcd/cT/XwKEp+OvC0qo2NTEdnFrU73IS/OsLa14q55EG53yhI7N9vXHDGrVpMTWl1OKKUq9nDKSbVeK+h2nhLa1vwTGPhLLdgKIqpD4zoJpCDe2EFDkT2tdLICX9BmNKDW0CPW+ccUg8HtfuQv7OMjwx5pfp0kN8rneiNqZCBZzJA5tYVAa7HWf6z5x/p9Xd9gYsX5U+uLvLMSgI//XGqU6LUNYjOSKQeZzA4xUeKLadRcbgc5bUEOAk8qKRQEvAfs99Vcs40sh3mPNQjjgBnYSquevnkQFetCzHmcYeUyU4nL17/kal4lWf1VIMs7KMyIhYLvMmsqSgD2K3gQXBEWmi5IM/85+Q6eSI2Ag+iqDr8G01U8gh/8WgU7oHWgZ1UMLnFdzN0IMLXpM1HvmAyFjubZvyV0BeHFOkR2k+tpQYyUrcwz4zE9bxL370beTCN6gAs0sc306e7GIGST3wR2I8GC6cyT/XMqyasTsiIcGUlqxtnPB4bz8dNjMcpmGID09l0wgCf1QQ== 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GTEmg6nbEV/cdmN4opTvmbsXSSDqbaqcIaU5O5AY6Ph3xHdLIzgynOZeNK0InIRK+ZEGIrsvB4BItoywcfi8yHvEukpuP4TGeowEcUAVI62xhTAv13vOmduCdfWJDn26J9ByxPb4yKQBbGHiheQ8RNmOUfJWcmAp/ELFtn0NmHhQ0ZCq2P6Rh8637DtkeVD1M52jOXpp0/syrLxpyy+kNfPQrpmhe8DU2sx9o1WmwS0HQiVUqeuJQ0HYEk10VbRl2uyw6KX/19OD03rlFfmoOu1JZtj3h1TE6bvkohysA6ip0DvdYb+Ni8VM/Hv44qpz9dvOZMP0raD4vva2y/e9mBFxae6ci9kPTzJEL4QHFmf2onqI5uoUZ1F2jdN3v5jmMU8RZL+J5ILV1qb9ikdCGt68ImnXDUp5Kbu/EoZLrEPxMvblbGCrP7JoNdeMEJcJtw1NSg9kwdK78/4yhg2SKMNrOpr/DWJiq7EUBadVZ/Q2IqDK1hL/ob8xPVL7MF7V9tzPtJJ6e2UyMU+Agx35Pp4mi5nKabpXvMiPXCXsF/umpcT2sJn5F6k6Pk48s1fZ2x1zIKbkMMuNODTYl9Ppv6wwT4d1rBDL46y06vXAqi5gBYKoyOxKcdGNDIGtjIkvIaLWKVUCrwXJc8llHr2JwwWnMSvQ22dHVPhajB1HlmGoL91cqUHXs7M+yoyPfA0fS7yKxPvAr4HbMybpPHh+4micMbVAEpmyXO95i/ewG893fUYrTrsTcdTTWkXQvBuWAXn0zB7shtevookBdS3B6+zyx9Zc36GE1SaoPMRcc3MSl4FicOluLN70kU4SlfiabeS/pyZWQaNLhf4Ht/N9lPMAUERYQKiTBNbg30iK6pREpuICKqmyVRL2uiQgqZuM+IIuK30kc/B4dCJr67nBWURQ8k+0dqOj6szWrkQGqpnig+nSLHGVsTMaK+i1cyjjI3eJ6NT9ngB2DtxF4K5PNgvfzUC7odsRkj91SYEYWYZI8VbxVqvQHMKKVBmogpwo66PhhSrhz1L6Bg6selt+IOQ54P1uzQAs7kmLo/j9pATtbuIqDG1i4dmMa0nthumNja6+/HH3GG6LWO2qPImLYrvIK/ctU/wN/Jtov4MgquTYba0/0/6UUIkXwXrm7pAd6z2LEuglcZbBwx80iWUbSBCbcvUovmYR68hpprdRno7AdfUJA+GGJZpg49hmRcgUyXi91Y6Mo4eE0NYacaPf0u890gDd0iVSwA5KuhcP57gt3UebyKz2DnCjBbF9Gt9GvNUHYc43MirJnzPx/UUNqb9s5RKhVj4NpsDg8XusmkWo73W61zEgXEuaUI+nB86r X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08e08265-d84a-4eb0-843e-08d9677b3d89 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:46.3524 (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: RtVSp/4/NpTc2uoswF+JliVzYRO+vzMYOpZSDWKTgGA6gtym6CxILecxqktYEsSCeEr3Ac+SImMulo9lRFoxgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=KdTvO8EV; spf=pass (imf23.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.237.89 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Stat-Signature: 9kwiiitzdogbqfmdsunpbo9615foqi6h X-Rspamd-Queue-Id: CED0B90000B7 X-Rspamd-Server: rspam04 X-HE-Tag: 1629863327-300884 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: Public 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 Public type case, should be set as IOMEM. 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 dd245699479f..618035dffc64 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_IOMEM; + 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 Wed Aug 25 03:48:22 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: 12456327 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, 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 7DB47C4338F for ; Wed, 25 Aug 2021 03:49:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A6E26128A for ; Wed, 25 Aug 2021 03:49:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2A6E26128A 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 7EA036B0080; Tue, 24 Aug 2021 23:48:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 773CE6B0081; Tue, 24 Aug 2021 23:48:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C53C8D0001; Tue, 24 Aug 2021 23:48:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 40FCA6B0080 for ; Tue, 24 Aug 2021 23:48:50 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DCC861802F641 for ; Wed, 25 Aug 2021 03:48:49 +0000 (UTC) X-FDA: 78512221578.22.3A09724 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2088.outbound.protection.outlook.com [40.107.237.88]) by imf26.hostedemail.com (Postfix) with ESMTP id 772F220019C4 for ; Wed, 25 Aug 2021 03:48:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aPHAJpxyS9TpVw+Y28l/DEgd09I/24emCwZuBJ7kOi6AfSArvmxsgkDnBmC87075/DrN6FRWIRYcYyhdGOrFBMWrK4Wzqdm3lTBnGFNU9wDdWWLBw/BlMMe1YqQL6k/niQfwB5ZpOYSe1vECibKq4Ap6xbFEtjVqsBwqoKYhNq97lzrbFm/M0B897EWjROAvQ+aPI4TPi6KfrK0tnNuuUV8IINK3wE431g/LC9alHBknaJeB7qCOtLULKtRUr78med7OgRbu4JC7Z87vtVVbFwiY/x1ONo6aFNc7L7/3XB0rLoSt5zKxDDlwF8Fk/nRJHeoALIgREF36S1XYOZdl+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=fQPvpQvAObOGLCrtDQx0fOMFpE3uCAqzCz3ILT9YB9U=; b=JRFSqk3LrFbuiqtOdSL8xJwXZOkd9g5OlO6QcOwms8Pq1gRGrZjVBMAWd7d22llGEnuA4S1vUdem/8Yif0jPb1vbOlZaPrNCtxt7k+q5rekoY1oiGJM76DSCAZOsJE2kqVE/ThAz7+jHO5A2aZLrIGjBIAXLPTLMgT1L/9FwPA6nZiCwtW27qqdOddrI+jjA+e8GOaLGSQSjydWSLfzK695YZY8Eqe043Q7NMCH6ImxRgPNnH6ycqiCfEXKLebMGNFVKKU6M9fw6NZH98F0pLu752SIbTOuPU/a0kDj4bOV44Iq2AUZ1bqY2CfxO8PtihKH2TGUr86c4r9Yih9MATA== 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=fQPvpQvAObOGLCrtDQx0fOMFpE3uCAqzCz3ILT9YB9U=; b=5rN2fBtCW5CJVHiLsZZ6pg0o3xTu70o9VR3zIUgKp2nrXBwD02am6y8+LVMDBfIP2CWyorPvZfdLqfi6foeyIFQmZt/f2BfdyNdB+wgt7LL4nC1sxuaSuNBHOsVY3dIy+gteqFsEJAmF5sDOjoNxKk9l2Eec9MszRnUlSiQsgTU= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:47 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:47 +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 v1 08/14] mm: add public type support to migrate_vma helpers Date: Tue, 24 Aug 2021 22:48:22 -0500 Message-Id: <20210825034828.12927-9-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5748ab7-2501-4ccf-06ee-08d9677b3e54 X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rcNwhrv4/LP8IA/DLTBeV8NEdhuvukhyW2wxGldaStA9i03F+7rbUPvC6cq854wk3DARTIxg10aLeQWVnmhfUkzQvLXjbPMdvIs7y3Y2hbKpKL74sBaz8Juz/NQsCaQhDBaQintOXeOA66UycAL/oEIvNEHNnKb3YJioccSOYEjvGd+0ckvce6+1CSb1YVPxQhoe5s425MZyrK0N80MU1mygscNDNPvFcZKk83Y3DHK0Tq0l/WgLVwCO0eK1bpX/Sh47dnmLcripnNFhslEWZVQ4xp6tW3DACQgiCxuVHmAil6r0yRwXlNaBJFNi6oYo+WW9iRU9XWA2Za5PfqokfHKV6PbKqyxtGwSm4uObVBg59Ep6o7K4XOoJxRHsUgdKQIIBuVU7McuoE6WNZsmRlBEZoxXcKJTpifUL0dqNZxLoLgPCpqfB9OD+haFhxR+11kVdU201+7NuO4v+S79KG3omPt01eBzTfRGfmq52Q4JS6WroK4HipNdZiJ+0qT1hY3tfdESJQ/VyKBmIcT7c6vcK9zc3ppAkYzIcGQVNfBQLgPkxzNjZiNzvRoIngbxLNNFGjunevH6KwhniHtrQ1jji7S5iYyJ2ZotzkwQ0Q5/SRZRJ3BS/C/C6oo5vZQ2riVLU6nDXo4UVRx/TOsnLnc4kmwwm+m7dzx32SQvaitQxdcTwU5FPwK8PywtmZDyk6OCGQcDu5TZT9jwoVcwJ4Q== 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z4fMhxm5LHLWFxzNY4km6Wgd0UtfKbsE5+SmMO1K0knqKZAWs2tJA4yqu6+aZ8HfRYxclWvwvQczL4xb1ZfQhn13ZbvUUm2BKUlo7GAwin6V2KtWqeFE5feGNAocfU3xRh+8avc1CEMd3jr0gXFQHHJlcBuxF0IHeeJZ3KXPFeBHBWah41zCiSAdKQ6jZ9XE3z+LHEYxIQr9FJ6RNICJbsaoB/yiMfNsNLu6g+VnVjMXr3v7EhV79zhlDeuBrbqSQeAb59nfgLtHidVZNXuJFQqgQ3sU5b6En/lLWzyG+dk9A87sraqA7zZsMKC8YbUdgaKRuABzq+3xzfe4t6/fACWmwDXFGxVlOJF+bRz4tT+Omr94QS2tcNDZ3LwDIBHa97Vv0NK4ArTNdhqfXNlbu+ZAwqdLueilSMW8Zsb2nzb2uIx+nYHKzu+sDcBGLOTTfywUuvMmTLCUZwPEdmbc+7UfdGpargZLK0BddzfQu7qjSVNcXy8FOD4h3CSUpYoJydEhpfXn4QknkSyg7YQ+eFFc8nMcq31hyxN+whzme8i2mPsTTWQYwx84zzy0PailYqNtaIOUmLWn6ZFNwDBGc9vOJ7yZY8WhX+jUwtc87Qq8rpzwIIVFCrd85iU3R2vVlTrxkRf0GGyBEirEtuc7MNRpmoFjI1RZsbajBUj8zwNU2pc+XCiJ21YLGHIQBbfC6/5xyJi7USd9rkVciP+GmS/K8PD+tfEQzdIJvj7I5ah6oX3ivaIBO0oj3oDeL3J1UDZ5jMnudThDeGj9wHANY/YATypjCrLXC2t8y7wIERptevYjo7/na51Mo00eC4jGmst7Qz5hYkwBymw3OzXnCbKXrBcPbXg1x+h3dKWf4chPir9tAOJDGD8SyLnuEMLy5pRqr9Zazrwvw+4L6oguMShoMaRDAnNG5qTbZBdWm0duxY3z5u5RToCYMUvrEsLfz2o0CeKV8DSmDLlSfe82fWTBSIvpzspINhFN3vGVGqE6yyU4QuyIb1ZTafAdrrqMC0hg5wrS8TksIb5m65mxmKdNKirkQMSBxfQYe6x1K3tsYZldc4q9riyWQCW1bewbevXr/zjkG9ULeBaGkJEet9jhQfqkoHGB5YzsfUE0TymjRrb6Mq7HDBiCfdbEgewhz7C99/4ge2S/pwLUYEfeOkazWaeGa1YF2SXAnVkafRxZf0ASJg/uOcAF3hIKzMI32+W+O/e6ZdVWBNWqZfgkbeG0LsTWrcqgn30CIzKXE9M18sonyGL5NPpNrnYxrE8fNwQbowQ+muAKqzDxXDiZDMe1L9V9AOHeBGerZYl1xNxv3aw1NoeuH8kqn5XgJbEm X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5748ab7-2501-4ccf-06ee-08d9677b3e54 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:47.6556 (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: NjH6x6ZH6K/pUzLL6sGRR9GpWT2bWjcySxTlCltq82dIbptInGVw7Je899WssbSf2QeN2/h+Eayu2HNmXAUL2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=5rN2fBtC; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.237.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 772F220019C4 X-Stat-Signature: rapod9u51d4jq3pdhpqc6idjgi1dbfo5 X-HE-Tag: 1629863329-434492 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 device public type case to migrate_vma_insert_page, migrate_vma_pages and migrate_vma_check_page helpers. Signed-off-by: Alex Sierra --- mm/migrate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index d4ae2da99607..09817aded633 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2566,7 +2566,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 */ @@ -2855,7 +2855,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 public page. */ static void migrate_vma_insert_page(struct migrate_vma *migrate, unsigned long addr, @@ -2926,10 +2926,15 @@ 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 = pte_mkold(mk_pte(page, + READ_ONCE(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 public types + * for device zone memory. */ pr_warn_once("Unsupported ZONE_DEVICE page type.\n"); goto abort; @@ -3035,10 +3040,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 public + * anonymous when migrating to device memory. */ if (mapping) { migrate->src[i] &= ~MIGRATE_PFN_MIGRATE; From patchwork Wed Aug 25 03:48:23 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: 12456329 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, 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 32FB4C432BE for ; Wed, 25 Aug 2021 03:49:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB2556103C for ; Wed, 25 Aug 2021 03:49:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB2556103C 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 D67FC6B0081; Tue, 24 Aug 2021 23:48:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC9636B0082; Tue, 24 Aug 2021 23:48:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B43878D0001; Tue, 24 Aug 2021 23:48:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id 9A61C6B0082 for ; Tue, 24 Aug 2021 23:48:50 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 501768249980 for ; Wed, 25 Aug 2021 03:48:50 +0000 (UTC) X-FDA: 78512221620.08.D467B7C Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2088.outbound.protection.outlook.com [40.107.237.88]) by imf26.hostedemail.com (Postfix) with ESMTP id 06F6A20019C4 for ; Wed, 25 Aug 2021 03:48:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZhPaDGX5Cea/oUtn0F7k9hH2r48Xr1+c4dTapomHIL+sFk00Uqwtx2tiJlSu+z6azfSgWCS1J05nwrTzdvzh0l+/HlV5OeHpYA4xiW0TjOeX8QVNPuQBoydAqUebhjSCMjgDFhbpQhScupO5WrDbRZFDQgC6HyQ9S7cwviWskFT8Q5QAGfR5F7kAxq/3rOy5ad9jYA+AZKDEo6xDrNS9Ms1ZP/I20dv5GyX/5diUmyH8mGbs8LB2V6UOPuO7cj0Nura/AOmx07o8WF1zCEwtVrsHpe3XpbosRmvXrS0PwUaW8HG4ZFIlRpFj3kw2wN5YGTKJ00a2V/rb36/4SMsRzg== 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=BIi/JPdMEuV9PNEmF+4MUIlbfqIvI8LucDuxAdl7G80=; b=f0TNPMUIH2IvI9ZawjVRNva8lNCFj7qDOP4f3LmzNI9tpmdRzLC/r64DKoZ+Oz8E4zrILE0BxZ+buMZIb0v39EJWKP3gC5vFYpMxjsb4JGOrFAy0upWO+gtWSsN+CxPfAESl8noauz2ppWRo0r3RQ44nuaR780zNulnZKkkzpg9vYMC+y8HKODSnO3eEIEI9IPlYKR+a1mNLaPBPcjO6njiI0SnUpMAdoLZp/c59TYcA+CQZGF9bSYnls0Rtjq6Gi3PYitcz3XpDVMFbVeUuMNo568dO9BFSVtqoe8Ard7ONO9X2lNGaNXZb9Pv1EChXOUeedRrRzOQPfdpUio0qtw== 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=BIi/JPdMEuV9PNEmF+4MUIlbfqIvI8LucDuxAdl7G80=; b=zBS0Fd9Gzn+gImfP7nY5MqyUt0ccnXHWrC4T7kLar5UhYeqC0wJabczkbr8Md5dzUngu8HV7We+MLBrTwpwIHNsFFEtAq6kuyjEwJGOuxqeawyrad1rPtkqDys0dVOG3vxyV/tI0LMhuTwOTFVPvy99nL9umfWHrwqViqXKe17k= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:48 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:48 +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 v1 09/14] mm: call pgmap->ops->page_free for DEVICE_PUBLIC pages Date: Tue, 24 Aug 2021 22:48:23 -0500 Message-Id: <20210825034828.12927-10-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07e13742-1283-49ac-c7e5-08d9677b3eda X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: 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: IOzwYaUoFGa/UVAmWj4Y20MDKxcOKors/9tug9DIslOFhb0aPWWFVlrvjXwyhbcXJEf4hBpQTG7Bj+SqV/i0qhEv0jgDRfbuMYMkQpbE74WoZf9nVEPd52Z0u0076RIQ/R2PprEEzvB40dRNaWpjw2ZBkLzclRCvf08OsA/1eekfROxlYj9SMgFjfVnABugajy14ZQZ7f2U2uYB3BFYdGYQnRF4jwKZDBWbTEmTDMvv+xRLJLM+4wp8JqamLQcmTZndViI7kDuzsQwh4p0ovolNibSrMBAAGsb0sl4VsHTiG7qjbtN6NOeQxgUjbOOgIkxy5+iA+CftFyZys2xg4ZaHVtVIn1y/kCxUVylUlbIbjJbeV72/kdwNZSvsd1YCn9r/D4l2Uc0OAaawIDku11Y/gDah8kHz8MRmSdTYFSY7DOiKBHYWHBP6emGtpazK+QMk5nu5jHdP//6ah+6a9jmG/dshKC45az8Zh7yTSnmlxm9AL1is96nkwPrPuvyFAGhbCeW1b51b1gTD1GhosZcPFXYZtZ8qdCheH8rAWzxZ3BDdB1hG142uk0baDC4F4BNiXErSMOfwxKM01vjhRRIYVlmD9fGHmo7lEdoujDLtgtkZH0trMIeII8IdkXY+4ezqjGm4Zl3jU5/9KE7+6LuUl8gjgeMgC3ynwrz8Guf13ZYrjzgJ5I/ZPEnhuelCJComzrxfBlqRW1w4Txca53w== 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zM+l6m9ewFv9GDdKrr4FzY9egveAXoCrmBAs400kxk8bndNvhI9+Ay+aXVUIXqSPxKVRaDMgzQvIRiu/Ryey9GSMHHrmTghV195u6SAisyPS2uNHggZOHgeuKoa8lChJY7tQ+/E/fqsm0lFeDCwCqoq+KSawR9QKFR96JnbJj7KHawEPq0WP0YlE37/j2vCOwDhUQnfcRQnOUiv5a2EU6CPP8VsjKgcJhOfYjaOq6X67EVRLpGfOrQ4GdhtumbP9OMV4U1e27f82/eFR85sJpi9kXubkTk1ji3+p49eeRlnQY4IqErJ7re/2qFIZD5ECuxD152F8OYBnbGUNm0rP9JV/+jie0nCvUW+iFLpoAItkou3ZWRdWhig2O+L8h7OVtKaifAxgPxGwgeBZd6ZnRzkUQtNGCEVqfFCC28pJeQ8kKJTEZg9NJCqiPsDTiIdeGw7ZABRCU6yTL7+tXL9A0z9YVKOdGA4rEVSmtYJV2ehQYp5UFVsiaY8JNfKR3TzK1IkbwyUZyJzu/91kiHpMtRzm1SBoXaE4TDEvBt5Jt5oTIFJfbE7p+oIO4Kxw0bxRxYRLd9Cr9DbmrlxV1mTVovQDhZwGJCFRo37lmH2iYJzed5HjJevkmhMyByodsEafMuMCTe+rNx1yYJJlhw95qDWsfhIvc7W1RAt//ttlgXst13h/HnKnu1ftNOi1IuPFKl3iK26eqTVOkW4bT0tXJQppvDS+Jq3eKhVvzmWhXljn+cIncFxgKiMBaq3skWJJtIMjQtWjFz04BoZAGPHOpv0ryTIUVECC8mwem2/TJdf1Fk7eKZhcgp2SS7OKYFSK8+zKp3HXIoQEAPGUtzVRyaLC1h0Uwgkwpi+LNpOCBEFaWzMHCns81whmhm8P1JQONZxCDqKNV+1J8W1wFZR+RM2ciXSQDAA8gb9oJix4An7dNYFtaROTRpqwkgM5rtwvZdtJVHo/TKfhjf/8OvIBn22/8K+Bk473/E7oBNO/+0LIHe3Na/nZFoEDAvU1pKltN994WETlz4LwoweJoGT2RH3bU+g4RCyWHjkVp2TCrxMVMRYCmjxxF63lOGMTeK3zMqyrHI52a3qGqmRff6+C3RIbK2FAEPpCI84X3k2hSybyWZab7gxwaxY/02jYJvbd1fr8bWqwvm5DzjO0EPszm01DK8I2zNP0yUNBg4fyZbUoFzowqo5M8udRdmUcs5L6maS9meOfE1u9ShB668zm1aUiHjsCeZcuADkN9BMqAbmTbXXsoaQKW0z5omQ/34jpUjhSWHMC1FlA7DGXjEV1N3cGfmRFh5x245cjavIUVHNAsDg3veCoKHyDdGBg2S1z X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07e13742-1283-49ac-c7e5-08d9677b3eda X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:48.5119 (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: ZUi43sRiTWqOZ9Jk6uDKa68OxIZ5JLfrUFTKR0vyjLgI/uUDOOAkQGj9cDwiNv18GrV1QWfWGPDp/WkF2XdigQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=zBS0Fd9G; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.237.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 06F6A20019C4 X-Stat-Signature: 5xkzb1z9whr8c7nkztetwqmwtg1py3sh X-HE-Tag: 1629863329-74823 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_PUBLIC case to free_zone_device_page callback. Device public type memory case is now able to free its pages properly. Signed-off-by: Alex Sierra --- mm/memremap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 2c8898ed006f..b9a8ed089cc6 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -460,7 +460,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); @@ -494,13 +494,14 @@ static void free_device_private_page(struct page *page) void free_zone_device_page(struct page *page) { switch (page->pgmap->type) { + case MEMORY_DEVICE_PRIVATE: + case MEMORY_DEVICE_PUBLIC: + free_device_page(page); + return; 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; } From patchwork Wed Aug 25 03:48:24 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: 12456331 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, 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 8450CC4320A for ; Wed, 25 Aug 2021 03:49:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2D53E6128A for ; Wed, 25 Aug 2021 03:49:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2D53E6128A 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 79BC36B0082; Tue, 24 Aug 2021 23:48:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74BCA8D0001; Tue, 24 Aug 2021 23:48:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54FB36B0087; Tue, 24 Aug 2021 23:48:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 3717E6B0082 for ; Tue, 24 Aug 2021 23:48:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C872D2570A for ; Wed, 25 Aug 2021 03:48:50 +0000 (UTC) X-FDA: 78512221620.22.DFBD67B Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2088.outbound.protection.outlook.com [40.107.237.88]) by imf26.hostedemail.com (Postfix) with ESMTP id 6F7E220019C4 for ; Wed, 25 Aug 2021 03:48:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IB608qQQ2oHFXA41Piarh67jaRAxnVZITyPW8wRjcUkwagXwgiwB0IfN4pxv2TIOxaLd0E98w+ll9GhG0E1D5EsaFlOWiru2widxXgQ+t5EIJBizz2hqjqMFeLUr6ic+Cnu5ppmTsKN8KAgV+CZl2GwBcaBZoJuHQ+r7h/jPNoa5IxL3zUE2nGA6LAAJKNYorN0mJ2wa3q3U/dZW/17r/odbr1J0Qp/6ZAPSO3h4Z0zzEeXxunUSYN28RfxHLhey+IiKIqzDFV4zwB7Uy+ZsVZLVfWpIyq5lG0unwUjrV6k8iIx+L7BPt2/E1gorNSTCCLUulJxxlHuEscN7LmeYFw== 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=dKC0SDJcXNMoavar9nuqOgDG5SsEzpi3aevSualtrlA=; b=lZIOsYZCU35u21/0BuOJ4CRscCWRl4T6Yzdvp1FvB5TXQS/huyW/4yaVdNFac7iTl49L+iPzf/0zQ6Y8yZEGncu1DEjfreosHZNtd5x7Fk8JRfa0kGhojRBCHvUVzmpYbqpL5TJRsP0hlW2v4cUJekNoGoOHuSEeBzIc75+ngv+/N10BQmGOB/oZ9y0sLXqVm1hxWU7bdHxBoiPWPsyAM6bEe1NwgduQP0Szk9YRGYgY68AacX4HEdDTHXEJgCtByO/11WBxpufHZ0hsIKHIOSYwwJkEwKXdaa+zIcUilnKn9xT4Q0qszEGElCRiDU4HQPtgK1KFsNl/LXyezF18zA== 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=dKC0SDJcXNMoavar9nuqOgDG5SsEzpi3aevSualtrlA=; b=kTKiZIyXqnP/D1MHpiS76QwPH882afenwMxQE8tOLPQm+iqWKEW1jrptYzX2YNaG/RhLP3HpNfltJC0/rS2EVvkD5wkAXs2kLyUSFizel6nyYkjUs+51damymApLnS+4lrHfSgTdtfafskVHVtf5YcMYFCg+TgBh9aEVbUnJP+g= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:49 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:49 +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 v1 10/14] lib: test_hmm add ioctl to get zone device type Date: Tue, 24 Aug 2021 22:48:24 -0500 Message-Id: <20210825034828.12927-11-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76d43493-cdcd-4104-03e8-08d9677b3f60 X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: 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: uZG1WW8EFQD1gmOKU3aPWLNOinci1PXViln1JQO1U3Iknq8blW2Y5DtlDsDxxRzyLrAH25L0i3cSg3RYu47Pa0oZjAypZoIIRVkXcXzcz5YfqZ81gKyTDu/QbMufZRYyngZ4oQPPaF6juxf1BB2EuzgFNdqECNg6nmftLKOW654z3V9N2i6gG4+q+IK4rUDYhUWR57anmlEN263N7JAQiUUNyHfLSETBCa9JZE7FpUNUyxB/Rq/S66fjSFS/ej5bFXfp+p28oWP7e15ikg9/21uBrvqbjtgANH961lWhDaQM+swprIc3N0+S1seU9goPwlSOUdiHBbn9t+kdmcfmP3Njrc3n/ydbkJyhyjfhztBCxbqbGjMNNjXQHR+Cm+kpL9TXM3eHwdzJdm0IpXPvkGi4AVd5KYhoKXpHi/+6hAXiV8B1zjQ8C26zeWt2r8Tq0oQfOOLhjOyDLXYUh/Tz5NTvcil3rLynbhT0TKzM2HJqJVCsLwTfrGRznHswYcJoSYB72PeHmkkfKquiTY5pJ32GqR8MpObwfDO3OiLaPztdOj2s5E8og5O22hBg9/eDychg1wGtxv0z98aIcelGfIvhYpDBxU/dfZy+Vxro2XhjMeAZ8iCMrzJafpMrKEnI95NUngeqbbuiTiskKwkTfnDYkWGuI+uco0wYCMnMi5dkPHAJvIwIGFFisL6SP+aT 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tXjEeyCvcC5jsUwzCM8YUBB/zI6M8yyhcZlrekQxjEZYBM+hif73/BIFy0eR2CjTgC/uyEIWbmS3chtJCN6c++GOM17sxXzSMuWVXbhvySMlKa38WLLDGTc+HXtjm8Us19KCuWViX91HbSVlEP95MC+DAFeAOinEgKewYH5PIVj4FlUqKn/M/5At1TfMD+rS5yu4iZRJri8LAoDUSZzXmd3+XiTnmQHl7bu2djtQV1WtEI2hS6IP7GcW/1/oFuxmfnLuM5eCiDvsTOAS9Y3uwrSRCZe7ZVV8qlFGXuEMYng0jtr5UDnN6uZBJjfOCgldRU7At+SqBz4Qf4CEllTdRXtGJr2EB4DTZ5ugWMiQ2gKNCk4wj4IQ/X0uNZQ+Low870LzGPAYbiAivEAYiwZq8/K+JqOcNzThw3NrBCMobdLsWJdcAYmLp6jG3BHttO2Z7tpzBXOJmRAZ01LajbFICYZNHE8MolPFcH22dsdUd+Q4R3Hb4i5Gm3U21Vn8FYCMIB2wDwe3j8qh8MHcTTd00Q09VN/DJoacTnI31LlQpQtaxhgXczmmXeZwWVfua/DJhDHRhhjS4oLp8qA8G/6tjDPb/mv0ObYrapvAqnCSeITe708U9ELC7ksHEZkA1nkFt+BC82l9OxKNvtP4JW8FCezSowfPVCro3Ay25vyq/o3EFOI017qLBbsPD4zSTNzSCBv7JBFaurzU39ibRK4iQJAWwMBAs346y5wImITFSNMCWCXON9wAmDFKe5xWQpYNWC9wMj1m/8vwZnabTUy0UbiZ/wlD6kEvFrQUcODUQfJ4bli8NmMuVpeeLbYg2Nykkokce5mmBXg8/l38z/DdQF86GLde7Kvv5Qm81hyQhhJETcJ3eeKj67c/0hIuhAmQeuWF8rrqYsi8DVS6Zx5/axcwDm3puzNWHk264wdpC5jyfRVkZuOo3OXchgKTjXOsvH3S9QXlf4wKynQgYXW4kwhKd85vYHQXiGwx5e4VwJaIZQxzd7w+acGEvWE9lGHEMKNpgM6zmwgUscH+QDcWFSIzzxmIbIslOHetO+aRtjFQp7VCfGsK9tVE5AjIL/PbQL03mo0+yYfN7jZAYXoPjSAQLmPeH8R3NsYC6FJad80nBut7l7SKlAFtRDZrynP2ZC+2hIhUoc2xvWerPMNXoUjfOZtaCE05mZOo5ZYvoJoJ1KPwv9hWAxnMe+d3TB3hvaCXMGsz5kk6QvTIjogmYgrGVwADOrw+WzIeD9fy+8/D2exMj6EOelknUTf4v3smQgd7t0zwiUsRnlXbtdj2zR2f1mCDBDLDQly98p3TUbia5wH1bDLeNHjmtW3HT2CT X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76d43493-cdcd-4104-03e8-08d9677b3f60 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:49.3213 (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: grfDI+SGhprsx2Ga6IW6YKQunPPrQiPSlF2xLECRybZrqWJMc10xrSiUnPeHbPaSFYBz3rmVeun7RLQ27wE4hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=kTKiZIyX; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.237.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6F7E220019C4 X-Stat-Signature: 9jcsgyof6a8c6yspocpijj7hckpmmhb5 X-HE-Tag: 1629863330-512330 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 public 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 Wed Aug 25 03:48:25 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: 12456347 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, 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 7FBA2C4338F for ; Wed, 25 Aug 2021 03:49:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 29A6E6115A for ; Wed, 25 Aug 2021 03:49:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 29A6E6115A 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 9E54F6B0085; Tue, 24 Aug 2021 23:48:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 995F06B0087; Tue, 24 Aug 2021 23:48:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E8F46B0088; Tue, 24 Aug 2021 23:48:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id 5F34E6B0085 for ; Tue, 24 Aug 2021 23:48:52 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 08269253DB for ; Wed, 25 Aug 2021 03:48:52 +0000 (UTC) X-FDA: 78512221704.10.7B287B9 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2059.outbound.protection.outlook.com [40.107.237.59]) by imf05.hostedemail.com (Postfix) with ESMTP id 97E1B5030FF1 for ; Wed, 25 Aug 2021 03:48:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m4rbjPhOhO30QgBWlpTSdzqAqaC0UjGAeptIul5KIH+LVTq/GxDhVTPP+uEsOr4WwJoG/3zxGpoCQN3X2j2EVQRLuuUrIGjCFWHBogt9lV8sun6LZcyw9iQhvXZ/UJhBHCcjQWAoMdJrCtrWPK4pFQhqcfwpAVSEl1DDi7INCOlunOSuMfh6/nzFntIh5hnYyf8R49Y0HEIgWVjxaEIdFGPcNVwcujCtZmA5O2tc0JGHDH4mtuR1W6OV4dhK3Ln1VI++wfVCryDM1o4EVwkdLv+tbCbTOZcb7fMRs5yGubWoX1W90g84SAogVNm6nVssrgcY8gjscqqhepFicIppcA== 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=Vezipz8HAGylYBhfg6EP5x9zGWoGwLSUmkbOu5ZdCTY=; b=mefmL70kroQBOKgF7lZ7yHMjQMXkc3X8DD83k6HfBfOyq7TPxlw4ynVCbGKxVfKdKpI6W9H/VSsyJilCbhJVJIKyReUjcAeS1r9DOd54UPgEdU/7ZlKlo1nUmFXtT+JZylMvsP28C0PRL8o9mP5nOrJiQf38GT0Aa23Xux70lR3K9Dzo13El7f2FDP9+Q4sEFK5x7xsXPvkQeRXIjWFSupwUwCC/9g++1ZKGZp2dc3WCKof257psH0Y13FKu4xeDmEu4D8MojNUeAzq1i+wypFHvVHP5VxeQloterCmcbWIztHJG6t1mVq7WbwXGh7CMk97nyR14k2Och8yxzrOSOw== 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=Vezipz8HAGylYBhfg6EP5x9zGWoGwLSUmkbOu5ZdCTY=; b=KUXeHjo7wtBAT+XeU+I1Hm4UrOnIwTGnx0ciaeqT6YJDK2AJjVb01zzAdraNDFUJpEi/6qov2DKXQBPj2IGxRGCUPj5WJpiStLr5HuoHIFnG2UWti6cXyYxyyftcS+nXXJfCJHn/G2z+tRq1EmJov/QjquPRPuQd8Nke1HT1n7Y= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:50 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:50 +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 v1 11/14] lib: test_hmm add module param for zone device type Date: Tue, 24 Aug 2021 22:48:25 -0500 Message-Id: <20210825034828.12927-12-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34be4cc8-c4cb-4f63-28d9-08d9677b3fda X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: 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: 7os4c1McGVINmDlnZXGOqMROqpRwJ5CxEoiU02/wSgq7tRU99Xo6++riJwYoJxy0u7TBAPrEFwdnnTiG5i1Z/Ajc2QqTXMHHESTykBRGuIh1H20skj4yL8HQEAqE49uJRCU9/Mz25WhxnN2SWSALirTDL4CuDF2eaMcE/pnYSQMC9FecRQbZZwN+9W8XaBlDJhshBTmcSLHXnNK6PhTJKq+kfpzD/Osuo6EY9vuOjZJj/+4dxsIDFIGF7OWUW4njUhAoOTrdJT46Nhi99tGnmDKDkkODpzRBq3SI4secAy6oKLCGK3kgic7WmBhY/N6/oyQpXBUDoVKh3FTGYNHyucjl6Ljr5r05XyfuWFlumD/Vcmai+6YKygqbfVaEMVg33EuKvL1CZ+sSQA0YpDykNjR3DhZMiCgS/178FflZo045gS2mlRhmtPlyvCIINzvBprMZEUVnu41hYNTDbLl0Z+sE9PKVGvNvqTj19Fz05/Y+ijmrZfkAkdwkdf6qOouzkCdMJADJX2u1UTWaBVTRyxWa2WrVA3ydomod4D+kf4RJ0QSgBpFy5hOljfln+HwzE+M68hsIminNIye2wneZlFD1MahMqVSN2d7g8Ak2HFOzijxmvKX5ANGNDBRVYRTxy3P0R9cnWbkj6HnA1YWGenf9XN637D0m48VAga392SLiD0oDvrehXrCceWaqQ04NaIYQNsiNriZ8+bdr1XX0SA== 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6jK+pEfFoBnCUHBHdphh+YbpIS9kT4edaN9ArwpAX9/CUxghlLvRueeP7/bS9MrUi++ICbOMIvRAE46IaP4ygHQK6MZzQE0RNhNUxFcru5xi49tCpbmQpFsI472g6WBgpsASVz4L7U8OZ0yjrjDqROonWmU4+7Mcl97DNWruB2qELKVU1MNkBgyFJldmx/dvq7b/iFYGPA+koauwiY3sGXaLXd5BS/BBQuWgC+d3kzeUWM+aKL4pf70+6WEVCsVGUrfAKvvK4Jj5WNTNv0LzqPLlGO4hQYpLtn32b3lEQCD9qYidaVe0VoTh0ywkfES8zNng1nbdrpDLFUFdqCT+WSmYNuzYE3slcr5eR8zBIROs+7/S0DuIDScTEqtJTdLtlpZ60KT9mkr5M23kBvMPwPyrYjr995RsL8iH5U6KOeGKSn4FixWdWeS4U7NmR1acJ/Rz6rmQ+XohZm3x0xrn8ZAr7TcBpe4jgQqrfVBphSuSuV9FjugvkwzH/uFxCC7PONbCw1AWOf4F+VgRH76Tx457s0NDyb9+hZuGYtcvLMJs2xbYL00Atkw7SVu/dtjcU5WLeKYUV814tAzO4rT2OqeBwG/W4VqXa37oYgMbviah/TON5wuTnLyGbWBbs0bq3IzgrtZTpNX+IxDMnAAOYqULXYyaq8BP//tz02sqR0K+qQGcDffckvP37Wyk4wJzuD/1XOZBp9K5bAt+0NSsknGoWMyxeIKe3vPbUbt/kn8Lin9Cx3AtxZEgotU+NLZqxE9aUEUzy40RTZ1N6QsWVVnQsrwDrGx+icvJK2PYcxeo7UB0y7xB7a1drZJSpKZEPlew5EYEnvQftwQLUoLs2KDgFmEEU9EMb04QXbgEIK5AgfooZiPXv2YoObVb4b9BFHgp6z5TgUyGtMVQaUWeRoY+w3vEv7PPDNcD+KM3quZ2W/+XxczdiJCT30gqjWrTbhhj1/TV6uySfa3mWTOOgvidlO8AMJxXz05O29aBu4fa+3HyPVbkGsl/9KbwR+jmb/6FfANPkBpO3FFqgyq+upuLaW7A+6GEHWKARWnUMtMgJ//QQXSL+M/LIAGKTFBh1dZaoKtdxTVeofmK57OWeGAxylToCk5j0X8i2vAKe/LHlQQrb4OjwT2U8CAm0RxRte55MHRpmFs+utihjF/AB2FIjZHSip1jn5kEQKAmK3n5s+agg/+rdtQMJauJLIMcmPK9uiF9fyWssYNCSkilQKaf8k5wD1dU0g4zXPgVduJxKRBKL1C39NTaOtT7KQoMgfzrKApvGGdLm5URp15EvldSi27A2ENeDFg1fxoa4/23D9CP7albe+bnMDGzcDI8 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34be4cc8-c4cb-4f63-28d9-08d9677b3fda X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:50.0750 (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: 0jZEKm+z6RU9McCZRsps8GtZkKept7rw64B7NLot3lZoBXpu7eogJjdKyyj0QTI+8Bvb6yJtIeohrJ0f1Nkt1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=KUXeHjo7; spf=pass (imf05.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.237.59 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 97E1B5030FF1 X-Stat-Signature: yngkebop84pzcfxfmfyrdzqz8yo6od31 X-HE-Tag: 1629863331-809864 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 public in test_hmm, two module parameters should be passed, which correspond 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. Signed-off-by: Alex Sierra --- 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 v7: Due to patch dropped from these patch series "kernel: resource: lookup_resource as exported symbol", lookup_resource was not longer a callable function. This was used in public device configuration, to get start and end addresses, to create pgmap->range struct. This information is now taken directly from the spm_addr_devX parameters and the fixed size DEVMEM_CHUNK_SIZE. --- lib/test_hmm.c | 66 +++++++++++++++++++++++++++++++-------------- lib/test_hmm_uapi.h | 1 + 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 3cd91ca31dd7..ef27e355738a 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,17 +472,29 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, devmem = kzalloc(sizeof(*devmem), GFP_KERNEL); if (!devmem) - return false; + return -ENOMEM; - res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE, - "hmm_dmirror"); - if (IS_ERR(res)) - goto err_devmem; + if (!spm_addr_dev0 && !spm_addr_dev1) { + res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE, + "hmm_dmirror"); + if (IS_ERR_OR_NULL(res)) + goto err_devmem; + devmem->pagemap.range.start = res->start; + devmem->pagemap.range.end = res->end; + devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; + } else if (spm_addr_dev0 && spm_addr_dev1) { + devmem->pagemap.range.start = MINOR(mdevice->cdevice.dev) ? + spm_addr_dev0 : + spm_addr_dev1; + devmem->pagemap.range.end = devmem->pagemap.range.start + + DEVMEM_CHUNK_SIZE - 1; + devmem->pagemap.type = MEMORY_DEVICE_PUBLIC; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PUBLIC; + } else { + pr_err("Both spm_addr_dev parameters should be set\n"); + } - 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; devmem->pagemap.ops = &dmirror_devmem_ops; devmem->pagemap.owner = mdevice; @@ -493,10 +515,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; @@ -529,7 +555,8 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, err_release: mutex_unlock(&mdevice->devmem_lock); - release_mem_region(devmem->pagemap.range.start, range_len(&devmem->pagemap.range)); + if (res) + release_mem_region(devmem->pagemap.range.start, range_len(&devmem->pagemap.range)); err_devmem: kfree(devmem); @@ -1097,10 +1124,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 +1138,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..00259d994410 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_PUBLIC, }; #endif /* _LIB_TEST_HMM_UAPI_H */ From patchwork Wed Aug 25 03:48:26 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: 12456349 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, 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 0DD25C4338F for ; Wed, 25 Aug 2021 03:49:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9DEBB6103C for ; Wed, 25 Aug 2021 03:49:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9DEBB6103C 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 1836B6B0088; Tue, 24 Aug 2021 23:48:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10B166B0089; Tue, 24 Aug 2021 23:48:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E51B26B008A; Tue, 24 Aug 2021 23:48:53 -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 C5BC76B0088 for ; Tue, 24 Aug 2021 23:48:53 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6F1C01802F641 for ; Wed, 25 Aug 2021 03:48:53 +0000 (UTC) X-FDA: 78512221746.26.1EA5178 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2068.outbound.protection.outlook.com [40.107.95.68]) by imf29.hostedemail.com (Postfix) with ESMTP id 0C816900024F for ; Wed, 25 Aug 2021 03:48:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VJAcathZ8wmTKk2gmUM4pQw6RqFh/v9mgGakIkwWcwI6s5Se3g8Y7LZm3O77V88/QCkzJaWew/r9BoOV/JJXYm+oODGZ7BieB5+4vfIzY+7sWEgtOSFIgKySPug6ToDexWpjwJESMoztsEgehtF+OEWJo+gWv1agN3vDGbljxLM4i6+VHvRerZrmNEBPeFonIqWsAtjtM49AJMRusI/uBZMCkgGVi5RMyGJw3RSF3kIqkZBkFn96mfI3XrbJZcY0yU6YTCdfhgKaOdx6wwfQZ6PDV+IQAlhlwBWmJfXadkOX+8u5D29k587RUgnGzFVdVo2TjcDzz9dnpwCKp60yTg== 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=leJttb/LFh2M/wzwUmywQ7bX9zYZjJvBAUyOE4AeRxA=; b=FYjkjphL2eagOyY706l+RfJqMwBc95EFZdAZnMVGSA9xVNDPI93AoVfTRwhMZ2IWOL5lLea3oC+9MTjGhR5Hvjn7OcEYBGCmOt/gI2JFGsUo7nuXwIUIepGo9t9UEkaKGbcNWCSCPYetdPPknrrDm+JWPLWRVByErC3Qa2IRy80TcI5uNQ4dw5uDQ3f3H9/jIyOTi9Hmv17cO00wSdNbPuLQjCrYB6aPXaLaCdiRA0r/fZNGuiKz8fEWhHpnCu2WedXWtjwt6qk4AguHCSRpxUBLT4IEF69GuHWb0HKIuLN+YK6KjIY5HNSXPdoey/BGOppHHxyWgcWPzbqzfEPwLA== 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=leJttb/LFh2M/wzwUmywQ7bX9zYZjJvBAUyOE4AeRxA=; b=jp3KnSuKDPtZiSm6S9rrZMEWyZRGh1AUjBjmzFBm7H6Z8rpPp4SfD3/hFTFPrnh7BYk8pkd+MBnD3MadMMEU8u4uDTmtD3DSpdw20ju7K2vylEcgq4MXAXsAQeYxMOH21xgH+nkkT8FBlzzIibkeR1sEfV/+C5hBHP2zUsHkQx4= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:51 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:51 +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 v1 12/14] lib: add support for device public type in test_hmm Date: Tue, 24 Aug 2021 22:48:26 -0500 Message-Id: <20210825034828.12927-13-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df307ff5-7953-4ceb-2e29-08d9677b406a X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: 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: oTt3M51vZEX/Cb+NKkxwX5Kg1MUcXb4YMhOGLNTNM0G8eFZa25tIbaJN3r6eWlgy97/+dF+WQuYlq8y+8w7kB+mq26LJzp3eoi7ksy7xNS/zizv+NpZFwF82DgcOskhSq30QWmpWR1gAwRwyt/sIFqX83RxEWMzu2H+ugEeIJTucbleefokP8CqscAacolIK4zCrucXhPz1y77hDDSRU5lSyOfTk2F3lasjE2kAzhwB7V7aNQlVeXq9nBC8qiLk++9pV51hmA8D9QElAeImeZ8MHpnww6Qa4kFUcLfc+m1Uw3lhDJNmTdpBuAhvic1GjHT1l7A0xb6S6GHhwNqcCm0ScV030LFGk8zdFXFQ1V3lu627KchttSy4LNnIwyTyDoF8RQAVHGduOsaa2w8dxjKkT+yr7QO5i/sj6+RuRwPxE0IgfAD4Pa2QdD5XPc8PLTbiG8onUxyrVKbrefFENpOJImgQRQN1WJ9MF96vsMH7HVhEXWXVLRlemFNV+8TgTcxPkEfonqERS3iMq4L4pUG0r4Adfm+vIMQB4KeHi+z8PO07qs3UJ9KbrWyCnm0t1YwAdYRsBw5vKAjkpFCB8uMIqsFQ/oIh4x4GIAnmiKtrHOKXCsCoGTEJHfIPGtqq/qCpqNZRgrvNVpz6So4TzZl1ynJZNLPPWTOSuEoomU9gjPij1vnsFbIAIa/aecKTtlAGRxs8AVo0sp5tNJtqBRw== 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(30864003)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UkaUVHV9Xs1hgLGJmaE51jkuwNnoX5pO6C8whvywbLypxqdZVm5v7Seus25EJ+OVlWt0T8l2fcyRUDxX9nxcxJYiV67AFgI0PsXEZf+jEMMrul7SQHo/scqjAWP+LOa+Gzjglo0RQysXFysox9yOgICMVpJfev8APeWPrGFSvVKcckiWEPciRhUXngfR5W+J5xeTXtsVGar5lV+oBW4jtoydDZBm3OXlUSqj9qup71CXuEtZOD+EAjN2ALzVeYGeKwArWfp+UTuwAl0UpuFQJTXK2anK3mExjf7PRz9FPTmQmkZB62mBJ6Vo9sxeYXeZiSsnEBplxAtwik0O6izpLRT4PosE3RU/d+aeXPOV8A0V+SoZUHnJ3cfWjJ/n9kVNXTeSNPJFfUavEhqyvZxW6hXEBrCOkM7dDm1hE5nazTZqXP1U+VXHBPwLL4nGFskDr7B5/NhjZ3zAm+3ePeJ/TUMF7wwqI8wmzYhuUlGVbHCQwQgclRg4XhP+/Z516f061CayuRZk3V2ljguRNI1vv8jqTEixmPgmOX/xIV+p/cYBwznowdXtEa0EIxFErb0iVgnm3TrCd/pYNOJ4kosFnrO3HqFsHisZCIpxaomIQrIMaKgfRzHgg0Sj7ZRiiiRgtGqjtwe1S60bdfBt3lyEexxThU2Q0l2Spoh/G7PAhG116doh6CVDaPndldBsvmR+hoXo2ded8SPHXz5Uf8baS/RCDC9Y1minimHz06N2LtwSPYaZ/v77c5Ti30AnsCrAXyjnhrO1XtArLzj8vHVORV3fdkdsml2V3YebxdKwqYV61fIJeBO8zdeuZ/GIsnjyiwQEJ0hPvfQvvAALGOzbCqQf+mhuMSoiVVf2ccKZNoCimuMC3LnRybxeQFyNbJNGhmrdTrK/OpGDw4jFFmgKdRAYe3wY4qt75QkXAKArkcyWZj5FPh3xYukatk6FGLasNXq0a0fMSKO886ARiaDcdrkoBcyVoZCtllxpCDQBLcs9uQ/tSNFfZjWrATiBn01n/ZPaM8B2Y1sUMoaSD+pcRCpzFSPE470ce/GiO6nAR00y6H4PfonDDWxsm4wg+AcQL7Grfsw2BNgXOXPd7xT0WZ/7P7YnL14pv+iXClVM99WpUlo4NQO2Q4ZuBuD8qJL2VQmU4hOKzVFw/aVeCSR0SRmda0YbLXaobawu95pDGP+VOeNzR28VYWgS/+yQr1EHfGU9hTyYPcJebdXGMYzchGivN1/Z10K8IVIloj84Eo7pTcqAkV81a8tDEVvJKfQh2p8Zva2j5ESz1KFmE0rBaOrU9ZMdIKksymPYRlVU/sXTSRR06VIwXSaYFZkvxXcF X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: df307ff5-7953-4ceb-2e29-08d9677b406a X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:51.0816 (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: 4nTB9ZFUMHk/b2av/Ul/58hYvIo/UpR4P4vU7Sz4Uexm1QtnhY0MGusI9Ha49znbdMnpgqUJgeVXwu6ddUwSkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=jp3KnSuK; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf29.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.95.68 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0C816900024F X-Stat-Signature: bcq647f1nzyjnjaw8iucutimuxki9f7d X-HE-Tag: 1629863332-109639 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 Public type uses device memory that is coherently accesible by the CPU. This could be 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. Ex. 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 ef27e355738a..e346a48e2509 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) @@ -551,7 +552,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); @@ -560,7 +561,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) @@ -569,8 +570,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 public type we use the actual dpage to store the data + * and ignore rpage. */ rpage = alloc_page(GFP_HIGHUSER); if (!rpage) @@ -603,7 +606,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; @@ -621,12 +624,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 @@ -638,8 +647,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) || @@ -673,10 +684,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 public 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); @@ -690,6 +704,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) { @@ -731,33 +786,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: @@ -781,9 +849,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 public? */ + if (!is_device_private_page(page)) + *perm = HMM_DMIRROR_PROT_DEV_PUBLIC; + /* + * 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; @@ -1030,38 +1104,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 00259d994410..b6cb8a7d2470 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_PUBLIC: Migrate device public 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_PUBLIC = 0x40, }; enum { From patchwork Wed Aug 25 03:48:27 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: 12456351 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, 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 9919AC4338F for ; Wed, 25 Aug 2021 03:49:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 371DE6115A for ; Wed, 25 Aug 2021 03:49:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 371DE6115A 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 8D4026B0089; Tue, 24 Aug 2021 23:48:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 887046B008A; Tue, 24 Aug 2021 23:48:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D6408D0001; Tue, 24 Aug 2021 23:48:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 550B76B0089 for ; Tue, 24 Aug 2021 23:48:54 -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 04623253D4 for ; Wed, 25 Aug 2021 03:48:54 +0000 (UTC) X-FDA: 78512221788.01.62D2D89 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2068.outbound.protection.outlook.com [40.107.95.68]) by imf29.hostedemail.com (Postfix) with ESMTP id 81296900024F for ; Wed, 25 Aug 2021 03:48:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=khHfLu6/EIiH1w8ooYJj0/dSmKP5OGYCna7A1g/FQ7ITGQxR3HmhUH+/R1WhWiQQNfRMaEoTCJ6NE+u71bfuPS3ajZ0g+Zvu3Sc091FwF87XLi3tdgi2UlxeA8UGlpWMi71S7T+HGJUbAhlheIcPW48ixpaHizeSWchQxhXQAilh88Ck33GRBOXkaXUMc8sRawBKobmmjOGyvnp9zIBgXnipxsm7GU6uMH5iMh5oePFFQQhOjuAgYs3blGYtjU24LAAT5m5Xz+Gr4GngpqBNYsReDpQFSo5MoIiTVIQSDV2VTwUL/vbpPiWrCB/BlXGFL/XCkhePpvWhialLPQ1znw== 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=PfsDeDPTrxHJIIQdDj4G6ondzbiB2t/+YrLe1QVCDLk=; b=aAHryiB8XnsBEbbIsD+DNLj0knM/S2bbv5gqQijU3lST/QokX5EEyEYUEArhDvsSVzPfJx4tD5XhmXm+IaR01tH/5danYxMwXtgoaOmi82YLmVGMdbQeEASgVlThxY7X3rCzZyXeKwQA4NxOOhx+S6P5VSsiFrIoSy9Mf3c/i6xAFKdtFuB/Aj6ASzQtgKTO4HvqSySAv5Ubi7Pfh6Xi9RPOZCnOmZBSadrDV8bifGgYmm3MDhQuVuPZPD9SwPeit9c5u9R3m02mVNLWRxb5WdVRvwW0ikwviFofL+uT+6N/lu9FOiumyG4kU0Hrmy5k8RzRzwUSXteDZgAl8eU53g== 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=PfsDeDPTrxHJIIQdDj4G6ondzbiB2t/+YrLe1QVCDLk=; b=M2AIzsv82s5xz+X+fJYKIP+5MYqEzZ2twYJTvnuOsDvdWJagjsOgE9ZSvOpI7aja0nlXpi+kqg2PeJqAwlWA4dU6olGwYFPa9PXF/+sv7g5A9m6Gu4sLRvj0Gjqy00/cdTMDf1cteJKTSAOUB8kLbnAn5ttotDacfMdDO61PchE= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:52 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:52 +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 v1 13/14] tools: update hmm-test to support device public type Date: Tue, 24 Aug 2021 22:48:27 -0500 Message-Id: <20210825034828.12927-14-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9fe1585d-51b6-49a0-a838-08d9677b40fa X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: 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: vUpmdye6eFD900Y7lbHnDGE+G7C8P7f5demNMvF2RHoQchsQk+oO/G8vi33YTt2capBzmq774upBpqQ29N4mgSz+yOOy5Nm5mzTwO/yT52Osdqhq3IIFVIzw1GfKxgBaqGW8BY2XKqI9OeTU+JsIku4HThciR7xHGW0ywP7bMypYnIDvJ4r6HMmQva4dI9RGuIBgAGq8J3lEA3O4iLuEdAAb8Pj5DKnHY01xJV2ilFI6uuocAHtXPjO/F10nSLHqC91Y8FOidEgWps+YbiyZUlhp7MJnuuatw/RceU4mw0emoz5R3hX29Y3wqd4tIjl4oHcG7N1t4tyksiwMqjOCD+YjObI6H45uULT6RDPPtEm0kmNvL0Um//PBDfNT3z4Vg8XEUPVBSIytYq9l6WfqGJZoGZf6xDD3ySsZ53dlH+Etp7AExYay0MB3Z+udnCulaqd5VGfJ/O+V2sGLcsClqst5BUAaBiom++60f6AlZ+rVN4oE1A6Vm7Yolr7JZjb+eLE9lLmY+oJnXv2PNght77TNDuoJSc5rxkKrGfeglXvbvW3sDi1hxWByUrevBREd61Z0M+fEU0BMQrBnG+Id1NfQBNtaunObzgq1ryaqiyTbjC+CvTRL9xSxqSRmS/K8KrwSFXgn8Y2hSrQmrGrnJ8ccnYwvm04Ej0E5C7fx1j0mVGESrsoAfTVvVD1IAEDA31ETLfNFE1C++7D4XDU9CA== 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(15650500001)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EPZ1aq6upuK46eKlCFEsMGcyuqZRPxzJD7NqSxGQ1LdUQhSL8LH6AGDhp6cFWzxKg5HmmDQDUjpvBKxKK68BFBONCarlmB59PSP3gTVpDnPQbGpNm1dCY6SehQ6IQL3CW9sqzTy+cZD3DfFreaYbR0CnUlrR7/USn71ewTQ0NLYSvQKjTx7/fAld9KSWvtDIO6n4u5QKzZnVTPQ698wU1uun9H9DgLgEAE1DKwzjXqdbHqnVKTB7hfoU3s/RvvAUqL9cx9RZ5u04Aak7fOnyI7f6PK9q2I8JVKD9LCijjBc2iPV/upElgqX6dplhL4r3A+IDemTWxNPZ/+l4BHvpbNSMCfa7ZcxX1wNTAGG4lP7h+A3/10JEMTMfVDw29XPmUH3yUFA59j56FQLDZIrSOEZV2ttzCrzdy+CLCzVCSJUmIjMI1pK6vK+QlYq5RmJwp0qEpTN6ansspGZVl4RBeMWwTs9yH5NngB2E9xT7lIs80AU+j2NhyazBYyLv5zJCacI30HHyEgdLaxqpW5XxCAm2MP4UGe/NAjmBiwfBlN/NstU4Do80w1MUbu3req58FklagKT4imul7DhzmLPw4AJZvd781neIYSOzrEgeqF9oqJ9GDyEqBrwqjpWwnXQ+icA5+mygCiMRQ1dydwiEl4SwpoquX3zVghYKG3KW+LnyroUhs3QPJ8XayZ7csDAkXuqK1G004g8DzJWYDC+KGDULIjNv4hNwRMsoaB2gQB08f0/b8xvcsevt7VI2ol/grJJeov1TEYguW3QzU29hEZ/g3c6ULZRIetGtNUqDfLHqCxNWDDG8sA7vEstOERX/nITfjf0Rc2epJhKUNW6qw9usC0wsWLWSUXThXm6NwChXn2Q+rjvN0GLgYQHp5TzYjZEpaxMxChEvx2hfzdpt0aRlZqANpBalPNRRej9s1E0yh/wtlE14QpizP1gFQR9bU4RZg4IcVeFnZW96t8TkVMBIaUCCD+jXymlNW3dZhC/qohcs4lBVQTy9YRXqyA66evyXpYvnSTxpiZQOnBkcQGu+y+3R3UvRcrK0aXtWLQEmjm1oBJUbs4HbSbZ51YT3GDeJiCI1kyxEIrP3M2Jxz+DisHbfdA46LSHKl1u0Rfa5ny37RC9mXLF+U71KpLYs887P8yZjoG7/mBQhfxDS1rG4cBvNNsyCuresleVzeHVbyuXqQUyd6Exb1T/lZvz026MKJuRCrbMovDM2qUgGYppdC0EQo6czWcv5YEgkzoOimY2JNC0+KqfRRQdmW9s+h+R8Y+Ys397+qwKHRM11tSJ2osaPeCvCqTHn2s6ulfehUl8hLMDdArqy93SxD0TJ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9fe1585d-51b6-49a0-a838-08d9677b40fa X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:52.2206 (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: 533wm9jHF2T1yf/kmDKB/8jkyelPh+nSb0U4a1CXXDL5ls/L5NUDIYl5qe0tFOoyqolySEM4zC/CJFJKKGn4+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=M2AIzsv8; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf29.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.95.68 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 81296900024F X-Stat-Signature: ccasga1n5pqreke95u6xz1fsd6isoqrz X-HE-Tag: 1629863333-619872 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 public 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 public 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..477c6283dd1b 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 public 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_PUBLIC | + HMM_DMIRROR_PROT_WRITE); + ASSERT_EQ(m[6], HMM_DMIRROR_PROT_DEV_PUBLIC | + 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 Wed Aug 25 03:48:28 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: 12456353 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, 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 D4643C41537 for ; Wed, 25 Aug 2021 03:49:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 85CED6115A for ; Wed, 25 Aug 2021 03:49:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 85CED6115A 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 57B4B6B008A; Tue, 24 Aug 2021 23:48:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DBBC6B008C; Tue, 24 Aug 2021 23:48:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A2308D0001; Tue, 24 Aug 2021 23:48:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id 204296B008A for ; Tue, 24 Aug 2021 23:48:56 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B2EC518043073 for ; Wed, 25 Aug 2021 03:48:55 +0000 (UTC) X-FDA: 78512221830.17.0866B52 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2074.outbound.protection.outlook.com [40.107.95.74]) by imf09.hostedemail.com (Postfix) with ESMTP id 48383300010F for ; Wed, 25 Aug 2021 03:48:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XkzSM8ffDAeJujnnKNJsrQCPAcbivkYlMJ+tpsNTFkrgu6EEKOM2cGbOTIOcK/D9IW8cFEU7gNRcxAr2rSFNs//EkaTm3ouCHoM8L+FtX2VLYIexT0Z0ieErSU83KAWIfci6NGNUuZZF+jG1yUlbIsh92704uqFtgALDJDOJTxikA2krrZFkH7+tkUpQiMht0G2TnmwlRxBtIEustMZ1X0ANYPXHJxhLT8x0dsSbXKzgyg12lWEZu4OyRN5d1aq2a5jlQzc59U4OANgtwl5k/5eWETG5XT4O6hS1GODCbZ1Sx5fHh06RkSbHZXkVsbw8teBV242rey5csPc62fQ6Lw== 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=K/HtW1JAM3zl/llSyGWWwvnXjZ+I+rn1LvUfc29p62Y=; b=OdasTBEbscq7nD2VERF6tQF2I3suVAG1bnJmRBnErcvpcVrMHG++pS0Toacb+hR+hNpiCSktDok22ntG7To/AvI6jr7qf08f7GnBnDqKB2kDsFuSTIon/b2SVEx6mROW844OIphwBiN65ISXerTnAooXqpyItaasQ+yj9SU9fdbwEVLaAfwtJwDxuq3Sa0PO99K5qyBnGdKELEXU+IMaonW1FCDHwNO22HEDX2pvBzQW7Ls9kYwV7QoFT2714pMygI5zcWsr6ozo0dKr0XfvvM2Af9Ad2QrSC5sdY5n0ie7J/rSU8d60G5cgYcnN2cAqDt7eal+0dQw9i/TcEZ1mhg== 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=K/HtW1JAM3zl/llSyGWWwvnXjZ+I+rn1LvUfc29p62Y=; b=SjH9YUWJFxQFV71OTzS1TS/EVx9FQWXVkPvoFv+LdzXukisRX5VeSuPcg6Ac7AUFmnE8vtI5TTPPba56wbldU+4JPM/qSZiNjnknEb08HxxpJoDLJ3QtlBsHZX2BxbtcCvqAxPFQCcOhEDivcm7wnO5au8jUl35/DIXr3l3YHuM= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4750.namprd12.prod.outlook.com (2603:10b6:805:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 03:48:53 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::855b:1f8c:c5d1:331f%7]) with mapi id 15.20.4457.017; Wed, 25 Aug 2021 03:48:53 +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 v1 14/14] tools: update test_hmm script to support SP config Date: Tue, 24 Aug 2021 22:48:28 -0500 Message-Id: <20210825034828.12927-15-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210825034828.12927-1-alex.sierra@amd.com> References: <20210825034828.12927-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) 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 SN7PR04CA0190.namprd04.prod.outlook.com (2603:10b6:806:126::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 03:48:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b9f57e7-2787-4ac3-3a39-08d9677b41ae X-MS-TrafficTypeDiagnostic: SN6PR12MB4750: 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: tCiLxMI4dzT6KuGGNhfQ57silOfM32xlmMxuu+0e1dL0WGg/0CwylziqLwfB58YNnrSS58tGF/B6NE7Qc5K7/i2QFgKsvJdqx7arKVPInZDVwf7Fr7t+Wi/g0AHQtP9HftQRj4xkEZbFuRHDZMLtk2jtEEA9bNcy4JFoVdFN4zXySqLmoCTUIqv82dIijoroh7THI5mnUbdGg3ZClneuSoGazBqNhxnYSt2nlB1LcLaW0xUOxorlAd5UnD/6l1uESg/2C3VAPMr+zgLGARsHY+AzRz1o/mMVQF8t4kSKfKPjVyKpSsabAX/OE0UGng2AokUqgwak0UGXtJSk0YPj55IM/qPkBf8YPUspWg3+bJaQc7f97yKKx2yFr8I2xo3B6Mw9S6Ybys3Dfh1MkWyHX+6Xf9qFD8tS4TitnXFYoQP1/FmtDOPSrzQ0HKxobNLG+FUTsWCrjbGWBzOv4syEdQOryoJ/ijLq5PetFf5w9UiGla7bWJRGgtC7KWIJ/KYfpPIW0Mjp51wtWjJbvD63jFseIphjJa749Uoo+vGFii6Lh9GXG6Bx2uqSMEGGXZeFS4lY1XszjZ/qd9FOyPUYmRUkRLnaSXQA2bcgqyGrT6oeP/5S6gSMZEHxHBFEfEH9eTgW11tduY7w3NLYZ8oZ+NmTTor4u9iAUVZuF42Pv+tl4WU7wtJEk8A57goYdYieujQC2cDRPcC542300VGCXA== 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)(39860400002)(376002)(346002)(136003)(396003)(366004)(7416002)(6486002)(1076003)(4326008)(86362001)(7696005)(44832011)(52116002)(186003)(2616005)(956004)(38350700002)(38100700002)(478600001)(66476007)(66556008)(6666004)(316002)(26005)(36756003)(8936002)(5660300002)(8676002)(66946007)(83380400001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kUkcxiaL401raqQk28EO8PZ3B83V3LHkBpPFOXP1SV8kSMUO/Tn0SONwapWjjmO+le11RsRgK5M6WgRrhysSroM8bPaXt6aXnJgqu67cXdkWcWlkPOo7RmD77eiegFimV8cBJ50sMByisJ1dbfNO774/oO5PYqqK1tHGckHTjgVmf9pmNbQInFgRpkjQ8FIc6weg6DrX9I3xOv/NwNePH2D5ty+xzG36onkr7pmxmgs/h+kLmMHU0D7p7AbcqdLsad93CWtUU9I/L2Fl66Il6oHIl/UxzLluA3UfNRtM3iG/F1fZRBlyGQ8MNptZTQ7JBIyWV3EFDFFxyqBzdOuHngkKwiK+qoYaycKn2PPtvLFmPsuQcnne+MItQeIZ9QlzA3Tw9hduHaiWj70VKxRM0/zVrmxK6/4s+CUqpRykKjJtwFjZHFagfHn+PJzqi5poy+ED+LU2ug5bZR9JqGa4GNQD8GyEFOu4SZY7FIk+/velGTtLl6m59/P/fB3FliDn4+/CT9ADxe9jbJp2mRDifyrAyuhu00aRU7zzB/pRuVOyuywQfEIolqQoKA0nNfWso490UtWL+xKbUS2X/IjKldLBtE9c1r2b6RMvfWiHVPPUpYaOORDYHbiZNp9bjb6SXOPWVzn4hFIT9Zcd5l348OZx3LTDYSxlOs5dGxcUC9g8s7/hODQFrR8JlFSqyEPOVFH2RFpBV6ZabVTGJaQY06barBXPFwfsmmTw+Ke3t4LIFd69PO5ghflnzOY8rwazQqTTDEioIW2G0/bMLbzknfuGSd+978OlPN+QC4pNl5TOt1k1j6FNsUxKDZizYkruewpu9X7Xlg2Z4Mp98q/K8ECrTKkjZNiifoyH4LkvuJ4+2ysf8E29AxVeLnUpeSWs/eDARRNYeKD0v4hNlWFUvusVQ+YFsmUBmBf7o7AUMM7mRQWLbnPTHQ4mfqtyYhMIFyErxdthLKcsfATX0PtP6oN1BBvZpho4E2Z3QuoKwigI11IF4VKrslLW52TYE8Pvsa8cWclDpPilUOn+ZnssZ+cT4yVxbZzzmaodNuTM3Oh5g646OJAjXB2GZgtcwTKABlasd7YpaJIljjfpMBRCQ/4mxFuYdDQ3XhkEdcxeXR+rJhzpofNbm9IFfIELcCCh1rWPp1CO+8vDf3qMaX57v+TS3kvircCQ4QJkpBLDbEu6I7UUf4vgf2qPk7glPKbMaISNcPziEUURo/T6rjZmzL+R921Ts4i7jAy8/CYZh0/Q+fQCoGso13th9r1/paM94vHf0FMKhhXzlmHUZbfHRSHxvWUlreQL9i1lEGHKYq/XaJJxVuo6ECy/KY42G2pA X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b9f57e7-2787-4ac3-3a39-08d9677b41ae X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 03:48:53.2561 (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: klxSZQvNrJFcz+9JeFt6dMgNUmOXFB3NwCDQAaYoU3vbZzz71HbGH8ZJYFhcgx8qmxaWk3sYIdvOTU12gUNmyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4750 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=SjH9YUWJ; spf=pass (imf09.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.95.74 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 48383300010F X-Stat-Signature: ef7ote1xf68pjiwq8tot9jsbddmxkwpq X-HE-Tag: 1629863335-975835 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 public. 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