From patchwork Sat Jul 17 19:21: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: 12383825 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.6 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 5336FC636C9 for ; Sat, 17 Jul 2021 19:22:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA97A6115B for ; Sat, 17 Jul 2021 19:22:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA97A6115B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3D2458D00F7; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 35AEE8D00F6; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 185958D00F7; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id DBB3E8D00F5 for ; Sat, 17 Jul 2021 15:21:58 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 89E90181AEF21 for ; Sat, 17 Jul 2021 19:21:57 +0000 (UTC) X-FDA: 78373049874.14.091A9D1 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2066.outbound.protection.outlook.com [40.107.236.66]) by imf09.hostedemail.com (Postfix) with ESMTP id 0455C3000103 for ; Sat, 17 Jul 2021 19:21:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jehlSSi5HRgBZMwqP/SPDwGlgwQzOGEkaR1RSbBf5X6Rr2Ff7NjS1E9yuCLdCAbU98DiCikU1r7pxtj8nNVY7j+QYejm9bcUljXSdQ0yciWW/doh7rOLmBVJcMfI+xvdPrq4ArPMMrDRuw1jm/+tSnaPxjZzZ3rovtyYrAoCpBjpUIw9hKjy8qAJOKNhPxo4/P3RkC8klcHBsVZ8zbDVT53gO7MOhZGMREppG4x0MEpUxz7OJNWr1wsJllKZlWCP++aDGGqw0H+xdpp3nS6UgJI6CkqyGpFdQTme0MT3Zp/ixsQKHUKe7a86mMgMNqUUrlzUSbzcp46XvAMq7HJa7g== 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=2jjxGrDzxeB0/vA7uRRDTZT4RBZZrOgQsqJSF7ty8p0=; b=BNgxBl16w3sjcc3IX9psWNN66Po27yOgxYEPjtsqpbQ4XTzgYhRThaRoL8Fs/1aApLxACPPs8KfuAiH//UJN5RRrYwUKg7wufz+2p2naoQ6gpHHOp3sXp2IgC34EcMEGObSIvIyjkXRL2JEbbuTM+aO6TOtsiszAKj/Lv7SoKea29r2wRFNGpoU5Xt9v9Ej5Gt3yxw0eXrmY1IPnfyDOw+DnijKc2naeo7dAwGHvlO9x48S1hQSwxxV6e7ChNa9cZGxNiQNHkv1GC1yoRT+WvbSrJ1fpNWs39VnvF6o9VjBjtfnYluUIxpOp+Xhb9ROVQ2wnumE7zvXwIgo+OUs+8A== 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=2jjxGrDzxeB0/vA7uRRDTZT4RBZZrOgQsqJSF7ty8p0=; b=YbSLqbZNCgCBkA/iBI8JCTbKZv/JbvuU5cXL+WyfocMy1dm/ObOiWFgULc1Ray5qRdGV60ArImL9aBsIPKsMgiITGSKdjvIC2lNQdPKxHiAIhikXvRHF10prWdD1peTbNWEgaxPOi1H+kp9xI5zbsYJxwfhcqtjKbtVtLqIbm4s= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2830.namprd12.prod.outlook.com (2603:10b6:805:e0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Sat, 17 Jul 2021 19:21:54 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21: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 v4 01/13] ext4/xfs: add page refcount helper Date: Sat, 17 Jul 2021 14:21:23 -0500 Message-Id: <20210717192135.9030-2-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 178b7352-c9fd-4237-9d12-08d949581e62 X-MS-TrafficTypeDiagnostic: SN6PR12MB2830: 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: o4r2aZRHz7/9C5iiP7ece3I1c1njBDG7FmN+bCGd5E1wYTfj+9f4rdH1bbV+ulB+bzwGiW7yupymS6TZCbGotJ1Ss8DqUX/FfwmHosJXAHwWNWgpUJn8++gZ1F+5ltLTfWoyESKxJbg1+WDAlZobQpoh9oMSQFxbxrQMS2fSN4N01YP2wI4cl9042E5LtMIhvWTvyaXCShfC3f4TG0/DRra1KZ+9z13UodugVGMuYHsmFUABUbmcXZAa7WiqXa7wWUWD9DqaeoNqQbjCxcLcetLDFbJEz/zjhGeO3c2g0IDH7YLdLcrETWlSRX80vOQ/wI8cRETW0f4rCj8P4Ud845wkSNZvYR/9PnZdCZe67Q7fsvCT9znEcR8ev3Qyx+zbjKzFfmybuEGj2awBJpAzGEN2v4T9XvJ7DsNLtruPg43wM7Hs72Ak0YEqBKu390Dpc7ajgcO5oaVQGRwv3RTeRFF8lLgyZMO87XbiTOkUG6v3Kz4ZG8bEgJIqWmTskWho9CWUiT0Jse5vt8zJT77CRoUkc8uAbhYqZuTOsgaghPe3bk02UrDRreeIN2zWhFc8Fsp2PmhK1MO3Q1SUqE2myXL+GIEAXvX8DMU0TLSWbDHZPIxU3N2s9aDfM+pJkiGvJqiXWsz9NC8Rpi9CJmf/15EMnj+gAKDsGjUcJKHap0aed2iasyanUSzqfD8KCIQFrUfaGLJYeLFsFF6ETDehaQ== 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)(376002)(346002)(136003)(366004)(39860400002)(396003)(83380400001)(186003)(2906002)(5660300002)(2616005)(66476007)(7696005)(38350700002)(52116002)(26005)(36756003)(66946007)(66556008)(8676002)(38100700002)(44832011)(86362001)(478600001)(4326008)(956004)(7416002)(6486002)(8936002)(6666004)(316002)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lxI2UClI+kJiUqf6clIqeWixqIj697zgoy9o0TLM5o1c7o16OEJCxw3JnwClnB2uvmP9TrZAemQEVGPVZil/Vatf/sL6Z98pld8l25JRPNmG/Lp/UdpdBc92f5/hR/gBHvY0XlaDHN+uP8DjuSflmZ9OUj0JXg1fOqQdqdxQkBXjsCEcqDnIXCIUyxXvlXOyXg+fsEi9CqUp8yhnGvQL7buDTO9xe/W+NljmeDNSsycx0tKLyqTCK5MqovXSVIfeZCPKjX4Bv1mpYM8HXQnntkjVS04QwkxaoXcEZbi/unTVTMxRY+z73LL66RVjQdzYZbAOVkQa6DX3ByPO73e6/RH+5sQk5HSAZBkuHl3AlLpHiaozHN1e8yMOyex2Ggs2Y6kbZmcinAEIBlTH7mzemzxa4sgsuch/S9LJ96o0JFwjbHD26yD77RUfpv0AWkHjkQkKFqDQxs3OmwjLZgHmmPNtKm7BmHrqWEXTymyuXTHnwbPyWCPhPVc+YPlOUxiCpOjkWHbwsPm3QkpagWqGQtoeYrn4vGcAM62QQ2QGGsKW+U3IVbaUuNr5BCViqqTErNr/KqtpT2TKuuCISXAUVnYFfjGjBbBj2DENnprrYOh7oPAQmGgHBbdd3FQcwaWVz1Z3UHAb60hXdR20z7K0WJGzm3n0QkZw8HInQj0Jrow6ATsB/6z9eumchyWRJ6HuGpftH4qCKtjtyiNya0SPSkJSPK655pXBZyHNn8fYGQisr5vDlkPBwI6moDHcVeuy6EBadL64c41WpLkQ179ASK/w0weAC0f6EF49mjUXDVhR4X/Ur9xTlUBCb/G5fsMXmoxtluBKD1X//rMhhtUqDzP2j/NZ5IZNMVe3P09TLSTKxp5nbR/jDUS3+jKTyjOlsp4fn2Zr5W+h0keHMPbPDmc/Jwfw21FleE8UD9VEyLpanQCXlBnaCvCfbtQyDx5EKMZeMX5hMqOBvb/QhS8XOYxLu3EOOFNM7BlSKMtgCT3Svox9J6XES2dDxWfIV0euW6MEiIUBtnS1RuYyozGMVJqG18gPY1dCaw11X0xvLTs1hLKUprzz++y5gnwhm5PrmF4G33satx1b3vEj43IY/vRGMxOBQLRAQ11MVpy5AK7/QFPXdIR6FySSOrxZLghLacyiPTgIlhVeE+PSSP/c20ptYbJ2C/xtwgF/LwFQ4I/gvwfzRjscNveoX/v893U9x1BXzAz4cEm+7KLidh6Lb3fkBqLraispVOXGDLWvoB1OGEMAREnoQoGLuVpyy0Yt1Kd3HiigoWerpgrqkqL08zRj8mtRa56Ae4RhrGmeWafKQ/16IC4wogykurPtXTR1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 178b7352-c9fd-4237-9d12-08d949581e62 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:46.6927 (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: gEtHjG2MyUKgBIZYoqafqOcLDnBQ4HwWIPlJlTgi20Ecz1xjx9v15YT2WMvrAYGUH307vC12VSnjz0q2y9QAjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2830 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=YbSLqbZN; spf=pass (imf09.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.236.66 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-Rspamd-Server: rspam05 X-Stat-Signature: 7f4nnxtocpbrxzqotxu9n5csckajpei9 X-Rspamd-Queue-Id: 0455C3000103 X-HE-Tag: 1626549716-443710 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Ralph Campbell There are several places where ZONE_DEVICE struct pages assume a reference count == 1 means the page is idle and free. Instead of open coding this, add a helper function to hide this detail. v3: [AS]: rename dax_layout_is_idle_page func to dax_page_unused v4: [AS]: This ref count functionality was missing on fuse/dax.c. Signed-off-by: Ralph Campbell Signed-off-by: Alex Sierra --- 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 26d5dcd2d69e..4820bb511d68 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -358,7 +358,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; @@ -372,7 +372,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 c173c8405856..9ee00186412f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3972,10 +3972,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 5b0f93f73837..39565fe5f817 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -782,9 +782,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 Sat Jul 17 19:21: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: 12383827 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.6 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 50F7DC6377B for ; Sat, 17 Jul 2021 19:22:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E7B796117A for ; Sat, 17 Jul 2021 19:22:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7B796117A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8DBE18D00F6; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B3B98D00F5; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68FE08D00F6; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 267388D00F5 for ; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DD2BD181AEF23 for ; Sat, 17 Jul 2021 19:21:57 +0000 (UTC) X-FDA: 78373049874.04.9EE0451 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id 613412001714 for ; Sat, 17 Jul 2021 19:21:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OUHv1WMsqu0V0OePCwZjG9wevCymavzOAQ4E84B0MbmOdlrQKvF8ygGj3Zqyvd3mZOa+oyZD/ovoKAGGB5rvcCjg0RM7s5qAlnWnjdneJcytJEG6/QaNWYJqs9zd3z7Hty8Abyfg1ueh/miT7X+evtVuHcLZnqSIi55zFvC6svW/ajhEfeu9znsiOGruwZMLCiz8m2M5P5KnG20DH7HcBNePXfGQ6AN7N9cWpwqF/AJPQpn2emev/NvJDwPxDPjLOBOeoUBwXPMQLyXLC4AA4VqoUfQvB3CC9502qL0+CuiSVUoHG9KovZSFn/YqCI5e8tteTTxjjDlyhGmMemM16Q== 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=Wjm6pMWDxs6WiuEIw3qI0MKrwFxS8V2SjJOzX5ns9I8=; b=aFhtB5e3bXuF02LNYO++wV+QlesfgUnrcLc3VZNikOrQ3L6VCtQBhx9NL8H//Lsw0+9OPRnwraH0e1eq44AOaCGu5Y05NoF7Wn4WeFgFvu/PNFdJITz0uHlmN8agYaM7AWo+Wtyc9dkXc7sG4zgdh3LEg0SG5eDECWBW+vyOTf0T7aL9luBf3OpSmpKRmCdmmqqr+okP4obLnqjfoqWl4zkwGkMG1HNdSWHI/FFAD9Nn70n2jo6V58WGrYek5P+LwrPzd+jck+gLBC3ckt1HO7ZBRW+P3wAgS0DFapVfB6j5Uyl23CSG/FXmCMg6aQobAFP7Zt4cMcKmHtYO+T0GUw== 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=Wjm6pMWDxs6WiuEIw3qI0MKrwFxS8V2SjJOzX5ns9I8=; b=aC1MbvaZwBQlktn2R9ajgw/dKqP4QCzHssHqL4A4x3HXQpN0Hc5C5hPpEzG+wLH7maKvoq/aaKOUNKro/JEPk6ykWVU2svkJadOw5REAe5dYTogCTsrMui5KqNqdlFBodktqsJIroYLIM4byJEt8dpG7SvdBgvdeD6qHB9LT+VY= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:54 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:54 +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 v4 02/13] mm: remove extra ZONE_DEVICE struct page refcount Date: Sat, 17 Jul 2021 14:21:24 -0500 Message-Id: <20210717192135.9030-3-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3008b181-81f2-4028-564b-08d949581ec7 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QOWoKG7jKHT2dK5NflXoK2YAo0vx6bloZ0jj11QC3rtj5tJ6r42VTOJpZSiYycWFAIyJOFB3W6MvZq9HiR8ph4cMngsbtbuXxhCLQNh4rC8dNR08ps15y93N9YFuYqj2n1QEqa56lC4R/1O2Vmwy/3hTFwuGXf8zJMr1QcN+AmTjN+4zDJICL24Zz2OOLrrxBAKJJF6vIclqxYdaskN67FXJ75VegcxW8I+o5awnQevUkxdf0bEjFp8z/JpOSno9uUdou+8x+LzsV6PDthUXczVvmmu8JEB5wD1Q7S9VXlBTiFo6oVgKHsR+0hKPqA7XEMoTZQq2xEqJCX2dNl7mqfILIBOFM/xq+HnkEpU0OkJQSdBWIh/lhfUMluNJkM27SvFN/mVhcd0KZqVOk0S8R5jI5cblT2mnpiWmw4Um3WAUCUeUS4cj8f2K+3mi8IpOMzjw9m4o4xGnmxP/aS3JkQAGKEjZh9te9VneNedAggSzyh33uAlwjM/yLnG8BzSjD8yMw/3+tRGYOD4q8drCpPC9f9QT0Advln7xqcWkrGHBb6oK4ltUl0sE+T0YjGRK2BZ/iTlT+e+9dhY1LJHz6Jyrb6D83/MQS3YebjaaMY2L1nLrtla3hlQ6iPD38K/RZM60xOQQJmLhpLjxPutqTfxCc2W0f5mhzM1Tlc59JPUwDslHCkHYxAgLbZX+RkbHF7k4PUsMZXnPVkL2gUV08g== 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(30864003)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TPLRUax08Tjq+sMpvtgXvTbBdYSlZtAwKZGoATF+BEgwO5cdffW8Z3grjAxckLiP/EPutsCuWkgc7LxAUDBukIrxZ6Ovn8rjiWb1jIZYmUGLRo5B4+caZ73/dzNeLNi1hDcxaA1OkraBaLpC6PGCTSYodTSR4BTeZMGy30nXbsZUecQFJMEYkT8uVsBGBGu3wyZbkj9vxWpDEjeQHb4N035352/U2xPof8w2ubJahBGINt1zh078vlVexsRBslvf1xa7Quk1Fu7wtYHhei0LBT8bgMxe+xIz7WsUwECebrGvLMe0BB+Rh+q1u36MWXaKl2JzWfmq8iog4sF17oNrvj0tjAOJqNDbwYSBHJnLpzIYHHLjB4IMPBv3rTZEDM5fHGuBNeiHGyMmswOoNkQjEnYfDLWnHUBHbey5tlzUWeqgVK/RxF9Mu4hdIf5GuF2x7lDhmuJWH4Hmxo/md8qILvYqHkfWHpJuNr7rERJRzDbG+5/n4wE7BrfR8HK6UyyKEckX8vK2jT4XX21Afl4cb2EfN1z1wyTd28UmQcjJe0VX7XMQFjKyIR+cVYcBLbSvM8+os0gsqFp+MFWLsTeMwWl25PUVpktaW+i7PJ5NwcfhmdsnzanW6sIWPeKV2SUWGGHlayMAFz89Y3zPOLFLWTWpnanhMFo9NWmNEcBN3Qh7hCRaVccOY7/qaPm5YTM1QVAROr5yXGyxtOdqQfGYde13hSN3T2P4+M4t0VSGhw4vDOfyGTcCJYn5g5DNrrHQDcv4Rbg7dWBBxVqrctbhaiGSfsmUuM9G0HDDq/GgiYh/pQROAA4iTX/WUa0IdRn1PFVjQN60dK58IajVdBck3S3OrHN7sNNFwt0h5wniXWtY9yFqB76dm6Rc/WHuY+MllD8RiqC7SlMGN5jpmXIWOa1RX4fjHFaYzepZpPiUntYDUx+V+vR+8YeCFD7JyoVK7ijDfdOcgnrbN9hcX+Pgy2nBXVu446MRrlp1Ezjmzhh+mvDzYC0wH5gqnv54wJya7XLb6i/82HXIEyIL4eSHAkV9iu/xLwzqp/cGxQpO3EZVDE/ayrHqNvSl5fMFnhJWMYNnpwKAbLygf+HN66A8OvOfS5gdH7iMARXz8gbyorC9Tp7SJOnY3+L72OMo5LMTlnQMdR4MP3NgcENyESnN/wjxKrwwgaamcfnoyQFvmT4JIRfqyAyX53qJMTMGNv68CHumfHVHwMtvfekuMfbX6lYPYB5/Wvh4+SHJJI6xKCZQozm8K+/pFTVXdqjlCQQLI+FHDNa2yJZ/m/gUvrxpxKzjlC8JKGu9nFgWzsPQiFoiLu6SM/9iBn+rXz/gWY1n X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3008b181-81f2-4028-564b-08d949581ec7 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:47.3299 (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: +B8BejZtDkMCMHOiBoyUnhKBgjXygzcFsp3Zh+0JLNMCEAecp2+V2OPerE7Qu7kANRqS8CRdMekpQhARVrn8Mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 613412001714 X-Stat-Signature: 6s5oerfkcx8a75yc57o9g79c1j17ejw6 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=aC1MbvaZ; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549717-9962 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Ralph Campbell ZONE_DEVICE struct pages have an extra reference count that complicates the code for put_page() and several places in the kernel that need to check the reference count to see that a page is not being used (gup, compaction, migration, etc.). Clean up the code so the reference count doesn't need to be treated specially for ZONE_DEVICE. v2: AS: merged this patch in linux 5.11 version Signed-off-by: Ralph Campbell Signed-off-by: Alex Sierra --- arch/powerpc/kvm/book3s_hv_uvmem.c | 2 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- fs/dax.c | 4 +- include/linux/dax.h | 2 +- include/linux/memremap.h | 7 +-- include/linux/mm.h | 44 ----------------- 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(+), 147 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 4820bb511d68..8d699c8e888b 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -560,14 +560,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 79c49e7f5c30..327f32427d21 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 c9900aedc195..d8d79bb94be8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1117,39 +1117,6 @@ static inline bool is_zone_device_page(const struct page *page) } #endif -#ifdef CONFIG_DEV_PAGEMAP_OPS -void free_devmap_managed_page(struct page *page); -DECLARE_STATIC_KEY_FALSE(devmap_managed_key); - -static inline bool page_is_devmap_managed(struct page *page) -{ - if (!static_branch_unlikely(&devmap_managed_key)) - return false; - if (!is_zone_device_page(page)) - return false; - switch (page->pgmap->type) { - case MEMORY_DEVICE_PRIVATE: - case MEMORY_DEVICE_FS_DAX: - return true; - default: - break; - } - return false; -} - -void put_devmap_managed_page(struct page *page); - -#else /* CONFIG_DEV_PAGEMAP_OPS */ -static inline bool page_is_devmap_managed(struct page *page) -{ - return false; -} - -static inline void put_devmap_managed_page(struct page *page) -{ -} -#endif /* CONFIG_DEV_PAGEMAP_OPS */ - static inline bool is_device_private_page(const struct page *page) { return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && @@ -1196,17 +1163,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 25d2b2439f19..d3e58746f2d2 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -623,4 +623,12 @@ struct migration_target_control { gfp_t gfp_mask; }; +#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 16b2fb482da1..614b3d600e95 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), @@ -87,16 +62,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) @@ -152,20 +117,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); @@ -361,8 +324,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 @@ -477,16 +438,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); /* @@ -513,4 +468,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 20ca887ea769..8c2430d3e77b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -376,11 +376,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 519a60d5b6f7..4612c457d0b0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6210,6 +6210,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 2cca7141470c..0a12af814065 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; } @@ -878,29 +877,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); @@ -1142,26 +1130,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 Sat Jul 17 19:21: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: 12383823 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.6 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 367ADC636CD for ; Sat, 17 Jul 2021 19:22:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B175D6115C for ; Sat, 17 Jul 2021 19:21:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B175D6115C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EFA3F8D00EC; Sat, 17 Jul 2021 15:21:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA4F98D00F6; Sat, 17 Jul 2021 15:21:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF9C78D00EC; Sat, 17 Jul 2021 15:21:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id AB6F08D00F5 for ; Sat, 17 Jul 2021 15:21:58 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 62C0B235A5 for ; Sat, 17 Jul 2021 19:21:57 +0000 (UTC) X-FDA: 78373049874.27.975BB3D Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id C4A352001713 for ; Sat, 17 Jul 2021 19:21:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PAzu27loPkSlPJH3bEN3cFJWEFWLTJs29IHZ/QHMf/rCS+oy2ncLVeBMVLzAteB8yEaVJQZhH//eTSn/Q2d8/LphwI3ImIBAff42JUyzSduWD2eiulhdW8Qm60OBTqDxW/BrW0wbLlqGFWWgMdaiAqoLOiY6AcvKfbTBQ2se9g2Rx48s2Edawcaj2qqHwpAm5bichbmWwTcD573YV685PHfm+cs/E7oaqy5vl93QbkGvQd2sE8D6XgVuskVR1q5/46kxSHmKS7GWh+sTPfd1EYygM/bHmCPoOXhUgM9/AjNSO3Y2XYSHq5sJC6YqJmgex6OEDzdI1XRDw1KGTKd3aQ== 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=vr2ksBJta8l7uq6fRDppZyPAgRDq7rGlCaJ8JfjVcec=; b=Lxkmxsi23mdzlbDmyXd+M37sKul71ygni2BF+u6Bn2X7q24bogOD+2DLz385ZTBxtHWYQSngN5E0QuedU4N29rqwoXRvq4GgLYRk7bfTE16sdHNZvFJMYG5Ix/3oCQxKCGZmHApDHFOgKpVyuyxd+eADWChJjuGagI84y13O15C6wc1yMm6MO55qpYX+bMEMtmxzkRCoRDOs6q/W+8nBK25JCvLw0P1FYfN5Prbgg/qfJ6I26ZF9Zr4HfLGICuWtr339cZUOpNfnR9dYx5pBDZejmnBUoWfAq5NE1AVwTR+4RuCuWiLNSN4lFXkkp47pRvTXrdw1YDT8NbG2YCdm0w== 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=vr2ksBJta8l7uq6fRDppZyPAgRDq7rGlCaJ8JfjVcec=; b=cAJAVz3Yo4V+I+L7tKW0d6+Am7dyZtoidPembVrhqFNJb4FMq6iU8vg5SrKz+jMJj5ATSzZFhUKJAIrrdeZElcbKqqiGRrVTvLeGRaiJK3rkayWoDqcuntiTraFxhd5JIsT17jcEasVudicbExAGkhqKlrdBr7BaAatB8tu3gIY= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:55 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:55 +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 v4 03/13] kernel: resource: lookup_resource as exported symbol Date: Sat, 17 Jul 2021 14:21:25 -0500 Message-Id: <20210717192135.9030-4-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a55bbd7a-32e6-485a-a134-08d949581f29 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ys50DDNocS/FyRk/bC/1wv7zu1EBEl9cqhKE8HpHm5HDO3dAmaEdqy2OQ33P1Qh3iHlAawQ27c+cAwmcMZzIPpmy18rNba74YYwDK9mqHOnSjllKxRcgCz4vzlKYUPs6DWbLRbsrM8iGA0EzQvAJDpWkQfRxhV4kUPNdt0MyeTS0MrlboyDCBoqNFt/NXoDNoKjfQqRRPCNmdk2dl4Ajkymogftu3CBIaJlQjDH1Xf2ksj6dc2SgrF43bX/iItytzmVKANhwfylFAJ1cD1SW7txwVMkEhMXwAGGPSlKsni8g8Lptxkp9hhJzeiQDgolmr7PiETAQH9DI13CBmZ4zGcOPYwSwhYzz9vyDW8yZ/3nO7blmBjt9fGv341GspVLNwjyYQTvb5aqHyjOKuEtoyWqodLBrbklQN29cRyuXLZebzOFWF6GhxE/g/NpQWUmIuvEijApuGdqkHgAGyI7Ea4Vrlwq4GznFvbQPNwA1g+BLjiZF2lzJ9ELHENkEaUBzrSmXThTsyfMn9Ahtg8b8EBzcIoQljEwe9RPDhusbYSCcdjw0fakuQkMt89+cVoWyFQjercLii8TLNRJQdNt6HkriPeg7hS/yIwHqxF0vcjGUlSrpailIEI/Y4gp8K0D6I1c75X8lxmSlS9OLIH70XlQL9kwOX9SeDgY38A7q5Q9PDkhtUlYlOix4HwuCvQ14yCCE9EINc5eiOTX3IOUBxA== 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(4744005)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dKPxX61qhxBC2Z8tjRViJZWe/Nk8URmLMGKMgwu70S/grkbXyNByZzy2h2Vbng+eQO0gbisPQ09YBf/MLY4IoAcQEkbpL2LRTfPj64hbx0etBZ6Lve0yNen+3AqJteL2UKJUKwx2w/GLHjNg7Uwi0JYSfPE6JG8ZgdNXEbgHlbA0Pg6EmXsa0SMFmTnNx26fGYTtReoUu9t2ME4EF/SbfAWhm36VCmzZF+Hwi5GWx2SEoVR7z+J+HpVF/rJS76kpRr+6fmfNGh0BTJgc+PXDSd4nStrZh6bgBxBfi+t7oCMWjCufQcufm1zXduWsM1m91hzp7RGd4iYpN4Un4hr7AlhkcI5l1N9OafzXHZ2vW2i/aQL2vP+t2gzuYgpLvqV3oHAZBlLmUSVbFWUrrM7RxQMMaVmUKnT924pfttsjcD1HkXrIS+IbpCoIbC8VwOtxwX403BADNcnq1MkL1hzAzM9OKQjDCqix15C5HzidWWVn8gHFu8kFXcRm9i3UdsxP/2nl9lSZNDC5kFu3b6Zdw+iD+yX6ZfAyUYjiexMbkEfnYlip9qzTIcIlDMkFsFFOQU2VDiLzCwcbrYHbh9h0g1omNbHteamMYAoRFqIJTACzJN+ioZZOldaf4HXqbntYoYUZ1uMH93MuAspuVNNJ3ON2Q0NeDTU5LjNzQojSFLjFFKZN8C4X9/4IHNOzTrF9vvfFQmHqJQNP9w03IkJ2GSd4nzDsjp3mjI/Wb5DQzWBDyh0fKzMc7pA/ESHieJmi9jqdR/gwQl/VJ71JbED7VsDcA4A8wP40IBev7EAehoa1+dZsS+e+9S+SZALERLxQnGOoN7KVGAO5ri8VqxxUGuTYCSM+/BPiJotbCYDSmmoYPk60hR1oNlclZnmMi7pLFK2wxmBdFGZAMAkyZ68FJaHuMyMVOS/uQ9Sb0NnZHk5U611yWeeuQDrjDVQlZTt/bIMG0Vi0uudhhmn8mYLxgUJxxpr4X1wP/sZiQCNFhuISlx+WULxq5wy05MlhfW4dnBKxYdtO1NMEc+96Befm5PHc0GQ/0OALLe+RTRuz3eqLMkl/6Z0PhH32GFV2WLGNpm9F16C7fdDOMbCQ/0vgBCSgcc3zpYlQez5pjOP2Ja+dfIq7KqXKBYLf+TBhsxsWcxU7e3kktvcojA+kQTtJtX7JR6CytIQvTAvvLO4VoI7bn0l+dDidHO2aOP1ZYEtGj40AUaO/8+m6mFWnRFa/C6jrjvF3ZkI/uKRpEakIi4WvCl9pWItIRLQI2NGYHfCE5piXRpP8BL/z/5RQPDHc1UK04cSChFLtqJ9P2unKpJKU8uDFaSE8rErB1FLXFpY5 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a55bbd7a-32e6-485a-a134-08d949581f29 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:47.9801 (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: vIFs0G4bk6mMasObfMBbRMcmLW6P3+tOdhllSRBgnkCE18CiR4Lsabng9+svC8oV86mrlrg49f6NBVergYCZlA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C4A352001713 X-Stat-Signature: ayq3uoyhmj78cgkheitrj44m6cmwh7ep Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=cAJAVz3Y; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549716-705999 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The AMD architecture for the Frontier supercomputer will have device memory which can be coherently accessed by the CPU. The system BIOS advertises this memory as SPM (special purpose memory) in the UEFI system address map. The AMDGPU driver needs to be able to lookup this resource in order to claim it as MEMORY_DEVICE_GENERIC using devm_memremap_pages. Signed-off-by: Alex Sierra --- kernel/resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/resource.c b/kernel/resource.c index 627e61b0c124..269489bb7097 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -783,7 +783,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start) return res; } - +EXPORT_SYMBOL_GPL(lookup_resource); /* * Insert a resource into the resource tree. If successful, return NULL, * otherwise return the conflicting resource (compare to __request_resource()) From patchwork Sat Jul 17 19:21: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: 12383829 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.6 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 B296CC636C9 for ; Sat, 17 Jul 2021 19:22:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6D7736115C for ; Sat, 17 Jul 2021 19:22:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D7736115C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F1DE58D00F8; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF4188D00F5; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D45468D00F8; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id B1CE78D00F5 for ; Sat, 17 Jul 2021 15:21:59 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 72FF3180AD811 for ; Sat, 17 Jul 2021 19:21:58 +0000 (UTC) X-FDA: 78373049916.38.038B7DD Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id EFB962001714 for ; Sat, 17 Jul 2021 19:21:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MuU1WKz0pcQ2KNyn0dUBjYPKgqHsnIdz2HMYV1+lfJjM4af5z2ahNV/r/8L+1RAtx/ScWRp/SL+53u98w4BoqAOX+BGQmcWNjwLHQwjiG9JP1ox012pv9yU1bzJpCu19m/XxmbBdu6apj83uyhZbglhkt+6SYZoqpRWQA2Y40pfKFmVomicC691w73nkseZI0G5MYf+s/nY02Igcr4qxhqVLPCcLNzmeVmy1U5yY+OtLw3sQbrdiZDkzcOPpz275ubUfju93iCL9TO7UirdRkCTKraJKJ6rj+O5hdxMNAtJ6CTvTZx9MmIFAFW/XzGov+8NWn4yBhRNOiZ6Iev2bcg== 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=q8+FHqCxZMWE2MGo8d+i3OWYO1BTKn18xW++LCna8UU=; b=aW1Eo1BsCLLTAJLcArQd4nyhXVZ6BW9uIksAUX/68kri5agE8tKBgjEa7OlWYbufovBK6jY4xtm1PKSdp/YkmvkLt19RbesRfFxMw0CB6kx3ZmWUQM2C8qd+H4Vsp9bJhehS0kcd9VH3wDQdBE11BLYntFziHpKcQYX5PCAjVKZkDDJhNwbC9IQmbgYDmsuqu3AP5L76vCQ0QcW0urI0OBwf/uPhM8sGf01NxJWmdYqSvzzy+2gRyaS0Tq5IuaqU1CuFDqVVJIghu8UNld9U6pT4oQI/0l/bEUuU64drARBE8MF88t8m0hxj0rkqAnPeMskV18DMrTWSEHrddTKxOw== 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=q8+FHqCxZMWE2MGo8d+i3OWYO1BTKn18xW++LCna8UU=; b=TQhGgDTPYsdEOJtDf0elx2P99zppZ1SC244Dtcz4Ljr+p805Au3Kz0ItrhP70XiJjSp2HbBwTe3D1LC3tt7pRu+ygUfqz9HYvehVCvtUSfmkabwunLossInme7/DmHELt1rNubBAPGIEOncdCXfGPOr5xbGlyKQlpIVlohCiTzM= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:55 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:55 +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 v4 04/13] drm/amdkfd: add SPM support for SVM Date: Sat, 17 Jul 2021 14:21:26 -0500 Message-Id: <20210717192135.9030-5-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e61aad0a-3be3-480a-ef97-08d949581f90 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1RQ93P4vX9N3CaGp9x7gxyHCrctCYYnpZ9wT5Hnq6mNW0gulF9xY427hgFXxBnLoWzED3KeHiwdMRmcQenFXVavrqLfZzxdFbWiG0vLZZk1RAzDRTElkuWzbvyNRN7BM0fUbvlOZiVHyGEs8dqUVbxteTW8Fb2L1MjYpW0bpI/DCy+lGxkSRntPtVD/NhREoTpOse6+HXxGqWVGYaGppOTiXcxjWSsGQnzqs+3OywHhbwHMeDCX4gcZmCNhEeqaVisH4eiFkmY6G1SmXGWIS1op25MRyE7/cXPuZcdEYp/tVBB/OxNoaOgEnCPRbaXaK+hDfVATDZQSlYvrOm4avZtZVpXP1p6XHWkhqIVCBVqh39dfGqb+/4wKYqlI3F7DUv5m64COnsyGB0/aJlqNkOMhAC49i8XeDpqbZQXLyYzUfQw3HyKt9Nssq0AMm03fXMjrY+hDLo/+4BOUCmzchEDkkAM4Ah+qRVFxcO8wIJZPI4u9wvyadC/SwR/3pdP2DcX6MBBY3gs0R+tnYuH8/C0S6wfGF8ydxFNHwiI2egNSG9+HqA0MAOBYsw9w2FWGGIC5P0pXlk+JHZ0Hl7fsaEOBQZjEKb+0fjNG+e18MxuSRN3gmQbRME4kC5DAZVp+2zrvx++gJ35ApyvIHBJBrVp6JLauljzdqfNne4DSzplrJPr2a2B6i4hOfPs8kNoKGA73JDfhb6Y0vYPorRGE8zg== 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IV56DqPM12YVxLqGBz/9Y7JuuN4ilJDgzNezzLhl1xw+wYDtpDq4l70CoyTbMug4U2bS05pXgBL/kWHqQy3HCs9ODIb2WHIxpVjvb2CM4Kr8aER6CFcxFLqMxLZeyyG9Sw+5BVItPfgkHgc/dtYegOSvP88ZEf6tWWy6ilLXk3kJEQkxlHdEVj89lE9g3G5bkbQ2LS19/a0a1KAgbpHHE2ot9t/rfD9wc+1R6SPeh9b9VxlEuKHFC10fchJjKN2OVkdKcCKNRx47OsjOmrvKXDga7KlYc9eu2crof33fiFe7FP8M+XLRzlC3De8o7u7Pl2AnTCsNN/w41QPOs6CGTVE44yC4BYGq07Vx/Vgqos61VncGkIVokZld3T7l02gGr2rU1FD8IERougln+6zKh/M/k6bVo9JUA0ytok/27+Z6BbfrHqJqwmd0T2yHZxGdZfoZhrY7zvu22Svdzvw8aLzgGGHXEwTnbLD9+xmMo5E3NeGy/mVtisXbL3MLuhaNPGVXH/1rUXWgj7LUe81HJ11oJcbBDDcjEl6/wfCngJ1yAIruW4y8Lgh2WSLvOt7ae2yYeRKF6yHPlwDlMZzm/l3K+Vv4pl6KOfwKKb2Q429UjuI3bvVJOH/RrH6qOcycPxM/PbQ9WR1Muue8SSzbkWdptS6nX17+FhwCT/zwkYEC91FdOHsQaa7xNbeLKv1s5RwcFZr7HTASdRm4W0XxacQgXaBkbpSbQUFW++oNhUE4rThB2wbO9Y3L9scR2upyBQtN4cXPE7kKscExN1nq27p2mCkoQldX+HOJSMVFVie6/z6FLftXg+shLXROktNMccdd3JNsLu1GXgf7wAWEkHcAyL9C/Suj47lsapziAZLqFwDhkMzSsuF4tbCe1z1cEucT86n2k1raRy3ikzcuqpAZ1UWPUy5pftH0NsnhAuExLfkKDKF1z/qS1xhYbKQgvL5IAM9xht7VaszbkECy2ZI5qR+7zQFtarZSN0Pyg6xQ/1j/6rSE47VfYoN7Cz0Gh5p/JOdIaPzrbEtJHW+v1Y6bXa3aMksy9/0jbbj4Xg7QZrbrHf4lITQBhqWZpo7K8+sCWsNiIZ5ShjfxFvSg/2ckVjfnwbdRJxdm4541G6iB+QKlfx12TqgB0hQDM3mPwOgTxIhezWsjDvLcc6vC4j8BgksR5Zyi4G4rRxLVwcZLqbb3Cfy4yCtqknss2Su9lZ1C4qQRZxhTJSwgL9XSBzPD10J50rTJaY1bDot5F2QyLvVsNsrVsX6WRmEVUs5MjuapdxMnlyHtQ8RMwbmBAIjl3QYvsxn83ZfVFKrM8vQVi8s0i+7vvDaWMRHqUgIa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e61aad0a-3be3-480a-ef97-08d949581f90 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:48.6491 (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: ca621ONh9LNu0mPFrw27Eyk/tmLHeGpGe3BmnapLP8/0LzLMlZWCzDPUedimdY1kTiCeyYSNPKelt4UVksOMMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EFB962001714 X-Stat-Signature: 6hieff6kfn5d7j8jju4o5b6wn7jjzxqq Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=TQhGgDTP; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549717-462203 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When CPU is connected throug XGMI, it has coherent access to VRAM resource. In this case that resource is taken from a table in the device gmc aperture base. This resource is used along with the device type, which could be DEVICE_PRIVATE or DEVICE_GENERIC to create the device page map region. Signed-off-by: Alex Sierra Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index 21b86c35a4f2..3e9315354ce4 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -916,6 +916,7 @@ int svm_migrate_init(struct amdgpu_device *adev) struct resource *res; unsigned long size; void *r; + bool xgmi_connected_to_cpu = adev->gmc.xgmi.connected_to_cpu; /* Page migration works on Vega10 or newer */ if (kfddev->device_info->asic_family < CHIP_VEGA10) @@ -928,17 +929,22 @@ int svm_migrate_init(struct amdgpu_device *adev) * should remove reserved size */ size = ALIGN(adev->gmc.real_vram_size, 2ULL << 20); - res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); + if (xgmi_connected_to_cpu) + res = lookup_resource(&iomem_resource, adev->gmc.aper_base); + else + res = devm_request_free_mem_region(adev->dev, &iomem_resource, size); + if (IS_ERR(res)) return -ENOMEM; - pgmap->type = MEMORY_DEVICE_PRIVATE; pgmap->nr_range = 1; pgmap->range.start = res->start; pgmap->range.end = res->end; + pgmap->type = xgmi_connected_to_cpu ? + MEMORY_DEVICE_GENERIC : MEMORY_DEVICE_PRIVATE; pgmap->ops = &svm_migrate_pgmap_ops; pgmap->owner = SVM_ADEV_PGMAP_OWNER(adev); - pgmap->flags = MIGRATE_VMA_SELECT_DEVICE_PRIVATE; + pgmap->flags = 0; r = devm_memremap_pages(adev->dev, pgmap); if (IS_ERR(r)) { pr_err("failed to register HMM device memory\n"); @@ -962,6 +968,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 Sat Jul 17 19:21: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: 12383831 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.6 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 176BAC636C9 for ; Sat, 17 Jul 2021 19:22:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A59136115B for ; Sat, 17 Jul 2021 19:22:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A59136115B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7546F8D00F9; Sat, 17 Jul 2021 15:22:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72A998D00F5; Sat, 17 Jul 2021 15:22:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E18B8D00F9; Sat, 17 Jul 2021 15:22:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id 2DB1F8D00F5 for ; Sat, 17 Jul 2021 15:22:00 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E043122BF1 for ; Sat, 17 Jul 2021 19:21:58 +0000 (UTC) X-FDA: 78373049916.25.971B403 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id 7BB0B2001714 for ; Sat, 17 Jul 2021 19:21:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7WvIgMWzlhLFDjL2I1n5wSyyUZwvmqgZEucFBO9gx/dHh+53tZ6kHiJqgRIiOYY33w9JFwQwsDk9SJSsB2qpgg4lHpu6UeHCRlhHOhc8ff1H73Dw4o3DxtxVOh48ECFqu59UpG+f6cRmh9h+s973Tu3V4+2LFWTEoEuoc1T/scklkOM9qHvHMsa7YkpqmgoVIA26eIAQZ8crXVrDt+1XZeeK+mE00E2MJFiFV1e+liTuDsuURPoVwRBqtfq1XhyxTwZ2LPqPONGfaKp3Wg+zYaCeyw8R/XgrTlc4ofC8hpioXxExEwtM9cFSrBl9QbS1pYNDvETWT2krIiDnhDxOQ== 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=f2ckaEYhYH5EBOREpxdvq67kPzy/ubBjQwHjl/1feIE=; b=mCa56c8Cdshcx8FNTbNnXmc0rACFqWimefgOcTj7X3XocFxTqCvgk4QbZr6aGBHPRYbkDplzcCqzFxGr/RYK4d4jdxZmeAb1ZBJqe/F8JF5CUwqF86qaiENhRXKb6tkEpw+I/bgpEC0MTrGUQmpS1oWz+Du2Asx4WtGWl6H0PIrMeXaQ4b/KpmDpDACGivjccVfu6q+tsBuXa0bIBC8gJz0rSCP4SB6P4vA8XAE/97/wBOmEq2pGjzy9Aqnr7nfxkG1XSX5K9LM28cOi83lUOKhF56X9fAc1oTBvmxmsRWXcnDsehQYqNZIf8mcA9dgVDV1DFqR7JyB1bco6IyhyDQ== 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=f2ckaEYhYH5EBOREpxdvq67kPzy/ubBjQwHjl/1feIE=; b=i76xfnCh9uQwxCh6GQXmsKi4J91E/6QapwOUhgPTfVhfKU39PW/u1epK8r65r2UT/eZ3Ea6HIKz7CeULzfxqg3hG2FzcbZk+jgSehrp2bKBmZF/bj36v1nIOrbFqrBORiFe4747nsuhqS34izNfeEBchhbi7YoasJcrvkep9Fb4= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:55 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:55 +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 v4 05/13] drm/amdkfd: generic type as sys mem on migration to ram Date: Sat, 17 Jul 2021 14:21:27 -0500 Message-Id: <20210717192135.9030-6-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8f95946-c051-4d78-1d72-08d949581ff6 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TGMsnx9RYgioKfhg/oMqvMu3oXZf0cwYcmCwHTZQ6I5yP/Cx+gFXfnlyx6UaItCZHllTShH80ioUD5SHOFA42YyumvoHeXiEmXX5YCJa66RC8WT3qe59CDaTkk2CWvoFAepfOCaSdVD2dZ9tm/jIClvYin9ZumpIq76PldBbKVWsRDsMDQ0ZoqJm0JmMJa7u57Lar4iqhP3MbmKTX/+YjCDE/8NXNgDMNWhZSQMzSuJxw5lPntLmfPHQGj7UQKWWwFVBC3pibE76BwPEPqSJ5e66W6ybHinZZu0lEJH28VGfItsZDZ7lxcmyHzGjRY9dzr7yfqQtJ+VXx9emvgfoBxOZLikNdpU761T615UxmgMyckOnbxvHzp/wIh5YrhYS/4VVtB9GBLotA5vFBlB4+FhOI9gd2U9twqgLprwNAcyxMJHz3f79nKlJ7VO+sKyGDFgaR2+elCC1k9Bj4skpCU58BVHybbbWujLSyy0N4RzPgZUEPLBkbcmF3GRYPgX/NuBRmfYwb227j93nB6H65ZQ7aQdOZAb6iaNDTcJ76eB7FG0/ZLqSeihl70H0Ms01GGU05adWIIpTuztFNBAA44SNEjbde7cG/ljwAzWatpBpk70p2WKm4zF9mTHcIm2SwOMdTmZXOOXsVC/3QPCr3OErSFb2s7SWouSUp9ml/M4yuoGXscpZEYJddUjpBRI+OcmIAUZS3MCOHcH1AU7Zac2LRRVCw3QzitQvtgC5les= 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DJ3rMfjwjPLcWxRqUTMtFOHvI/iPm+rdt4KvKiDbLBrsGpL1kIrshuvkVYXNE7UdeYeGonzuCIXfbhimB0OJx4d80S1BbANPAQFxfopzbIfzNOGGiV22WPIK7LNqAQ1HbjlzpaBjxXmboe3hSO2MGPtbyKi4Q8LnYPptLy5Ektr58zF+QKDQkE8No3tZRdauSUwxBgr+qy9jRZf7KeW9aOHEpD8qFcUw+hVdIKpNhrMKba+rj5g2Dz/SwzZNzOA4MywTUvVLgIDEyJDYaY+DF0wjYpyfKTlWJAXHfZYBdyTfyQ1j3WsUxkHShZ7luvuUw+0bYtugSBUUiHRpKWWgDKhE7rdg9n1P2Oh7DprEU/WcUkeFHevTu2e2g7UH5vBr/kpROAG/2uH4oZnPhQ1Yp5QhI/Jr4EtQ0HCE3akw7wVMrGICqW8spsRbbwNEehTsVMdhWq7R3RKQGvdLFYMpWFG6gxQLx3Qhu2LDpWGWNk/oD+4Ooa1xIJIyZ0fJsDEGM4AaHw8w35fcftUGOCHjX3vk7vegSxLUJSVIhJbLWwgaJs22wEbXjCAKDUYp7gkGyNUZk6+Yi+QKJApOl2ZgsccbeMiR6XS9VRepQbonOD9MFowQNpzibCSdQ66IzmZd16WgJyYjL4gg3QEjYbL+2cT1n57Fbh7SwOoiq4+XHkaGFd+eFQfoEiD/0yYWsbrP7zidKVPyY85nEGHY1abyxTv/NHfOfA6zga6xERlXftPbI3T6VakKqSZ6mkqRtrmRzkcGTxPs+DGeFT+ozp4Ykx09gR7ok8AR+/+sd+DWjhc2a8B/KVEswArKaTH2zJm5DUeAisg7U8vf5Dx16rUix4SgI+YeugzC3gXJcwesiN9M3hPz4Qiv8wRHU+PvcQloeKfUaEF629kEbrZVOx25PTuxwKO+hy55uyfPw/G7t4SbfB4pCOiVs4BXBtff9RvZW90hcc+nL6Q1nh02aSs3ki8ctz0A2zHosWbbYdKO6AhJA3ByQYzON32H5S74vs/jz3RajXyMay3JgODYHQvv+HBnXL/jjwe78s9JhdK7oSwNU7jFffateR3mgmKyly8ATVvJPSdI6iaNhnplMipk3yg2RLH4NAkSTSGWofajof6UDjCedAkzPpRqzHu08Ddi5AHqSh1OoejB2XKY80/Si8+kShALlMUholcIYMoi80NZXojCVAnRYyb8TnHgLD8Gpwe7czSwMGmBQGfY9jVJnulNTfkePzXSE8Ep+66MMZlR+m3UKZtB1CvdXpvJZOR05YGHwriThuV/IjLP5b8gg0Q3wXEFbg7bVfS1mM7HopJIj4U908xonLsJWNPO1DIb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b8f95946-c051-4d78-1d72-08d949581ff6 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:49.3222 (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: 64p9Vxxf8e2JBsQNgwu1Ae59xSyt6veg3Pi92uDQKHRZcpglyznuMEhmqF+GCEGMuf+iwAB0czSwIZ9NEfNbzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7BB0B2001714 X-Stat-Signature: 64mwfaa4qnbtx44cqfz6u9yps4hto445 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=i76xfnCh; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549718-157115 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Generic device type memory on VRAM to RAM migration, has similar access as System RAM from the CPU. This flag sets the source from the sender. Which in Generic type case, should be set as SYSTEM. Signed-off-by: Alex Sierra Reviewed-by: Felix Kuehling --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index 3e9315354ce4..fc491bfc09f4 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -664,8 +664,9 @@ 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); + migrate.flags = adev->gmc.xgmi.connected_to_cpu ? + MIGRATE_VMA_SELECT_SYSTEM : MIGRATE_VMA_SELECT_DEVICE_PRIVATE; size = 2 * sizeof(*migrate.src) + sizeof(uint64_t) + sizeof(dma_addr_t); size *= npages; From patchwork Sat Jul 17 19:21: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: 12383833 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.6 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 2AACAC6377A for ; Sat, 17 Jul 2021 19:22:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96BF161167 for ; Sat, 17 Jul 2021 19:22:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96BF161167 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6BA078D00FA; Sat, 17 Jul 2021 15:22:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 668008D00F5; Sat, 17 Jul 2021 15:22:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E32B8D00FA; Sat, 17 Jul 2021 15:22:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 206998D00F5 for ; Sat, 17 Jul 2021 15:22:02 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DA48922ADF for ; Sat, 17 Jul 2021 19:22:00 +0000 (UTC) X-FDA: 78373050000.21.AB1AB62 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id E9C57200170B for ; Sat, 17 Jul 2021 19:21:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9quswX2DBRwiXDgu9rth8gN254M5xItIezkgfaCom42j+4Xsp+VCRM3qzUl3WtIMbac3TS3F+HVmtUslPPzHH/my00MAJnxx2NSBrk7+Ii9mvkBYP+6+34r6enWZ1fQ8lbKCQNYYbqLZVlIZltaZzgeYA+JVDw75+EVP3Lhd7HjvBSnmjwLHWOW65hva8+6VKkOa/ID1h/erRv5QGw8Sof1a95IUi2TflBnY/Ys7H8avwewPtrNYiMf9/Ih56fzpGnShLNI557O1gXtALLr5eNJx/fEvC2hfebKBGgFA2L7Nqm0rHDYinjtcQy9G2XdVyMWxo8oYiyZp1cIIuUL8w== 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=t+7nKyjfyLOZihYvp28L3Imk5sdJ3gBsKhRXrSh/IuI=; b=T5+Qx+8FCnVBL27ueApHrxDbzVRXxP7PuF1lpIMnm3ByXCZr3weoTuG29EvfmBS/xfZDEoPbo5MkDnIXoz0F2LbfexGW9h4hQ5xVvM43Ah8UOoM+0m41Z+Y/fDXiIiLdxpyJ8rZMnxAOcEhhNmLAj5TvZk64yB6ZKo7UXFH2cQ5suoLaUdj+SWIE9M3KDxMIFVBMc7Zr7TMAPNLHz5T7sXDMkXKl3QYo9593d7TcNz6DA6gHPlRLORy5N0rmtyeF9qAe1A5nior1oOW7INUU0V1MeIDDg+e3TqToxFrBfLs9UGKveBb/LVK38NMhLuDjY3p2X9dbAlhy90YBbq/NGA== 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=t+7nKyjfyLOZihYvp28L3Imk5sdJ3gBsKhRXrSh/IuI=; b=IAYivu5vasuPFgW3f42ExlAvjIyQXs6eZ94zvAfpLWdtOhQKXdE4AAE5qZOsW6NUuyN3vW2SFgOM+pTCfKW1yYjsqouVxs8LXf/QrfAmPyLdBGBfC3/HLf3se3KMeX+occZGkGwe3GzzEFXXztXXtlhA5/jUldRwyu2Hi0ikVBY= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:56 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:56 +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 v4 06/13] include/linux/mm.h: helpers to check zone device generic type Date: Sat, 17 Jul 2021 14:21:28 -0500 Message-Id: <20210717192135.9030-7-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1613532-b24f-4ca6-8272-08d94958205c X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:156; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A7tpfG+MChFyNDi47Jsq+myyhH20SqoFgf2qXmPqlqqkOh8SPCOHoiltA8c13qLvqjve4ocTeNUcUhlYMid5Z/PIonLXTnV7iyh9zE02Tmzc2pXIzoPMZo+QhkX1Pfr0/HowHh2q7AqLMXJQ5T1wEUfSJM08v+pxcFeRleyN4lGuh1lNcdTC4JX02bWP1OllbAZF3SbOAcwKsMYiGcDzNkBBypTkPCawQxww9ZzVEp07wuQoLAjc0yfBSl4HFub2aFf+5e0VSvJFRKLb8+B1gVKX22mgfq8m+gwqvh3L2NBhUDR1K9LwC+rwEJcvy/2ECJHwn8ecAR8G0PK2kQRiBdaGVlLWFq/8Fm/T6MnA3QcMJZm0/A6xOFJ95vCPhPkoi5IbUlEoyqASZ0Ybq/QGm2F7kORDDfgoSvB3K8BBJw2ubrFryGRWKMA24kK5Gw9waZw8GXN3A5YMgR8vZdjhv1KIE0qu/j6qURq0HklJ+my+j2szkh9sxeBnP2Q0fPx1EFF9C6cAPlNJq9g02DGJMPmTtLIejqu0yWfcCRELVr0YKC2B1Zyg5DkffLDrqOrPjrgSz/6FrRqKuh5kY4/ft4m3crOapsXg2SqxMLvmYufeI28Qpfy6PH52/AA47ncBmYIylfVWiFdjyUPNXTCfjbIu2e0yTk3ZC+x/FXKh0e/KG5yQTQqAY6DlOKqNI+Fpj5CyzJ3OQKxejYvQLAivfKW82hoYIjcM9qhUmn5fJlU= 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(4744005)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(508600001)(66556008)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cQaOdrR+sS5N7hv1ro6dshtCacNUIe1Y1h4lpyK6ix7rSqYjqqxRcvF54TiEBIgGuW2yyLY6zKrEf0V60GLUXa56st+LXd4H6EsEyRypwyuA0fhivjpCV1ayQFZXwrfuN4UJIipQUI/SrJdFFrGp1r1HDC2rCWuhIuOuouF81wgZQErAcj3KGqvdbBnsamJ2y9bU7bEqYMcWpCoQKNnkY+5c6EeKuuzFX3nmWiythZbphrPgQV1J8syi2WL6x9eSRqU6ROpIzhJIDrvQqh7rN3MnVvMSvu7I7QFx4lKSYdliy017r3jU249xp4czE/rUMm143JI81R6gK0w5ItV5V2/dlxtnTfBJKZP0PHO1z8BoF05ujJ5dcR0CChKLMZgSkxXWZ3s0nq7PcyTOvyZ7hIS+gOi6m8mHT3h8ffpY+rtdfCfL1fCPS0ZbxjrMXSQbVmy/rz9arKYvuTKf6ERUkD82GXuC+zeB3/7Zq0Ks30yTdaG6jcUA40dW3VvooQFoMCHZq+EJSi5Bw6sWyIzp802dX5F947QybqwiMLPEtUZ3VneH7HNWMGGNky6H3RQYWwsNlnytzYDgR3Ef0aaC1QhCRkaTFPueUCzdcgaF7UyYWI4z506PT7wAehpVpzSMG2U3NxxfnoJpTRCFBR73mIzuvR28vpVwybcAhIXGeocr8f7s2EfvSMN8V0jTR1Qji1pOPHRQp//kgzpLQYtGHC83gZbRFQUoaHWN6+SDIJpR79acO5cylxt0LknwnfaQ1x/eZ+agLUdzYWv9+ot6e8Nm2VfeplBmZvE2Yu0ZDolrtZLRLuAOPxfNjUaAbvatcUwtzJzkkRVnGXjYCphWMRxsgvNwRHOTUHh/Vpdm3OLaHx5M0vZ9/QhTjx+s2g84Hb7O6yDj5P5X0nioodj4gCdWtd9M8wOl0lVSvy5rh+Mj4jKZw9qXnyRi9pMkewQRLD2fbI0LLXLjhf6N3iFfsvn9SRE4tLelWUAtUfcWnIEYhAyX30ENIcgVs9OeN49uLeYdqGN/vw8+VGk2mFl0yoIVoDg3UknesRvKoNF8HZpL1veU0kT4XBGIHvSvbPc4+90LEuR5Yq9ONx8vgkKRIvXAJePXgenysVULcRVODud5FaVNqwedV3NMFQASFu80wbSrI+5QDqqCZC29CxC5dvEfRbZazxNXjIscer0kTnRn0eJ6xN/RRATLYXjBwrWinvFCsWrgLGxWSJkfilKJglYNMTNf8Bp9AVG7Rv4nRFh47vqR+gLr+G969wbtsGMsVyuRZVYHsq4prhnBxpbfDJNdPTp6tVdYYY0zHlkGsbyQpbTfi7TjcDwqFsAPwtUR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1613532-b24f-4ca6-8272-08d94958205c X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:50.0181 (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: AZZUdmsY5ky2qdGqyGUWNKLYypvEIoLvILNTryIf9LrjIy8i0NKuN+b97K/Azx+1JC33d8VmLVgVaIAx74P5Aw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E9C57200170B X-Stat-Signature: pu1mewdwmeymezcj6gwn7yh85eggb65n Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=IAYivu5v; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549718-388265 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Two helpers added. One checks if zone device page is generic type. The other if page is either private or generic type. Signed-off-by: Alex Sierra --- include/linux/mm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index d8d79bb94be8..f5b247a63044 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1125,6 +1125,14 @@ static inline bool is_device_private_page(const struct page *page) page->pgmap->type == MEMORY_DEVICE_PRIVATE; } +static inline bool is_device_page(const struct page *page) +{ + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && + is_zone_device_page(page) && + (page->pgmap->type == MEMORY_DEVICE_PRIVATE || + page->pgmap->type == MEMORY_DEVICE_GENERIC); +} + static inline bool is_pci_p2pdma_page(const struct page *page) { return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && From patchwork Sat Jul 17 19:21:29 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: 12383837 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.6 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 928CAC6379B for ; Sat, 17 Jul 2021 19:22:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2EDFD61176 for ; Sat, 17 Jul 2021 19:22:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EDFD61176 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F1C888D00FB; Sat, 17 Jul 2021 15:22:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF4568D00F5; Sat, 17 Jul 2021 15:22:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6F988D00FB; Sat, 17 Jul 2021 15:22:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id A8F7B8D00F5 for ; Sat, 17 Jul 2021 15:22:02 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 63A0C180AD811 for ; Sat, 17 Jul 2021 19:22:01 +0000 (UTC) X-FDA: 78373050042.36.0A297E5 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id E5447200170B for ; Sat, 17 Jul 2021 19:22:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UAOkMWIGiUT9+bovwCrFqBKuQdso/xYFu7FdAj7Bd87Tzj1ObVwLdm1Y0uPK5pF6nBMDNBUuwQfWAp7qTah9zlPyv2+ZoSu0lpWqW6HFrP2o/17HhNBTqmxYKnGX2rEAtRImvog+pjwH1KMyJrhVXwC1iJbPxcrdd2bH2O5ZKGSZC3mG3ygRyavpbHeNqrNZA0lyQtpiH2feUlS+BrLUTs7V2hcMhTBEa/1Qq5xEKYVKC4BtCYwmC0wofpeQKVnpBW8BnEHyVx3dk35AIRICF57tMw6jJSEl8eJAZ0LSgihHmkXl2DyOBFuEOY1MCQ53Z9H1GavXv23XFuvaZZxlYA== 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=Y4+r/IEg4rDKbRnDMnysY04/FdE2VvCumV6SQrZ8RLQ=; b=Y5Txbu9MIESUJRApkWmBO9Siai0fotCgMUF8AQoMbsOxHM2K6iVQpp1nRFeQlFLVc/5mpvCG84QOqQhPIENapY2+0d4hFHJfg05wAUw5HaHBYwiDTD1N2R6ITmr7DoO/lBKaH5YF74fpqRPYD184yieeGtelse00UUFJPk915QrBnFmS46Jg0mPmWKZHc+jpFTmTmCR2NUjCRQURN3OGxh1NY9A63B1o4VEY6b3fpQSb0gGjFa7uqlcO4LhzB1ii/rXfUEmYwZ9rnhI9O3gGxksDpZNBYowEWrZa1UjMO8DFp5V+qdTLIoHLd3RYhgvEUQxHKV4c4UxK8D/3Kk9pkA== 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=Y4+r/IEg4rDKbRnDMnysY04/FdE2VvCumV6SQrZ8RLQ=; b=E4K9dcbicy333R/yJnq7OE4LDM5EeBgHbl90Ev+TMZK1CkbrIOIOtetdhDCMAfBKUvUadH4cL76nusjBIYYIdCQmwuWosKoI0EMHKtJ/B3c78JAvkrfFHBBWqR2YsMQBmcy/++PcIV8IHTO/7vI85kg/pPEC4lKK7PIn1bLxStU= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:56 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:56 +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 v4 07/13] mm: add generic type support to migrate_vma helpers Date: Sat, 17 Jul 2021 14:21:29 -0500 Message-Id: <20210717192135.9030-8-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d137e190-98b3-465b-ba1c-08d9495820c4 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: 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: YAn2JIMEjrfipjm4vfO9mBeSy6bG9/qOmvtqPBmAocevSDw+quy+ShOsc1Bj4G/NuEFwCfR5EVrOUINfV4eocv1sFiOAFvOitqGScIqIOxzaFZcqOVhRx19hzh/ANjuEpQn7b63EVPGyrX68LRHuTFukSpKEKTHIkyPKO8PAn22hrei8iC3xBfz8skbzgcj4a1vMQuvFGes9NkLFUz6d1TVKZEofYKgtvjRvQz22hc20LsSct1jpVyAm6EZq2wn/qtF/w/Jtrsld5Z0qVCzTl87O4wEpLUJuGGqb0f0xVscBVq4YEAyd95ciAyfqxTL4TsZNA/7O+HX3s8cdDx3Yvx/Q8Xq/LbndAsYTOZaD6vs8N7VXJqbicRtbgur8gz3Bmhn7JrIpLVUlo1teRHuJ+Ap4aIkVctym6/MyULYZXcSRNMY5ui9n5ciO8OCwtT32rJItqlTuFsMd6KUMsKrXO9bEpjHj5UACmSJmu9t6KXCdjmdL7AbIkNuDBp/Pb4B3qPLl7M0FhzHZZYo6XoPjxZyKSYV6LJO/IYOHZBcArde4Tsifaf1HzoEQZOcw9QDzTu2Hc95BOY3bcM6eNbL7PVcZH4Mnh5F7lONEDpanXYngs4HMpQJYW3/pFeSSec9k08EQK3dZZiAur4R69IeHpVZGyT9te4qQ+cv5lkvL1Mbcs2NkpzVmcmJO8SenhCFZoDB3NWAn8DEgJXZ5YN+vpSU0JDqxXRi69r2Uwgi+8XM= 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t380QsiiYA/318jCZ6HqbVL6eK3K7K/v2C5S3eCMdXmq4bnJY4S3Akp7UrHmuPbartPtep0EETxHTZwaP/nAn1Za/5/nt6QAHcN/GoZ3TZ7KtV4xvjRIahhYsQpwSw1ksiaDZx5NLcJKEU8Gttl+kQBKXfvt8VAhmwplqNqXbKx/XinYwFix5e0a54OQxahmBh78/G9HggcoADqHekAEojCXQrjaJCQzTHVAj/FZ5rBBePksMIVP6JBBWR0xTyqcAW63fNn7KE3JDAwzGM8ubxnTpT5zlLszJB9jcd5paO+syzijHcvUxKa81I/+yqoVGpY3uYc6FDOmRL3jpOxkhce2Lah9NznMmczpp1GTenihq9jxPxSeEgg620s3a4CZHkqBDTvHzW/Z9VdVKr9bL5qzZlYrCqd0IioI9SC5hKxPFOy+aihKaJ1KLFutf12LGc+KYTGa0S7/jyp3mwonYt7jONsH+QJPaRNYRXXUVUlTCaJ4d4KoXf0K68DV2AzRX4AliyQA+M8ZMPbO6x3N14/luP1QqKPw3Sm3+xPlrtv/5mbIOHZMXZMuR3CzyP/4VUAsxNRlMu+tck8affcS+Csx1sx6I4wmAMrH4+8gsWuwbpIIbEXbFHxb0XIPVef8t02o4cHhsqfWAxM6hhUAEARJ24Hwg0Ilqd4JidEGb30ZcUw2Lg4xNnenjyWJpz++ZZ+h8NmYwy45eLAOr0TNYgUF/3/cJZiH/ace96TrJQGr0tlTQiW3jUFEn5jS3nUh5WWAIxDyQA4rXvToGXkMwVcbKtCaqpiheiMykBoxbVlSDNPq7mvMYOtuC649rARqhAT6ZeEq/D//6Annn6WxYFW5QRWeNeqWq3LX7YuSB43CS3xQ9E+cJsxNM9Xsrh77zngkYKU3mmiCAwkyMxDuzvRI8oaTHnySLzKFFxPMkiKtvFwvYDhE3Zfi5yM6keFday5+UzdeWqI1B8OMpV+rXS2LrymSsn1qPy3s4Cjw+hjZyM6JEJXToXPGEKM9gxhT2wITLYdXov0M2wRf1W90GZWm1o5EylStfWiKZVP4TsfZbwVSJryjAAQtJpP1HfIVOBCSKNApyEulXgCR5Di/D+GmvsgmYqhRMDzDLr8Dw6IBf5qVtp5UfkeDcHzyAjxS6A4oT2N7Ka46aj9XnbD9lcfhh2RibX1QOrE39mRk/Pp2DtfxfKMDdpfPFuU9/LkLYeYsu2rFa4r8lZ6iq16SVWR5Nm4fEbkmJS7wdrmZsDrr2OoUxMVqzrWfNioLIocPYa3DkFn/xw5wWU6PFQHicHhCXi7soCUg9dsRGMuqyQQN1JcIK1TvNCxuIHVCD2/2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d137e190-98b3-465b-ba1c-08d9495820c4 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:50.7161 (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: JzlQhrrYA0aG+FokRuRQBTuOzlTOjlTKwQ0rQ/A+Mt4CwlRj6ek48ZlcDqbuR9vamHwg6Kr2Kja7kXaXnHbnmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E5447200170B X-Stat-Signature: zkackfbu6fwwg56wn361xrwutiw4cmk9 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=E4K9dcbi; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549720-590818 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Device generic type case added for migrate_vma_pages and migrate_vma_check_page helpers. Both, generic and private device types have the same conditions to decide to migrate pages from/to device memory. Signed-off-by: Alex Sierra --- mm/migrate.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 8c2430d3e77b..7bac06ae831e 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2602,7 +2602,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 */ @@ -2891,7 +2891,7 @@ EXPORT_SYMBOL(migrate_vma_setup); * handle_pte_fault() * do_anonymous_page() * to map in an anonymous zero page but the struct page will be a ZONE_DEVICE - * private page. + * private or generic page. */ static void migrate_vma_insert_page(struct migrate_vma *migrate, unsigned long addr, @@ -2956,13 +2956,11 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, */ __SetPageUptodate(page); - if (is_zone_device_page(page)) { - if (is_device_private_page(page)) { - swp_entry_t swp_entry; + if (is_device_private_page(page)) { + swp_entry_t swp_entry; - swp_entry = make_device_private_entry(page, vma->vm_flags & VM_WRITE); - entry = swp_entry_to_pte(swp_entry); - } + swp_entry = make_device_private_entry(page, vma->vm_flags & VM_WRITE); + entry = swp_entry_to_pte(swp_entry); } else { entry = mk_pte(page, vma->vm_page_prot); if (vma->vm_flags & VM_WRITE) @@ -3064,10 +3062,10 @@ void migrate_vma_pages(struct migrate_vma *migrate) mapping = page_mapping(page); if (is_zone_device_page(newpage)) { - if (is_device_private_page(newpage)) { + if (is_device_page(newpage)) { /* - * For now only support private anonymous when - * migrating to un-addressable device memory. + * For now only support private and generic + * anonymous when migrating to device memory. */ if (mapping) { migrate->src[i] &= ~MIGRATE_PFN_MIGRATE; From patchwork Sat Jul 17 19:21:30 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: 12383835 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.6 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 3D67CC63797 for ; Sat, 17 Jul 2021 19:22:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F277A6115B for ; Sat, 17 Jul 2021 19:22:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F277A6115B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6B83F8D00F5; Sat, 17 Jul 2021 15:22:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6915E8D00FC; Sat, 17 Jul 2021 15:22:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 496F08D00F5; Sat, 17 Jul 2021 15:22:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id 2227D8D00FC for ; Sat, 17 Jul 2021 15:22:03 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D45E48249980 for ; Sat, 17 Jul 2021 19:22:01 +0000 (UTC) X-FDA: 78373050042.31.A4224BA Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id 7C59B200170B for ; Sat, 17 Jul 2021 19:22:01 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aII6i5sIu6n67C5ztvv7a7R+5q+1vTfQwrKp4gbjvEONrRZIs3F9Rwj32uPkVqtIMnvh65naE0Z+2HFRmcrBOrBeKmuQymhYd1C8bD0ZpZKYeCOZD5A4/njalQ8tE5kBwsqrfzbRxRkV2xCPWluNN8+bFJHUj43/7UpUlSQt+km5klFIRFkSi84gQZXka2+hqrBL1EjlQdB9k530Tj/livtZR03YnTS/GjxdAZuJ74Bd35vnp/43OJMjw8M+bpTZ75J5tlIiiM/nkX72HTYlEWDHwF9upiT4remv85Z2Eo5WgcYxqkSpAmZBJheTvieyYFK1saeWZlE2uXBYiluXBw== 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=1qSk32SVXvhWrJNt560kEQMeseoXBAlRtyocaZ1Jee8=; b=It3m5wx1MbnYEb3vMs8heK1pkgJWmzC0wOCeedb5cQ5WQ1+1yWRRn/G5fClspKW6Ojwi4HRqPbxPD74q4iRk9KfVWomi0zPG9jcAAQgJAW7G0NtidwF6L1ucmVafttqdRsC/DkXpdWGEsjfW87OuLIizeK1aq565No/NLILUz5rkuH9INs/hbwbl3ZBsMMC1g0FjD9ESJQtu8zgZjb387EV8deQsLa4fjTMWTyarT1ITPe40bzOujODLO4Wk/1GCCj82QwCi3oMzl59QOmWKrbPLv5Ne/16qpB11GQzOwQn+rLrriaWg8XQ8aoxNJgKsdreismHGgZqvgQ4vL3oaTg== 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=1qSk32SVXvhWrJNt560kEQMeseoXBAlRtyocaZ1Jee8=; b=YZq+uC7dQnXkq3kDuGxY9lW06iqL5IN82ko8hQz8JNJdKcZXgmGudpJosYzEpIkbhrlPoybgA4l5be9hAjdH72Ff1I2z+dza11LJaz9QZHl04qIddlOO0dNNAbeA+eOkH0A4qA+Y8wShj/4nzYv1wDD61JndFAaucLzS6d2ognk= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:57 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:57 +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 v4 08/13] mm: call pgmap->ops->page_free for DEVICE_GENERIC pages Date: Sat, 17 Jul 2021 14:21:30 -0500 Message-Id: <20210717192135.9030-9-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b5841aa5-394b-4dd2-3937-08d94958212f X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: 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: tJaS3fBE5cOD/1p6E3ge1WDWZtTwXh431P267OBQUHlv7cQ0RPSDus84Rok9PXRt2gSqzdfnGjcTYmhoA4cTwlaRqxGjGW6fVdpUj/xi94qC6SGpFqulQhJq8ASx3dJALG4VhcjfOJ0OAslvpn+Z/SG/3f9isf3EMAMxFm+X1kjzM76238t5KzQ2mpBN0qPYOyefbPYIFG9g3S2wAJBDkMZZYrGm19T2R/YaoWs4lS9O6XHstvUiB3C8DJKQzLKQ1419hSBbZfRC8CxKznrKzaW1i1SL2bXmBR6dwcJgagcKjTmusLjLwPxanBUjZr4ttUyty1rezETGpZzHEaJKVtjG69kUDh7pt+F3qwiNDtqKrxTGGOwh5hY8sATiAYydR3ZyQ9jh4WavcWwYCqVspjbNOC5ZrhkxLEzR0lM+FVMe4W11V47NReQkTmbBDWAkSo4AFE/Wkf3uCm1Z9swsIltDlt/07JquecPBt+EGU2RY+jOdg/1ZKE6gK64pm88TgcCNjvIa0/7LRFbBLt9nop9Q1ZLZHZSKHwBmYuHJJqkyQKYg99EJsToGAeZtKaoNrw7mzcRUqbMWxt5/WH3mfrUA+mH4WyTFGD4fLDRPy7Zl7PMqgzAlaUnOaxGJh8km+y+RJ/qaVbbVEyOtnRByREBKyXXN/7jM9AVydCMcFDPAS+pcNWTwVeamKzDFIcMEkjFQypiKvP79FOk6rqplx3cGWNyYTyqVihwUxMhq2OU= 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(4744005)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: whzrJ2i7grHu6gRiRJWLWyad86I3x5Zk9apSsGYArhaQqBnfyAgr2CULkCzrgF8Jzu47NP8ftCunnSB+WR09fBz9VXfshL1vU/eZK7EZxQlikz4Z6VRYkt2xnORYzPRA+WRfkQTDML0nO/Usc+0zXI4qzJoLWeezXtlR/J4owT9WKBiMQFRGUixOJHxHlaX/0yYh5dnaxrDKia0KCr8wQfMtsL7hy/x6Aji2ywbgJf5ufzbOd5ykbkHrQHd1/M5drPe7k0VTKv/QwJjLyU0QmeSkHPvHOWzxvonrEQJeZhMS8Q9DrXOg7RAQytGxfM2bIfYBcHslfb8I3RsYribP4ClsaycYsV0oIkbv45ZeYXnLJlHLTU7B+gyL2c42MJgWRuA3KvXenyAn1m0PXe02CngvhT8qhoW5+qL6M2L9eZ+HiS3fgXM/ddKkKzjRF5CVoFjtdzet8DeklORMPE6xacts40kvlDoS8QLF6+Ji2p8A/A+4yqoy9FO/KKYVuOML9XkgyEXraCVWzJgCIvtdOy9QWED98Z9u06FGS0Ea26Miv/HWPzA54+42IDexH7+gCvsdoAwxuFQvY0eYQZWqEuXvNJt9+sxHyZ72BSfiR0cvCr7SMkFpJh+NykSlN44sOdZherGEP/xDpYHqAGWKiq26xGPBUtZ42BkNE2716pOzk+ZU2Q9Q/GqsAwwBIHg/zLY1pZQn6pjAnkizHg/OZKyOc1lUdJjBGpTuv4BEPDNjEp7NX2RPebDeiCPocdX6EbbrLzk0dWfv8dUP59HtWKOo3/01ejh/SrLvknnoXi430SIjCPNM4GHqBY4vYFyybgFdVdEy8suLUS4XhSlDP3wsC0cP5hHI+X+yJk8+FM47jktPqhoFwzMRp6ZHlvfnrIIp3LR0FISacVUgYzTCFjoA0Tz7wiF/wt94cHZ6Iu4gOQsDq7UlSexTZeefuC/1gXDUG8ePsekIvU3Ix2dEEIggTPCzUT5hj1GfHymS1JWqqX+e4Nfd49CWXt6YWDECV+C31ToTNM3t2LquYwzSqjR1fo2qUI95EBJRfAoEdH5hKQPsGlqO9uAiAnYZKOycHPiuGuI0ytzJl6BrWMTLjVkWHucgQO1SaSj4bMr9Ue8USRDX0ehHR8q5QzUQDo7yG0Odq515nN/Kfp7vWY6Fixoezx5645UqO/vcvQkCqvHjAoGttxmEQpYINrBiWIde99tqiPLyhh2BXk/eE0aTgVph0HXNBjLifDlEwAz+8XuwxQGb98lNQN1YrR7RNd3T3Uez4QDLgC1BTm2bA69571Lds7J2lK30Z0mEn0f1CsKpdouGrRpi6TCrt0NeWNrR X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5841aa5-394b-4dd2-3937-08d94958212f X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:51.3931 (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: H+PpAt2L0MlCIdeh1XNkgJO6tBC+udxNQcWCGzp5iqzntP2O2+wXjGNrUN3Yrt/yzhnzlIS1e+DbR4td5Y0uiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7C59B200170B X-Stat-Signature: se4pqcu9mbbhzn8otfo9xpc7ku4qkep9 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=YZq+uC7d; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549721-185860 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add MEMORY_DEVICE_GENERIC case to free_zone_device_page callback. Device generic type memory case is now able to free its pages properly. Signed-off-by: Alex Sierra --- mm/memremap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 614b3d600e95..6c884e2542a9 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -438,7 +438,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); @@ -477,7 +477,8 @@ void free_zone_device_page(struct page *page) wake_up_var(&page->_refcount); return; case MEMORY_DEVICE_PRIVATE: - free_device_private_page(page); + case MEMORY_DEVICE_GENERIC: + free_device_page(page); return; default: return; From patchwork Sat Jul 17 19:21:31 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: 12383847 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.6 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 E10C4C636CB for ; Sat, 17 Jul 2021 19:22:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8AAB161164 for ; Sat, 17 Jul 2021 19:22:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AAB161164 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 88DD58D00FC; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8175B8D0102; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 420908D00FF; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id 173D88D00FC for ; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5398A230F0 for ; Sat, 17 Jul 2021 19:22:02 +0000 (UTC) X-FDA: 78373050084.07.7F07292 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id EF05C200170B for ; Sat, 17 Jul 2021 19:22:01 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ck1XYBAwg49OuSsqLxQBMe7cjklBJsIGR9gywgVasnAPDk9eWDLS8bljbdq7cJmMX9Js5ACuR/DfNxGnykjRy7eTiZxHR0RXW8XfgqFFKG8LrB/z/Fugl1aUgN6Aw7A+bZWM2hiw/tUJXJt/zFEB6/cQu7lCeP3+2Ztcct8EYl0FroIVZ1dijDSSPrSChdAnHcwvtu+5NAMwbrjxQqSKUvqIUCHRuWbSmTg/akErvWWHSoFCwdnOrZxGPl+WF4mXrx0gUp7aIqUai8fiIEC/cct/ugaVFCfLjXcJqBtu1ELI9EM+ZWSz+P/a6AndYDEeMiGSywml1vgmwTd3DDZ94A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/JYNbIZyT4GsemXLmS0c1O12FNYR+CKGj4BBJeppL5Q=; b=MF2XcKWBIWRdX94oJGlDH4TvjaYotr78tCc9zwhViYo5k/mm+vYgmnlnXWELqNoVhutxL5utJmF0OQqwUrXvOrKn2O50KBUcdCZxNa1inOo8l9dYfbtUR52f7irCFNq9uUPLclnkph19bPXTo7sgyA8v3cH8Fb4fUkDf6xdbUofJq7khPFAdY3hpPDHElu9HG+IUOk7fgQ1f918voAX1qBSgbcvzZ6UPZhk9Shqam4SpX7kKgQuQP+jYCDist4mxSBdgPEYfs0GCybr7f/nxmSQ+YEnwEFsUditPZKYl4/e8agGJba/7O16TkaYYTPhrgh+FWLrPpEeDECCN7VqonQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/JYNbIZyT4GsemXLmS0c1O12FNYR+CKGj4BBJeppL5Q=; b=kfY9Qmf02zxLbPe+TpHwd6/NZ+mQC6YZdr8HfKNBaDx5Ec2P0gWzX+PHqJF0VZFw5KFly0W3bim72evknBEQh5DEKnQIW2eZJJyXsbNtwbpeR9HiHlQ0aMIVXNCf9VADu0npEGjg5SVe/gvdpQp/ATWuf++NUrfwY8j0+GvQvgs= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:57 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:57 +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 v4 09/13] lib: test_hmm add ioctl to get zone device type Date: Sat, 17 Jul 2021 14:21:31 -0500 Message-Id: <20210717192135.9030-10-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 165330f9-1a02-495d-ae74-08d949582196 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: 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: /xRhQnbRTtfHiTppS8Fm42b3Z46DPZJtx8T81K6qE9s0yjhQrmxh5zO3WzpXHuqYRNJ5hvU2mwgu4iKO88/J2KpkmTZY2JcA5WqgCROXspXCLIrppxmdcfDzrTbXwaFL09RacKUtYl1S1AOr7d9wXdvujryIcWE3KB8BGdvao5KDwasFGq2XIKAN17iFlYAQywF+hV2S/2v/hOKYRKoiVxcz+e7lLLt6VY5AHe2Vd0RMS9fDaBQVoCrw1MdpK+hqZRjcz5jmn0T6WEvYerHYQwDc6GjIslJDVYE31A1kG4ST/KlYp1CSNESWSiBTzB0LFgy+QR5c6FIuIASvuc6mBuAW1n9/Qe+TYHN9WY9snqP8obB5hra7Sr4Ak8BeyrHgVKEv6xN3ootFG+M76KO7WbSe+MjvH9VQWJMmoqvQ+pd1/zHUUShOJGOuVLcDLbIBIvk3V1FIl1AajL66x0mo4iFKZeO7Ydrx+A+gdsS7dQVEHasXP5Vsr0aaCZhucQgAAJMmZv+i1mIrPA6NxEJzsAeufiNdIfhk6dbvytsQf06jEoHQzUV9aiVFiiywKhGM7HYceoPYm/Lzm49wJdenASkHQZgLw5bMZmBuiMELYlMTsoALNC1TRCmfvLKPDxpkUFZVjL2K0u1NHKgYzi8OTaDVRRXRiN2ywcO9RrtujG25oB/UIwt5VqPcp6hy6Hhm 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZfW8EcFVP0UL5b/1qQlIxzHb5M16wwycv8Fbfsszzn8fXyknHToLs8/yfklgNRYgpYehb+buZN22XUYafRsvKoT0toznxfhqpof3vD9odSjm+WqTA3LahrsXxUuejjeDO/mQ7WeCSmldTOZ2xtD0Y5LuJeiGwt26KbgkQ87C3gD8ORilAeSZEV6KhpBb+eaVEM9rglxx78yRYNsUj+PzGcRKUPnn49u31z4LTTAvzwFccaEGn5mGK4X1wj1DYmhxyZOR40JX+WvKtWO/+1S8lSUlXPH2ZN9yaheypTYYBPcmfsVPnc2Dzu0cl7vux2tZfIbvXd0WcCawoVG6ABhj1C3EzSIkbsrLzXFoHcjY+qG3gtKhX0fd1grz0Z9GP6oth2rgnybhS8JRLPCJLl0d4hQR8GsZcMp/6migHm5lOgYCl971uFZx6CBGk2PcDvqC3vF5JOjHgS3y0JUFZY+P9LuLTKdS8xpUpZgviLnTKvUV/Ne8JzKtevNMBe+GeDaQx/Gl5jeawqp2Omfwyu4tLyy/ss1Uv/LFCjKHg6STetRzIhCeyOEHNdpKfNLRuR3/KhPFOgxC1TiY3acLRH6LmMSGg+eqaxdU4aKSQ6lNaBinCVIpq85dk+AtiAEwrtm/IZ0V/Sd0uj4JfWbPlPn3vjT4m2NezuBt77zl4WYcUNwW0LpG6kv1tvpeyU72qPJMx+gbGbGsTiQUmqSF7+lcrSNJbNhqOCLfN4lRjDuS9lyWYyGoqsdpgYo9WZxuh8f5Hsth8W8UPRVJZQaVbSIEofTV2ix7vm0ueUjBH8hJIao58gnrEWNchwvLEDQke8ciqjOfHf7BAehkHWyYIYnud6nXs56cX5+r/vl+ChIsE0aujZL/NQVMyAL6tX+GFzgBZph5/o95egdYj0UOKjoOHQxOcN46Qoa6EWc5mWrBoEbkHa7ye7onQqaAkP+ueajIxZcm4mmANQYXjMhxbVU6u28UNdj8zWKh3JpR8Zmx2QhY4ZHFUc7gKTyKsTrYdjH7HahqIKgGzXzzUBSgimZmMToPIRGEbDSD5n1VqeHyJtlUtvcGI0VjDddeXgsSVMrcCRLgeRehvfrITHpLJEX7o+qwg5Vvr7vHejTXH2uxSZRQr+EJumkIdsJA70PW17SG55UfaK/gPS0JMqpkPj4k7f6xmJFzR9JFoR5Gkeo0J2uQEjbtOgOsGQ22lVi3SufVPYObP92w0kC8wR1LBLA0Ixv+5fPlJ9Jv9NOy/96hoTH1QNwK67nhbEROwZ8XHMjQOfdL1T7itq1BzD+WKMpJ6083BXHnbLZoKWsMLzVsRPSGOKWM847omUJzx4+V5bKQ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 165330f9-1a02-495d-ae74-08d949582196 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:52.0383 (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: ZYFCoGdpKtLQoBFaOp02In5Nn5IDUnyU38fbBjfdWNc4zPAXUHnlYCLPsGes5VJPip0RWZom7nnOqsaUHNhg6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EF05C200170B X-Stat-Signature: m9mr5b5jqx53zdy4miq39ymquyx9cpxs Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=kfY9Qmf0; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549721-811695 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: new ioctl cmd added to query zone device type. This will be used once the test_hmm adds zone device generic type. Signed-off-by: Alex Sierra --- lib/test_hmm.c | 15 ++++++++++++++- lib/test_hmm_uapi.h | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 6998f10350ea..3cd91ca31dd7 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -82,6 +82,7 @@ struct dmirror_chunk { struct dmirror_device { struct cdev cdevice; struct hmm_devmem *devmem; + unsigned int zone_device_type; unsigned int devmem_capacity; unsigned int devmem_count; @@ -468,6 +469,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, if (IS_ERR(res)) goto err_devmem; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; devmem->pagemap.range.start = res->start; devmem->pagemap.range.end = res->end; @@ -912,6 +914,15 @@ static int dmirror_snapshot(struct dmirror *dmirror, return ret; } +static int dmirror_get_device_type(struct dmirror *dmirror, + struct hmm_dmirror_cmd *cmd) +{ + mutex_lock(&dmirror->mutex); + cmd->zone_device_type = dmirror->mdevice->zone_device_type; + mutex_unlock(&dmirror->mutex); + + return 0; +} static long dmirror_fops_unlocked_ioctl(struct file *filp, unsigned int command, unsigned long arg) @@ -952,7 +963,9 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp, case HMM_DMIRROR_SNAPSHOT: ret = dmirror_snapshot(dmirror, &cmd); break; - + case HMM_DMIRROR_GET_MEM_DEV_TYPE: + ret = dmirror_get_device_type(dmirror, &cmd); + break; default: return -EINVAL; } diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index 670b4ef2a5b6..ee88701793d5 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -26,6 +26,7 @@ struct hmm_dmirror_cmd { __u64 npages; __u64 cpages; __u64 faults; + __u64 zone_device_type; }; /* Expose the address space of the calling process through hmm device file */ @@ -33,6 +34,7 @@ struct hmm_dmirror_cmd { #define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd) #define HMM_DMIRROR_MIGRATE _IOWR('H', 0x02, struct hmm_dmirror_cmd) #define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_GET_MEM_DEV_TYPE _IOWR('H', 0x04, struct hmm_dmirror_cmd) /* * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT. @@ -60,4 +62,9 @@ enum { HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30, }; +enum { + /* 0 is reserved to catch uninitialized type fields */ + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1, +}; + #endif /* _LIB_TEST_HMM_UAPI_H */ From patchwork Sat Jul 17 19:21:32 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: 12383839 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.6 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 05742C6379D for ; Sat, 17 Jul 2021 19:22:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A79606115C for ; Sat, 17 Jul 2021 19:22:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A79606115C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6DF4A8D00FD; Sat, 17 Jul 2021 15:22:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 690488D00FC; Sat, 17 Jul 2021 15:22:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 494738D00FD; Sat, 17 Jul 2021 15:22:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 270BB8D00FC for ; Sat, 17 Jul 2021 15:22:04 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C074A8249980 for ; Sat, 17 Jul 2021 19:22:02 +0000 (UTC) X-FDA: 78373050084.05.24F020E Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id 6DA9D200170B for ; Sat, 17 Jul 2021 19:22:02 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RJM2zCgBUgOc9S8BU62IRIjzUZMnsgBVHcFrDVHNoaft0Rkw/oHG9hJi/EBZQmeftqrb7PnutNyp/Qm/4HWBnIk5hWgAC6P6pokwqlztWq9Af9TdT0r/+DpKfJ1uJd8P+lrsIcydVAbPe1Rzq1g9OBScJARS+EHIpt+azSIxCIjV2Qz3yaWqb2+Dv/D2Ni3JM5INfp3ap/gGQkUwKw1sEndqpA7JDTSiTDy4aEXiBqBU+I5zIIbPqdFmfvKcFvaVj/m6PVc7cF+9cmbpG4VNfrl5Yi2RM2DihhQZtqGDNOPkW5lyBJsfxv9wfiGHejCMjKgfTC2FOTofSAHmYItWig== 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=aRvbV4JGMbUEpWoe93Bb/nFVKCW02HMvzadh9Q75HKg=; b=Mjdjcoz1FDDHHBsP7YvGyhXV2YQPQcPegdrShp0gBXVOzQQ2WlOFlCMytZL7z+WMK75/nbdzqHUbZKKysYg0XgKaW6Zf0i802uGnEDJ5jMYagkLgSCbM/Si1GFkxl2TN046SdFCDbwm6v0/0vvWyG7mgmYMjtVj9Ia5QhH1exPhn/VeykmBj0e5L5QGstxxdmk4EvhPy5amHjeriztpJoSVqd/izZCrENnoRqEAEKYn9y/Qr3cLGmZGyFduykKced8vbES1TqiHu9WnNngiA2cVD496XnLss6Q8fqKKZmQF8mBrWJe/muR8yBJrbkSE5mafC5VwFnfAs5J3SRrF29Q== 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=aRvbV4JGMbUEpWoe93Bb/nFVKCW02HMvzadh9Q75HKg=; b=yZdDh+z2ff4iMbUknvV4IN6ISX0wY5JKTyJDgq4mAlGniSvwSEQ+pYWMleyBOSqdAypOT+8XLv9t4vwsn0yVdnUSgmnC4X0pR9zIQ1jl4gZAltR5nGFTARTqKPJC+xzdbQDgE/ggoSHLbj2AmiOxkA1LOtZAHn+A7eRL8iUsa5M= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:57 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:57 +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 v4 10/13] lib: test_hmm add module param for zone device type Date: Sat, 17 Jul 2021 14:21:32 -0500 Message-Id: <20210717192135.9030-11-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a35122d8-478c-48b2-471e-08d9495821f9 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i0Ro7dV4dFX7Nmq6KVH9TVtLBvBeg5AAqP6yNC3ORCNsL6FV8zzUB/jFgslnlqx/GT44sv5njEudFG+9X3/zpLnJaj+DfoHki+k3M19RNQtQIhMPUwAZqu9QLUt0vgn9EWFrSxyi1kzpTu3XpeDzPFzktNrJ8fofMRBUpyPJYDz5uBUv/yGxhYxPaxi4c+O6Qz6uyCMLKDF2AwUEyCrnoWBzIm9i6x41+z6/0ZtgZrODZwesVkZp5YXpJXrXJNZnh+oGMLc+SwbizONxKik2zIhm1LgzQJ2XBMsuZ7VoUxOY+eSGA3Ledce+YSXyYC6N71GS8V+D3vIzMb1C0su5kqJfr1d+GM5a+t1w6FUyPll/QoMbFjptr4ILJ7r1bIRCDQkpNWPFb1DyreXCc9cl1PpZtej+gXmtPAajJhYiFrZFK+uKMhK8+jtArVQXTzMHstUNEEmK110FpQySLRg8onQQpzdGsqKv5KiHH7mgTrbxal8EpnPFBLb9Ufsv4GGv4tervz7OpePNc2UGKeMgD20B7EmIfI6DoUJMkAaOVO81OymOZ3GMXW3/l1t+ZBRqsDekzIfbgH+nV8vdkUM41X6OHm5dd7YNI9TqnzBoZszNUf6GDL8oMTR5GucM6t5YhmJtoptoZ+fuDLCi6BtQCacuyFjnHUPey2VYqNrgSIgtkhrEfdIh0JLjvtMeKej2AO2Gc6sjOkUaVE7fykm0Yw== 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UNpJ+LDDLVABxWIPtZ5+98T5T03pjdkD3R3b8sSV7FltycOJIolAo/ABXwSXPnQ9tfRTn+viah7rRPfXRdptERb/uCrzem187cGcaeJELpKNUWDmdyKw08uGAJe3kzjcl2hS6FJlWad9w3mvdcIwGVycWvR361GLL0vB5JnrWK9S7qLAt1WDKkRkdrDJDWMwrZwZ/+cQy7n/SySp1dw0RVXYEvzpS+l+M4Kx59LxSfgogh7G9HZvB6TrlZfzmowHrv4o6U5Arc+BhFcwkFdF1K1KiWChF9vEzjKHrvxBMc/YAJMEbO9fMjBX/EzXAuOjWxR3ffmrPUAojHhkVtOv+wd8lcarqajPs7cxJxr0Ot3Pc1MBqSumJ7rIZ6KTUcm50r8DP0TAH5ER6DWQ/AMpOAnSKQWb9pGbpI6oLL44W9BxoYlRC1KBkI8xowh3rTwWlwuT8V0zjjSe7tpfCQxEPVKqrelpl/3pki2AoVoAknLCVcL/HVsvCN2Z/50s4a4jASAaG1qDmMx9b8VQ+vhCiM/4ElN6L5YrmsrUn8jwRXdxVnnhfi292lZZQCQElc3gHEHM+p4640OyEpcS9pn8y9xPKeYJK668aJN1gHoE8L79FaJlAnHOvS/uk+xsmYl7R1YWqeMdGYt7lzhf3IPHjqGQwDeUrg3ETKphmaf76i86f8VV1Q48TcuTDUsfivqcY3UJWYXXh4XJ3RHfOS/L0g3y1hdBvYJCC547VOrRMp7byIpaXXHWry0wJlTERoJ7KmhgQod/kJn4Nu1N8hs51332HLDaIfYLcBoXyT9YP7oVomqMH0vRNYG/qgsHg4AKhRZF/1iA4guzfzRCZ7a7GQJy1EvSsU/G1aSc65pIydiaVzMq19dHJjEcMfKFVycYqELVKc4WwMFV3w7MBm9WmP02fdxSMlKYOKPnA6lWxsjb8ESnM1NCU0od99Ra2cUUlqvItXIu91+LV+uFtKcAMpqQcK+nWHM58VKjbZ4ns+p2gIQYmUkahKwmYHkvcVx7yivOZKy0ONUMLZ5Ye1kPlYwSjPBiv7MNbHA4Ia/JGv7OuLDyYjxOznk/2afMEEIwGYg2X/x7Q3FEG2sMdOw3y4yS0uPtwSGPSSMC2sa82YvIuxXl7TCnOMht8ckfcXCyxpC/b446IBs+HfuXqXYxLofBiSMOnWzcjIYOsxsdl9NkLaI4BYN2urAR24/K0kiLKvG/DsgPcTAZVidOHv0OWhHIyz350LKs478lC2jhxwZwNMWgMe4j6s+3PxKB+cpfukLBJDw3/B2HxDZ67QOmCkhCTBfrAa/fD8sZIuWohf64xzbku+V2a3vi9NWjOMad X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a35122d8-478c-48b2-471e-08d9495821f9 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:52.6934 (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: nLmhyzSCPRPl+sTyJmGoT9M+cQ4rw1HhWOtKd/vk7eqa7lRj/CoBhLPH58DgYCyy3I0pi1kO+Kpi6YbmJ/bm1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6DA9D200170B X-Stat-Signature: ytn4i1gemjgopsacx6ksmm8uyyg4etwg Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=yZdDh+z2; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549722-915533 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In order to configure device generic in test_hmm, two module parameters should be passed, which correspon to the SP start address of each device (2) spm_addr_dev0 & spm_addr_dev1. If no parameters are passed, private device type is configured. Signed-off-by: Alex Sierra --- lib/test_hmm.c | 45 +++++++++++++++++++++++++++++++++------------ lib/test_hmm_uapi.h | 1 + 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 3cd91ca31dd7..3c2e1fbedbd4 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,14 +472,26 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, devmem = kzalloc(sizeof(*devmem), GFP_KERNEL); if (!devmem) - return false; + return -ENOMEM; + + if (!spm_addr_dev0 && !spm_addr_dev1) { + res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE, + "hmm_dmirror"); + devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; + } else if (spm_addr_dev0 && spm_addr_dev1) { + res = lookup_resource(&iomem_resource, MINOR(mdevice->cdevice.dev) ? + spm_addr_dev0 : + spm_addr_dev1); + devmem->pagemap.type = MEMORY_DEVICE_GENERIC; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_GENERIC; + } else { + pr_err("Both spm_addr_dev parameters should be set\n"); + } - res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE, - "hmm_dmirror"); if (IS_ERR(res)) 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; @@ -1097,10 +1119,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 +1133,9 @@ static void dmirror_device_remove(struct dmirror_device *mdevice) mdevice->devmem_chunks[i]; memunmap_pages(&devmem->pagemap); - release_mem_region(devmem->pagemap.range.start, - range_len(&devmem->pagemap.range)); + if (devmem->pagemap.type == MEMORY_DEVICE_PRIVATE) + release_mem_region(devmem->pagemap.range.start, + range_len(&devmem->pagemap.range)); kfree(devmem); } kfree(mdevice->devmem_chunks); diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index ee88701793d5..17a6b5059871 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -65,6 +65,7 @@ enum { enum { /* 0 is reserved to catch uninitialized type fields */ HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1, + HMM_DMIRROR_MEMORY_DEVICE_GENERIC, }; #endif /* _LIB_TEST_HMM_UAPI_H */ From patchwork Sat Jul 17 19:21:33 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: 12383841 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.6 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 31F72C6499C for ; Sat, 17 Jul 2021 19:22:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D4E761176 for ; Sat, 17 Jul 2021 19:22:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D4E761176 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E0AD98D00FE; Sat, 17 Jul 2021 15:22:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC9C78D00FC; Sat, 17 Jul 2021 15:22:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4A068D00FC; Sat, 17 Jul 2021 15:22:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 8AE4C8D00FE for ; Sat, 17 Jul 2021 15:22:04 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4CAD4181AEF21 for ; Sat, 17 Jul 2021 19:22:03 +0000 (UTC) X-FDA: 78373050126.16.AFC937E Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id DB134200170B for ; Sat, 17 Jul 2021 19:22:02 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CFxbs30+EKvuZE4CYxS5UEFDFzGf9/5S54L8S3+WHr158MZ+FoOKnH+HStm7r7PCRDxxYRWhEuWeM0ydTbk4KJ7eVRVjmR0utqr6g0zIDS1XwiSwfXF0AcZlD1DDbYEHQBEu2SrK6SAf4fbAzIgzYoqJlKMSs3M4198UGoVIsUWBxclNZt8VuF2zYgdgtDxhKRx25LBmXkMgdR5+Hv/1Ru2Y28uqIUl+XYE+Y0qPMSWtliuyo8jLcxCMsuCSaA5PPf6FpK0X5DGxZxuQeBRFukV65O4ZdmODd+04z4mAOGtGegIKwTPk0Mv7Ato36VridWE0QoqAEaz/sq5myiR5kA== 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=WxORDB/7hRjKfIvUPvXBFUKxwjsBDFZYHc65pjTMu0k=; b=W+Lju5/nSDUVDOkX/ADS563dVqFiyW/N7oPw72CPQrAAgdtnEBo+859Eg2FqebITZUPh8y9WYAjfijQB+DxW3SXUHilsdaAoCABZVrcNtBzI2fAdjBsPHAF4liTD7+YWwojsa1L5fIysbtjBBHXR+YptCgtzjmoT7boknl4uJCRgOFFxF3F03gRxr88JQg3HJY7Xp7p4ThsnHJKxdpJSshgrHsO8olVLlF+Pe9d5R1GKoi+XTPQ37skgDaQWI2yUiy2GaO2gsdBSz1CxGWOt/IIziYwK3O4TIwWWWqIpJTljYM3Gu9DLl/FJ5EPiPpasxz5NCKRENy7UhaFZT/S4Bw== 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=WxORDB/7hRjKfIvUPvXBFUKxwjsBDFZYHc65pjTMu0k=; b=O12SM8vYJipmBCVHl/ESt+/nIGi6Ijg9f8FXzFHOIe+AMTfV9hiuqo0DxaahAfBvTMMU3ehofalIXmCeq7hqK6c/iyzlplfJllpXwPBTuZuzNr+/zsk2CDGGr0nJmtZASqjWj2FdhYQrQzJ+GoAAXqIaFV95oKG40zRdvPonsyo= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:58 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:58 +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 v4 11/13] lib: add support for device generic type in test_hmm Date: Sat, 17 Jul 2021 14:21:33 -0500 Message-Id: <20210717192135.9030-12-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4354b30-90ef-4fd1-dfdd-08d94958225b X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: 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: yPtPnWceWOYHtyqF14SVq8Sb1blm+H5weO8Hxs5WA6E9OTh5PGHB/v/k42rSMM3VihCD96rLLFitLrGTMIO7RlPHUc7elJGECN1QmFyXis/lXfH2v3S6GTpdBXCZIyJTKEA7x2ZlHp1TIHptNzFdqF/NaCFSswomIcfreReHgpz+YeDsCT0fgcAv6YSvn/SrG0QbAG4GYTdJ/1lFPzOZmeHWPLrLyI9e7y2iV7u5/Uf0jhh8Nc3UBciav5RHVhzVOHCBStGEz//Ccr6ITGUyLJIbvk6ch2ghd2Mxp5tLY/+R5V/MtJQSK6neRIqhjJwpMOOpSIt298Q74P16pJ/qivnM+xMuYyGIvBLft6YX7kDbK9Px8HAaG8Cu8YOWCoE+qTlXzvv5jeDDfx3jTRjWuOi6a69TgmZdzdTXcfyDlk+m47Bjfb9c+xNLh5z20pn35oprHT9t5X5f1T0FTjip4wIGvTw3KY6e3EnZs8oeivVO8H34lMBAqGmUnAf/q1Cak9X0rYVjtP0qvSxjcNTWfFM0DPC51cg0QxQWHdxpC5zBGFpyvIjihm330RPoU8QK/QwAarxeUmXPx+eafyGCi8qnXLrI3rZq/U6jen5rhEqe6xOpZIaHrkW+aP8Zi6DMNct7qDWEHNnnXQ9RZRZtgc5G3UUPWio1muiJo6kD08ZcjGpvwI+SBS7IgJeWA5m3cP9B98JSYVOVsRbCOwIRYQ5VhHlAlgz+xm4fNDx3p4o= 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(30864003)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: czUwKf7QU/OnWNjM6vqLbEVVZDUurQ2U3RReMvtdb+c2dhXQNAhM/0tqes9CO6JpMHTv4vpSDItLExOl2OFBA/2kBGaLSkJdiA0YBeFQCV6FdR9qv/QOiZZgkEjp1SzycfTpjOUE4nY/hCzo3Q/o6j7fZzt8nfssqQhKwecilFSk/JklW/yevfoeYCjVesU01adNDL791yVGeHfvACh7lZ6C3hbkL4BoakcotFzmpusWUqvzPqVJjm8drKDE98C9ecsm1JCLa8HzmpYJkrlOjr2/5ay2uYyMkSpL4H3loyJi0/bIU6/cZbZB6G4bjoYETqk+VQj8rIZ5aOzK6Z6LUtPp92w8kSJKka8Imrt8RMtLy9EvcYa31di8YjeXQqv2KkAkROySWg2YwO8idBi/WftqKKufXrPfygq4RjlqhO5lLYu+VuNEjjDFqDkD6pBkc07yFoQkd/w0NDVpbFJoWUj8v+FadZIx7XlX6YNquK6AGgjaZ9PD1Q5U/3XaBo7+du6w2DDm6j/m48P+6Q8xACcRnWOpCNqlhbcxpLxkkTxdLw1Wk5sqlkXNpTPDQiD0ofib+bqlZPZ7HUt4OqmxcuO9Q89j7LCo5WA0PAFsxrMCCpKe2E3sgU2DnmVOGjxpUVWnJtHuV+FbWoAnfNRrWssYr9HPief6asDMGJt/KM9to5N9jiBUPrO/R5XYrAQXPs0Q4dgRK3/OkJ/6WRZWqozxKlxBqQtBiZhHmV0ehwCyrtShSYYQ/j0QxgHbs/hURujNMcvW8i+PlTFQffFDrgdBnQ7RfAiZxmdFzfKmMBHnSOcOibAKoJeu4h3bNgY+YszlTGA/nN/2wRUFd2kKcHrILpXWXr5gJWACJDeCS+aiMqibuXF8LpTvAc1M9OrSqUba66YLwPj5LjHX+V9n7WaELY7732mb1tQ+bqn9BcEvS+9LilQcsoXCPNAJUjnW9YZOmvXiC/1UqimBPAgyOPOmh4ssgxYdBFujr8bhH6aT70SvPexo0UI84uFRQ+uS5GVE/NuRZ4uYNbFc9PJxtKWImxnjnvht5gnsH4bMS5mW6q0IRkLGqkD+7xLYXuqXtO6GzsImkWSa7lnOL7AdwK9zxHlDfHHFjOA3Tjz1+Vz4Q+savTsEWZ1L6anBpEXqZHHC+N+9tDkIUmdpaoDBAtmw81XL4JDOwkzv9Q9dqvZ5b2A8H6Tu9XnI2e+u1BZvF/bGpdRZc6e43LrbyytJ5GH9IXEL99/MWJJFYP6fpcYV1nOYQnXbVuTcX4XLXabt0QU3x2erll5IvY3qQzfGvweTWr7BvFzsXkNRj09XyQt/tVN45Smqz0Oear+ebfLo X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4354b30-90ef-4fd1-dfdd-08d94958225b X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:53.3475 (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: YUtMuTPWHO1WtK1ooW46TPTb09PcV+68M81/AWlVltIMvK6PdnSCb9maTDSTkEGfVbf1SsZIfdtNE20N8SiFmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: DB134200170B X-Stat-Signature: wowzxrf3ug1rxdxrcrsqx66jf87kc71z Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=O12SM8vY; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549722-654388 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Device Generic type uses device memory that is coherently accesible by the CPU. Usually, this is shown as SP (special purpose) memory range at the BIOS-e820 memory enumeration. If no SP memory is supported in system, this could be faked by setting CONFIG_EFI_FAKE_MEMMAP. Currently, test_hmm only supports two different SP ranges of at least 256MB size. This could be specified in the kernel parameter variable efi_fake_mem. Ex. Two SP ranges of 1GB starting at 0x100000000 & 0x140000000 physical address. efi_fake_mem=1G@0x100000000:0x40000,1G@0x140000000:0x40000 Signed-off-by: Alex Sierra --- lib/test_hmm.c | 170 ++++++++++++++++++++++++++++---------------- lib/test_hmm_uapi.h | 10 ++- 2 files changed, 116 insertions(+), 64 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 3c2e1fbedbd4..dcf0729d4883 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) @@ -517,8 +518,10 @@ static int dmirror_allocate_chunk(struct dmirror_device *mdevice, } ptr = memremap_pages(&devmem->pagemap, numa_node_id()); - if (IS_ERR(ptr)) + if (IS_ERR(ptr)) { + ret = PTR_ERR(ptr); goto err_release; + } devmem->mdevice = mdevice; pfn_first = devmem->pagemap.range.start >> PAGE_SHIFT; @@ -547,7 +550,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); @@ -555,7 +558,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) @@ -564,8 +567,10 @@ static struct page *dmirror_devmem_alloc_page(struct dmirror_device *mdevice) struct page *rpage; /* - * This is a fake device so we alloc real system memory to store - * our device memory. + * For ZONE_DEVICE private type, this is a fake device so we alloc real + * system memory to store our device memory. + * For ZONE_DEVICE generic type we use the actual dpage to store the data + * and ignore rpage. */ rpage = alloc_page(GFP_HIGHUSER); if (!rpage) @@ -598,7 +603,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; @@ -616,12 +621,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 @@ -633,8 +644,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) || @@ -668,10 +681,13 @@ static int dmirror_migrate_finalize_and_map(struct migrate_vma *args, continue; /* - * Store the page that holds the data so the page table - * doesn't have to deal with ZONE_DEVICE private pages. + * For ZONE_DEVICE private pages we store the page that + * holds the data so the page table doesn't have to deal it. + * For ZONE_DEVICE generic pages we store the actual page, since + * the CPU has coherent access to the page. */ - entry = dpage->zone_device_data; + entry = is_device_private_page(dpage) ? dpage->zone_device_data : + dpage; if (*dst & MIGRATE_PFN_WRITE) entry = xa_tag_pointer(entry, DPT_XA_TAG_WRITE); entry = xa_store(&dmirror->pt, pfn, entry, GFP_ATOMIC); @@ -685,6 +701,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) { @@ -726,33 +783,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: @@ -776,9 +846,15 @@ static void dmirror_mkentry(struct dmirror *dmirror, struct hmm_range *range, } page = hmm_pfn_to_page(entry); - if (is_device_private_page(page)) { - /* Is the page migrated to this device or some other? */ - if (dmirror->mdevice == dmirror_page_to_device(page)) + if (is_device_page(page)) { + /* Is page ZONE_DEVICE generic? */ + if (!is_device_private_page(page)) + *perm = HMM_DMIRROR_PROT_DEV_GENERIC; + /* + * Is page ZONE_DEVICE private migrated to + * this device or some other? + */ + else if (dmirror->mdevice == dmirror_page_to_device(page)) *perm = HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL; else *perm = HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE; @@ -1025,38 +1101,6 @@ static void dmirror_devmem_free(struct page *page) spin_unlock(&mdevice->lock); } -static vm_fault_t dmirror_devmem_fault_alloc_and_copy(struct migrate_vma *args, - struct dmirror *dmirror) -{ - const unsigned long *src = args->src; - unsigned long *dst = args->dst; - unsigned long start = args->start; - unsigned long end = args->end; - unsigned long addr; - - for (addr = start; addr < end; addr += PAGE_SIZE, - src++, dst++) { - struct page *dpage, *spage; - - spage = migrate_pfn_to_page(*src); - if (!spage || !(*src & MIGRATE_PFN_MIGRATE)) - continue; - spage = spage->zone_device_data; - - dpage = alloc_page_vma(GFP_HIGHUSER_MOVABLE, args->vma, addr); - if (!dpage) - continue; - - lock_page(dpage); - xa_erase(&dmirror->pt, addr >> PAGE_SHIFT); - copy_highpage(dpage, spage); - *dst = migrate_pfn(page_to_pfn(dpage)) | MIGRATE_PFN_LOCKED; - if (*src & MIGRATE_PFN_WRITE) - *dst |= MIGRATE_PFN_WRITE; - } - return 0; -} - static vm_fault_t dmirror_devmem_fault(struct vm_fault *vmf) { struct migrate_vma args; diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index 17a6b5059871..1f2322286fba 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -17,8 +17,12 @@ * @addr: (in) user address the device will read/write * @ptr: (in) user address where device data is copied to/from * @npages: (in) number of pages to read/write + * @alloc_to_devmem: (in) desired allocation destination during migration. + * True if allocation is to device memory. + * False if allocation is to system memory. * @cpages: (out) number of pages copied * @faults: (out) number of device page faults seen + * @zone_device_type: (out) zone device memory type */ struct hmm_dmirror_cmd { __u64 addr; @@ -26,7 +30,8 @@ struct hmm_dmirror_cmd { __u64 npages; __u64 cpages; __u64 faults; - __u64 zone_device_type; + __u32 zone_device_type; + __u32 alloc_to_devmem; }; /* Expose the address space of the calling process through hmm device file */ @@ -49,6 +54,8 @@ struct hmm_dmirror_cmd { * device the ioctl() is made * HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE: Migrated device private page on some * other device + * HMM_DMIRROR_PROT_DEV_GENERIC: Migrate device generic page on the device + * the ioctl() is made */ enum { HMM_DMIRROR_PROT_ERROR = 0xFF, @@ -60,6 +67,7 @@ enum { HMM_DMIRROR_PROT_ZERO = 0x10, HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL = 0x20, HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30, + HMM_DMIRROR_PROT_DEV_GENERIC = 0x40, }; enum { From patchwork Sat Jul 17 19:21:34 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: 12383845 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.6 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 E66CBC64995 for ; Sat, 17 Jul 2021 19:22:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 942C160200 for ; Sat, 17 Jul 2021 19:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 942C160200 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 61CBC8D0100; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A7C18D00FC; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3820B8D0100; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0025.hostedemail.com [216.40.44.25]) by kanga.kvack.org (Postfix) with ESMTP id 0E7ED8D00FF for ; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BCDCB180AD811 for ; Sat, 17 Jul 2021 19:22:03 +0000 (UTC) X-FDA: 78373050126.04.796E122 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id 63108200170B for ; Sat, 17 Jul 2021 19:22:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gXWt6EdcgJYBT1XdL7EX7GLCWuJJmP71ec88AvQvwUUlF2d1AzCnZ+Jg9zvVr5LdqvCyv6gM7wo0WgNqnvPKelIDyBAHRq3o1kbNgjNbS0NbG10WEtPGj79Tv8q7oCSSiDxWjKN2idEKqf7y/hXSICc9hL30iAjFW1yKJNHsKZST9A9ubcss8Vauu7z5Aln3VpqLo2qSLqbPsAuFfq6K7c1tRAl4gf2S5lYU150KrrdaebMW0KRySH74dCYf6cMl0s+wPftao9Fe8tQOsYgyUWkeQimPC6aNSQWU4+bkaxuXySx7X3m4M7BDu+oQTLUllVE5FdIB1MywJUK40QKBcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m750G1HruRY8e0UdQp9kGzjlljIQJX1uEk9lQNpHmcQ=; b=EQjgPBqK65OD4uotoPlAFDEbOVHyM6db9WRd1lLnWEd9NeUYNSwZHvMZsFIVajjEp8r8OLjH44PopZb4jNqXLuW4Lv2mQDpuDn16Cw9TrDQXpn+2C+iY/5acWFY6MUSCB2BNAvchlPw8/A9bLw8dCVkJDtw8MxKVPgm0dhhw0TEfpOwCWeksSTnkzq6wJxyFB4Gi3oWLK/ZR04a2nkbTvZlxAd50B4gjwXSlFI6NbvEwSHA6lLdAMXmWinIYYxSTLsMU907AA9EnAWjh4R07A7MBrQbb7gd91ysTnYNmywmwStjCrLgd7icVMKaYDnnWe94tBy60GoVEImxndXPeXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m750G1HruRY8e0UdQp9kGzjlljIQJX1uEk9lQNpHmcQ=; b=PoQDIEQbtKdGwY3CT2d1V+05+5dd/GjWCfJHz85a6IdXf2K3kDm5G/AM8a3jwopl6r47ORJrF9YFwTZzcsfHPGSiQqOr2NBCKCv0qrj05CDP2J/ILSBTutQZEcDoqsYjfHrewdMOlQW9DUUhRfXcAWDo2FpYv17rAmG/JoAj5IY= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:58 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:58 +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 v4 12/13] tools: update hmm-test to support device generic type Date: Sat, 17 Jul 2021 14:21:34 -0500 Message-Id: <20210717192135.9030-13-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce49e815-9d09-44e1-6bc1-08d9495822c2 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: 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: V1okHR6ZLDL3I37WyTkgSJrrLvD+e4AXDnfzmRhnnDapiHcUHYJiamSeT+hriubWGXFKO5bjiYXBsYv01XiAKma0celLN/nLBQpOr5nrDU+AGiWsvf+KufEiKKlgJfUfkjcHdFf8CwwWqiUO1B3o5QWwkMi+CaWcWhfMMwUpw9CnZkZO3zwSJRrFOBkK/mIur3Emf7bJIxL8BL8JLBOQcNkmSJq2JU0K78XN6PVxG2OQjSOKqBmOrlmBvXM+DSnDlM1AnF3Fvn27UmcmR8Dcc9w0MHDvcmxs+LAjPN+3ETv6BCGRMZMos/g47x+/nI2oWX28hzUu2yIB1CnjRr6Dcll9hsG/nczL0O0MEypgtaaAe+uNknMPiTxbVZ22fasbHTjrwQr1Z0S+hPQP7Q+VuyTf+KTVH3D8C8m0adBEijaWCv+j6xwE8EXxqlhUOTeToTewyE2BlmQLvRgKIPAWI2piukeg90rdq/FJ/uDmSvvYDzOuOCDMFwdaM5ur7WoZjexjua0EBjsDveOUHY24fTNuCSdpDfDqOjOANDCtIpMjxAp96FRagmr8E1F1eFSDdfQPJOZxCrBdTD1dBlpdT5Fa+tijRzUR3nNU+LTC4jk1Daum9kHitb15HBmTlZVpmO+zkDEKBQB6M6K9p9ewg6B8svx9bJ9ewwVFWIPhCSxAVv6GmNOmeLn08jIDDzrQkzJUH+0wH+zkRtZHjlDu84i9UTEUBoQhVNDLnPrjGno= 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(15650500001)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mRUkAOh4vSeYN803IlYbkzvdG6VZHEJ8Ub3q6KqCEPj50qrBMZW/nzuRY0SFgnE7xwtxMPEMmhqojr2T+51j8agLLObg6ugAk3mHoROxiQahKMlr0gvB1xyZj8FjCFw5CJpMJGweTES0rlzxlmwu/ERUGSXUzdL3VtZbh2qJzY/K8pGcDXHsEafPfwvXWLLH0DKp6wpNP3BUUee7pRE5Yfh1YNy5/tScv41hIB+qyld6TYeB7vUg9L929sIbR+c/ymol1+RPSWoCyHbkzbh3I5MidvTeAMKvZzRJ5EHPF6W8marrtZkaw888PNgEdkIc5IeEUfaukpSqLVXZTadplzMcrQJE1pePkApKadmUuq+xnhPU8VVOHhCElAQ58KOM51krghP9g8O/3+r5Us+/f4Mfc0YQDwtXizzrq62JDELaMtqRrs7BYyhrRL+antSUk/orCYEwf7bC4vaaEU3HgcFMkdSifZxz5ccjhycy4kJBnu461K1ysWtzaYooGpsNqUUEhrVUE6VK60JTSFnlYHCq8rpONu1F7iIR7tUQTeNyChAGj1GnpgZ9KFhqjRJR/Z7k/7N3R81VFc+pbVAXK7oAqcfgXpyEmCvkdjzS3s6fqst+PH3a7qmxrMkTzw88N4BqPo066xyL64AN62sbuOkMTaQh1Pp0Y74CJ/Mhm7uhRbZeWpNBdlO5WfY7QGwOiXDIaQ8XwCZvPcL/ZMAQrpfu5cxpCNbXwWQSq32IRt2D+UZIjKEwPJTt8zmR3r5cs22qvtYo/IwAwMXKpwhEg0CPAUMvmlpVVQUYU3KY64yBy1VlpjEKbWxmL1u2Vn+7+NX51VCIcIO0lp5iQnkPjrY6sqbgXH8DINOr8CbTn2ttycsN2AmFrCujtl0VO2nQUj9zCQLKk7650jr7/lN9nc0K1Evl6xC46/PZ2De0Vg9w1k48ZX8tbn4JMtKqB9m2S5u+gj/G7lejnfsvkTNgEGUK+cyHA7TEK7/Yp6dFQHifHkGrDxSChVLqRFw7U3IJzsLRaCA1KBCSrc2UsACRn+ce8B22xiWmu3nTeKUybGQVC3TvTuVdfefiBpj4kOWiqSAbBZOF/p+HNHhwl3P999RD3cfYp6woasqfH4KafqA1MUOhO7Psjgfh6qJAowF1weQvCuekoWYclpNpsxuwE24RarJNOYkd790jjHMHzh8LwF+tuAFg/SvJ/Ws3NqZVZ2d7T76RhhZf2S2oJ+IhmDlqp2NhpRlLE52UzZzWJjOC2BKJr5TO/uMsy8/+kG5OgWCuDtxGoyWlMldaoyfxR+r1wjsHlMNLA89dJXeg6j4qPwYrJxJYoATRYM1jUVnn X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce49e815-9d09-44e1-6bc1-08d9495822c2 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:54.0863 (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: OMe3/hEcB+c0LY3hMLTv507Kf2chtWt+PjHBwFfaV9s06oHqedIIwBHlMuNG+9GoW1ILCN6ff5gIVNSXUnKX7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 63108200170B X-Stat-Signature: zohikowjepkdyxj5inqp8zqquumjmngu Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=PoQDIEQb; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549723-270386 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Test cases such as migrate_fault and migrate_multiple, were modified to explicit migrate from device to sys memory without the need of page faults, when using device generic type. Snapshot test case updated to read memory device type first and based on that, get the proper returned results migrate_ping_pong test case added to test explicit migration from device to sys memory for both private and generic zone types. Helpers to migrate from device to sys memory and vicerversa were also added. Signed-off-by: Alex Sierra --- tools/testing/selftests/vm/hmm-tests.c | 142 +++++++++++++++++++++---- 1 file changed, 124 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/vm/hmm-tests.c b/tools/testing/selftests/vm/hmm-tests.c index 5d1ac691b9f4..70632b195497 100644 --- a/tools/testing/selftests/vm/hmm-tests.c +++ b/tools/testing/selftests/vm/hmm-tests.c @@ -44,6 +44,8 @@ struct hmm_buffer { int fd; uint64_t cpages; uint64_t faults; + int zone_device_type; + bool alloc_to_devmem; }; #define TWOMEG (1 << 21) @@ -133,6 +135,7 @@ static int hmm_dmirror_cmd(int fd, cmd.addr = (__u64)buffer->ptr; cmd.ptr = (__u64)buffer->mirror; cmd.npages = npages; + cmd.alloc_to_devmem = buffer->alloc_to_devmem; for (;;) { ret = ioctl(fd, request, &cmd); @@ -144,6 +147,7 @@ static int hmm_dmirror_cmd(int fd, } buffer->cpages = cmd.cpages; buffer->faults = cmd.faults; + buffer->zone_device_type = cmd.zone_device_type; return 0; } @@ -211,6 +215,34 @@ static void hmm_nanosleep(unsigned int n) nanosleep(&t, NULL); } +static int hmm_migrate_sys_to_dev(int fd, + struct hmm_buffer *buffer, + unsigned long npages) +{ + buffer->alloc_to_devmem = true; + return hmm_dmirror_cmd(fd, HMM_DMIRROR_MIGRATE, buffer, npages); +} + +static int hmm_migrate_dev_to_sys(int fd, + struct hmm_buffer *buffer, + unsigned long npages) +{ + buffer->alloc_to_devmem = false; + return hmm_dmirror_cmd(fd, HMM_DMIRROR_MIGRATE, buffer, npages); +} + +static int hmm_is_private_device(int fd, bool *res) +{ + struct hmm_buffer buffer; + int ret; + + buffer.ptr = 0; + ret = hmm_dmirror_cmd(fd, HMM_DMIRROR_GET_MEM_DEV_TYPE, &buffer, 1); + *res = (buffer.zone_device_type == HMM_DMIRROR_MEMORY_DEVICE_PRIVATE); + + return ret; +} + /* * Simple NULL test of device open/close. */ @@ -875,7 +907,7 @@ TEST_F(hmm, migrate) ptr[i] = i; /* Migrate memory to device. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, npages); @@ -923,7 +955,7 @@ TEST_F(hmm, migrate_fault) ptr[i] = i; /* Migrate memory to device. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, npages); @@ -936,7 +968,7 @@ TEST_F(hmm, migrate_fault) ASSERT_EQ(ptr[i], i); /* Migrate memory to the device again. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, npages); @@ -976,7 +1008,7 @@ TEST_F(hmm, migrate_shared) ASSERT_NE(buffer->ptr, MAP_FAILED); /* Migrate memory to device. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, -ENOENT); hmm_buffer_free(buffer); @@ -1015,7 +1047,7 @@ TEST_F(hmm2, migrate_mixed) p = buffer->ptr; /* Migrating a protected area should be an error. */ - ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, npages); + ret = hmm_migrate_sys_to_dev(self->fd1, buffer, npages); ASSERT_EQ(ret, -EINVAL); /* Punch a hole after the first page address. */ @@ -1023,7 +1055,7 @@ TEST_F(hmm2, migrate_mixed) ASSERT_EQ(ret, 0); /* We expect an error if the vma doesn't cover the range. */ - ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, 3); + ret = hmm_migrate_sys_to_dev(self->fd1, buffer, 3); ASSERT_EQ(ret, -EINVAL); /* Page 2 will be a read-only zero page. */ @@ -1055,13 +1087,13 @@ TEST_F(hmm2, migrate_mixed) /* Now try to migrate pages 2-5 to device 1. */ buffer->ptr = p + 2 * self->page_size; - ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, 4); + ret = hmm_migrate_sys_to_dev(self->fd1, buffer, 4); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, 4); /* Page 5 won't be migrated to device 0 because it's on device 1. */ buffer->ptr = p + 5 * self->page_size; - ret = hmm_dmirror_cmd(self->fd0, HMM_DMIRROR_MIGRATE, buffer, 1); + ret = hmm_migrate_sys_to_dev(self->fd0, buffer, 1); ASSERT_EQ(ret, -ENOENT); buffer->ptr = p; @@ -1070,8 +1102,12 @@ TEST_F(hmm2, migrate_mixed) } /* - * Migrate anonymous memory to device private memory and fault it back to system - * memory multiple times. + * Migrate anonymous memory to device memory and back to system memory + * multiple times. In case of private zone configuration, this is done + * through fault pages accessed by CPU. In case of generic zone configuration, + * the pages from the device should be explicitly migrated back to system memory. + * The reason is Generic device zone has coherent access to CPU, therefore + * it will not generate any page fault. */ TEST_F(hmm, migrate_multiple) { @@ -1082,7 +1118,9 @@ TEST_F(hmm, migrate_multiple) unsigned long c; int *ptr; int ret; + bool is_private; + ASSERT_EQ(hmm_is_private_device(self->fd, &is_private), 0); npages = ALIGN(HMM_BUFFER_SIZE, self->page_size) >> self->page_shift; ASSERT_NE(npages, 0); size = npages << self->page_shift; @@ -1107,8 +1145,7 @@ TEST_F(hmm, migrate_multiple) ptr[i] = i; /* Migrate memory to device. */ - ret = hmm_dmirror_cmd(self->fd, HMM_DMIRROR_MIGRATE, buffer, - npages); + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, npages); @@ -1116,7 +1153,12 @@ TEST_F(hmm, migrate_multiple) for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i) ASSERT_EQ(ptr[i], i); - /* Fault pages back to system memory and check them. */ + /* Migrate back to system memory and check them. */ + if (!is_private) { + ret = hmm_migrate_dev_to_sys(self->fd, buffer, npages); + ASSERT_EQ(ret, 0); + } + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) ASSERT_EQ(ptr[i], i); @@ -1261,10 +1303,12 @@ TEST_F(hmm2, snapshot) unsigned char *m; int ret; int val; + bool is_private; npages = 7; size = npages << self->page_shift; + ASSERT_EQ(hmm_is_private_device(self->fd0, &is_private), 0); buffer = malloc(sizeof(*buffer)); ASSERT_NE(buffer, NULL); @@ -1312,13 +1356,13 @@ TEST_F(hmm2, snapshot) /* Page 5 will be migrated to device 0. */ buffer->ptr = p + 5 * self->page_size; - ret = hmm_dmirror_cmd(self->fd0, HMM_DMIRROR_MIGRATE, buffer, 1); + ret = hmm_migrate_sys_to_dev(self->fd0, buffer, 1); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, 1); /* Page 6 will be migrated to device 1. */ buffer->ptr = p + 6 * self->page_size; - ret = hmm_dmirror_cmd(self->fd1, HMM_DMIRROR_MIGRATE, buffer, 1); + ret = hmm_migrate_sys_to_dev(self->fd1, buffer, 1); ASSERT_EQ(ret, 0); ASSERT_EQ(buffer->cpages, 1); @@ -1335,9 +1379,16 @@ TEST_F(hmm2, snapshot) ASSERT_EQ(m[2], HMM_DMIRROR_PROT_ZERO | HMM_DMIRROR_PROT_READ); ASSERT_EQ(m[3], HMM_DMIRROR_PROT_READ); ASSERT_EQ(m[4], HMM_DMIRROR_PROT_WRITE); - ASSERT_EQ(m[5], HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL | - HMM_DMIRROR_PROT_WRITE); - ASSERT_EQ(m[6], HMM_DMIRROR_PROT_NONE); + if (is_private) { + ASSERT_EQ(m[5], HMM_DMIRROR_PROT_DEV_PRIVATE_LOCAL | + HMM_DMIRROR_PROT_WRITE); + ASSERT_EQ(m[6], HMM_DMIRROR_PROT_NONE); + } else { + ASSERT_EQ(m[5], HMM_DMIRROR_PROT_DEV_GENERIC | + HMM_DMIRROR_PROT_WRITE); + ASSERT_EQ(m[6], HMM_DMIRROR_PROT_DEV_GENERIC | + HMM_DMIRROR_PROT_WRITE); + } hmm_buffer_free(buffer); } @@ -1485,4 +1536,59 @@ TEST_F(hmm2, double_map) hmm_buffer_free(buffer); } +/* + * Migrate anonymous memory to device memory and migrate back to system memory + * explicitly, without generating a page fault. + */ +TEST_F(hmm, migrate_ping_pong) +{ + struct hmm_buffer *buffer; + unsigned long npages; + unsigned long size; + unsigned long i; + int *ptr; + int ret; + + npages = ALIGN(HMM_BUFFER_SIZE, self->page_size) >> self->page_shift; + ASSERT_NE(npages, 0); + size = npages << self->page_shift; + + buffer = malloc(sizeof(*buffer)); + ASSERT_NE(buffer, NULL); + + buffer->fd = -1; + buffer->size = size; + buffer->mirror = malloc(size); + buffer->alloc_to_devmem = true; + ASSERT_NE(buffer->mirror, NULL); + + buffer->ptr = mmap(NULL, size, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, + buffer->fd, 0); + ASSERT_NE(buffer->ptr, MAP_FAILED); + + /* Initialize buffer in system memory. */ + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) + ptr[i] = i; + + /* Migrate memory to device. */ + ret = hmm_migrate_sys_to_dev(self->fd, buffer, npages); + ASSERT_EQ(ret, 0); + ASSERT_EQ(buffer->cpages, npages); + /* Check what the device read. */ + for (i = 0, ptr = buffer->mirror; i < size / sizeof(*ptr); ++i) + ASSERT_EQ(ptr[i], i); + + /* Migrate memory back to system mem. */ + ret = hmm_migrate_dev_to_sys(self->fd, buffer, npages); + ASSERT_EQ(ret, 0); + + /* Check the buffer migrated back to system memory. */ + for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i) + ASSERT_EQ(ptr[i], i); + + hmm_buffer_free(buffer); +} + TEST_HARNESS_MAIN From patchwork Sat Jul 17 19:21:35 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: 12383843 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.6 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 CBD14C6377D for ; Sat, 17 Jul 2021 19:22:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7EE1761167 for ; Sat, 17 Jul 2021 19:22:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EE1761167 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E5C738D00FF; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1E4F8D0101; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B22A08D00FF; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 7EB738D0101 for ; Sat, 17 Jul 2021 15:22:05 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3482E180AD817 for ; Sat, 17 Jul 2021 19:22:04 +0000 (UTC) X-FDA: 78373050168.09.81DBDA2 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2088.outbound.protection.outlook.com [40.107.212.88]) by imf26.hostedemail.com (Postfix) with ESMTP id D5E4F200170B for ; Sat, 17 Jul 2021 19:22:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=juNKgQtDu/BcrcrQXDbxz80QAr+4n8QsSIJY7X/CJTmUwEYD9eXCR5xdaVYhcTDV+0woBW6UEYPsaHH8yf+oKKKSryzSoegMXjEmbQXNqOu+P5XCAM/EUcbR8eG7pRgzyjmAWP9/cF4XsY7HHeqFEP+DtQX0t+Det3zrc+ijVhpZJGzVyUor0Ux3J1Ikb+DehtTZE87JVHndSnKC969HBNoyxlmk9m6Svcl6TPH01LkNSE+Wu1mZFqELFrQqMGecSDWmQAgzcmTcc1cCdAF9SAKf56TI6S6A7i33vp9CFPGYZJcdFTlvrlYtmmVeLMVXBzpLWvpNgAX4ClczxuHSmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=707xnJfuFhrp+6dAh962xzl7si469vWZYp4BZWlrkTo=; b=SpbX9KQugp7MCAHGlIIvTWxF2LmYG+BKB7o5yjylqAlilXEHyxdid17LkU8DqOBOeOBYs8RcSawH9nF1aij/xPETVdoTRcF3tVUaxmSslv5hWEDFTADuWmMebE7JZ3T+4rxRwMpgv8ay9DZu9WBdxHZFUC9s5cL6xP4LSzhcQEtWG+fOwSJyx7uH5XxTsP8x/8uTuOd1UMe2yC5jTvH8B7CQKmA7WgZeYBDw3zyy6zh/RvJ3JzwFBiO8gSvnJBWpBj4vDxblVNrwoCoVfKbIgmtCxrgh51MfotQeRwPleMGSZhtPc7f/AUnqYQyCjge7JGsLQiXg1cRmckrHT2n1JQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=707xnJfuFhrp+6dAh962xzl7si469vWZYp4BZWlrkTo=; b=5tMeas0m3k0B/QBW7vt2hfKwrtxcRCehJFUY6NuF6W9nKDGhWRuPHmu/2koaHAYnSXdgoxfa2mfcxtp2bSQexvPwz2+M90I6GODuHFPIIhj/0ljV4SkOmffCdGOHmen4JMp8J+HWG1F0v1Y9o/x/ieusoSRMQagl0K3zE96+IaY= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB4670.namprd12.prod.outlook.com (2603:10b6:805:11::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 17 Jul 2021 19:21:58 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::d0d3:a97e:6b7f:ab39%7]) with mapi id 15.20.4331.029; Sat, 17 Jul 2021 19:21:58 +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 v4 13/13] tools: update test_hmm script to support SP config Date: Sat, 17 Jul 2021 14:21:35 -0500 Message-Id: <20210717192135.9030-14-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210717192135.9030-1-alex.sierra@amd.com> References: <20210717192135.9030-1-alex.sierra@amd.com> X-ClientProxiedBy: SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) 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 SN4PR0201CA0067.namprd02.prod.outlook.com (2603:10b6:803:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sat, 17 Jul 2021 19:21:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81c63fea-588e-4ab3-b0bd-08d949582332 X-MS-TrafficTypeDiagnostic: SN6PR12MB4670: 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: lzRubaDRxtU8ctmhTypHDJF4J8NyuAATR7qvuK0City4kggLrmijU+jXXFb8pruCvobYJs+LG8cHsfC+k7x0nxJwusDiDTi28laWlpyvpgCK6FFg3JIS5EoqTGZxlZns0o35XxI5DHXkW4DH13PpCK/4tgfkwG6xC4pFuYE6FTyo8gMTITYlarhmdLV8xyn5QL8Dk9L6/WTDlVuZtDmFWSvD2A5Hw05YRf5woAo8/gjD4ahYEtBQla4lSdpFogXOAIVbWkPUvDWIRJ48O/lkBvlNRK/KJ+GQMxlxnhLkTa3x2WvOODkWjpErwYgMq+HqY2zD/Fkg2GFB/ikeq+k96osNXwFw/aihWaDxK9TMXUxBAkQSCo+a9Xa4yJ4SMTOxp3Sbdr9J2/DPE34pmjCzDPU9GBFW0wOxeRkI9k0YctURHcCnSyk80pF8agZhw3I7WFh9QlXJGerxSfFrvfXBJMLUDTRLBRydEBW7oLOH/cfMcVzq0Yzc/r+Xnclht1UkXq8AVpWouHryUT8vT0aieO1QhjzJK5Qa41E3pQsHCnBjzRkJTsaiHqdDNZweG1ZTdMaH8GMJwE8ueetV2KeXK/C1gQgjB+HrnINu+h/gvhVUNWomeRZf8JdGIhtQ2i0v0bnlMdlKc2utvQ13zxEVkPUTcmKnmZAZzw266+SII1Y9HAVE0wPODNVqBiKvnQLMWuKC9sA+9cLohsUkWRDnbQ== 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)(52116002)(2616005)(26005)(5660300002)(2906002)(7696005)(7416002)(1076003)(4326008)(6486002)(6666004)(186003)(8676002)(956004)(66946007)(86362001)(316002)(36756003)(44832011)(8936002)(38350700002)(38100700002)(66476007)(83380400001)(508600001)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zGmR3L6TrWoP2ei+sSFhjnxheJtnwQwLYJ3LHQcYVY6k4jSY40FYQCt/hPSqKybdOrSjPIPe63mTRjCx6/lNOeNXOmR4GkMGZeQfy/CxSEJIYBbXcvP0pRAEVe6kHXF0Fe5cUQ+1YK9qkA2hmvVADiartdDB/yVKD2AE+W5UjloyiWVC/boagZqnVqakduuGb2tTS1Q1/iOrKCaoXgdXBku8t4T8oUVVf6ZU8y2JmWdGWG9e6N0Q7vea6LhiTnzd2pLL88PkzoAHqSxXElKn9pN5/xn4mcrWf6pdR09kCj6gQhpeAFxpPAxiII+vEOOWwy3qjCpRB/kBpfO24hzJa6BuETuaKWXf7yIXmR2Uoklt1bcAQVtdQYr9sicSVAAkzUh5uUN/V+6+OGMgCsENzcSqTqlEm+pUkaWwQAOBKxHeUuxga5V6qUFka4d80YDrUkWFsmqxHmhj6BkWJ7mEnAmGXy/e2wedXv9PWW/fGm5dF50N4XaVtdX9+FIUu36CsiNzLdSkinHTJkKbpoHwr0ESqHS4cnDN0c60AzgGMTpJtjsAB5065caIqK8sqOCZDQ2kmDXf4ErA0PB1oR8vWtnPJ3mH4XD+09YnNP4rpiI4oie6xvq93CDfPxVJPsf7E3eR+1gLWwcWkAVSn+DFDQ+2RppFvGttuM4wSzoMMXaBvRvIlgWWRcWNhJ66qWfKlocrq1IeRRLvh5HEht69w+gvUMXohFnkPTkzzb/I6Fn9MCSuJhLIh3eFbndWgP3qeart/wU6mxb34HIaP6C17me2nEXQHdAjcU4Gjoz+5MvFPVE93QnHaeTlFkZCok3Ce6hrRb6axr+wgnIhZlpDTeWsjR9938SAGtd6aJCCClBZa/Xnm7xP9yNOg2jbbMpkpg1Jf5X6rt8m1gAimxCHBAwkDyKPN3UA1qGM1bzMc+lwk1aNcrS/0jNvABQpzkU+g+sabWkGGMNlEtT5SJ7pzJcLjbpEqfoBW/Q5IXbBvais/SjKL4pPD+Mpbilzc5XFm9GOHb4GTYtudUXody6ozYUH10LH4AVe54p+Oo80Hr6fcwVhp51An074ImSIydcNVlw5+qomgtEGnV3rBgwywpUh7DbTkcARuGOwzNVRqz0cX+OyWlLOz9Xdcb2FC59sXtljISnC+Zg5fcgZb5HLj4kzkhqAk6dk1zBS1poGEhvqhQ9GFaBOLQfeAKkLsRK9znqikjJ3cy0X74J6jTVJ/P222+gFJl4IZ1XujXdAGoZsdY7PqROzwvX6A3o3C7gdFH/axUQPlXhhKfCFenzzXg/OtsDLQARjIBpYpqDRO1AlpCzc/MhpHrjv9UxTDslW X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81c63fea-588e-4ab3-b0bd-08d949582332 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2021 19:21:54.7344 (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: d3d89DOdyUPpMJllcwFW2JAt/V9fPPbJbxKdMdVXmblKTsSTgXZvQ8PmjL41SL4Jg/mjJlJofz2GX2TXJ8+Vag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB4670 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D5E4F200170B X-Stat-Signature: jt8ume36k5fambdiui9nsbwd3g99cypk Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=5tMeas0m; spf=pass (imf26.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.212.88 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1626549723-313536 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add two more parameters to set spm_addr_dev0 & spm_addr_dev1 addresses. These two parameters configure the start SP addresses for each device in test_hmm driver. Consequently, this configures zone device type as generic. Signed-off-by: Alex Sierra --- tools/testing/selftests/vm/test_hmm.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm/test_hmm.sh b/tools/testing/selftests/vm/test_hmm.sh index 0647b525a625..3eeabe94399f 100755 --- a/tools/testing/selftests/vm/test_hmm.sh +++ b/tools/testing/selftests/vm/test_hmm.sh @@ -40,7 +40,18 @@ check_test_requirements() load_driver() { - modprobe $DRIVER > /dev/null 2>&1 + if [ $# -eq 0 ]; then + modprobe $DRIVER > /dev/null 2>&1 + else + if [ $# -eq 2 ]; then + modprobe $DRIVER spm_addr_dev0=$1 spm_addr_dev1=$2 + > /dev/null 2>&1 + else + echo "Missing module parameters. Make sure pass"\ + "spm_addr_dev0 and spm_addr_dev1" + usage + fi + fi if [ $? == 0 ]; then major=$(awk "\$2==\"HMM_DMIRROR\" {print \$1}" /proc/devices) mknod /dev/hmm_dmirror0 c $major 0 @@ -58,7 +69,7 @@ run_smoke() { echo "Running smoke test. Note, this test provides basic coverage." - load_driver + load_driver $1 $2 $(dirname "${BASH_SOURCE[0]}")/hmm-tests unload_driver } @@ -75,6 +86,9 @@ usage() echo "# Smoke testing" echo "./${TEST_NAME}.sh smoke" echo + echo "# Smoke testing with SPM enabled" + echo "./${TEST_NAME}.sh smoke " + echo exit 0 } @@ -84,7 +98,7 @@ function run_test() usage else if [ "$1" = "smoke" ]; then - run_smoke + run_smoke $2 $3 else usage fi