From patchwork Fri Aug 13 06:31:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sierra Guiza, Alejandro (Alex)" X-Patchwork-Id: 12434779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C416DC4320A for ; Fri, 13 Aug 2021 06:32:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 75F7D610CD for ; Fri, 13 Aug 2021 06:32:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 75F7D610CD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 10A718D000A; Fri, 13 Aug 2021 02:32:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F39308D0009; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D621E8D000A; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id B2D6E8D0009 for ; Fri, 13 Aug 2021 02:32:11 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5A95E8249980 for ; Fri, 13 Aug 2021 06:32:11 +0000 (UTC) X-FDA: 78469087662.36.62EB437 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by imf17.hostedemail.com (Postfix) with ESMTP id DCDF7F0011FB for ; Fri, 13 Aug 2021 06:32:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k/yqxzjGKKMtxC6SKZJxq7t5GnBNBnypbmW9UlA0uiyoQ9F3/KyCg6ZfawM7Jm3Ohhvhz213WjvJ4OnxCzwhChrkuyftW1U7WFE1ZitTxX5KE1vKRc7y+fbnAENZ9YarUT1YzgkXreembg6hhBRKFojudCYKrU2Ra5AQ7GSWNkeoAUagE6wHl4JFJ+vWIH/aW5gtAy34sG+M9JMiNanHNNpmxyDbhHYyAzeGY2FuZBSIZ/Hehsgr25gDEr56SLw59+uNtvxjdjaPCzrd77vOi1YuIBh0ypRnp6+SSRwSl7ysoN/Hi3RjyaM16H37oZ9L+VDKHqGNhlyaxRLlzaRFQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/JYNbIZyT4GsemXLmS0c1O12FNYR+CKGj4BBJeppL5Q=; b=h7FF5dyhPABr32hykHSR3soaAyT+4YBOnOTOaV/PPA1SyYSsrsUEyYMmHDKgwWJRsGGUSwBGQluapKrrdz2XqCTVTIfHAYa0Gp4mQtG7Gdf4F+6WdqqwjcYFELsaRJMsJYaeAhlpAvW29fNP5v4NK/0AxLPv5HpiXdbsrqxIlWilpAFtxR5Qtfb2xjALZa1KyDurRuUUPbyJFZwUYn7xSRXfHC5D1XF93ebNFWp7j9W9+Cg0LUgI9bMA/iB2TFZvW2VlDp7ozTYaaNKDEcwBi0P/aUdrGFH7M3NX046XHFQeqGFqBuXPm2pjZGrrPi/Wph2QzAXoLV9BBFeYW/o1SA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/JYNbIZyT4GsemXLmS0c1O12FNYR+CKGj4BBJeppL5Q=; b=B4VhvBwjKZNqq8rqOAKc33YE9AAKN2hXPrVMmZeY4llqBnCHOTbvYkVl6gcdZXg8gmY7/Bfl6DDbnI440+HLdumD4VAA4vakOXgU1tfEsxca8cZVfThnWUvUPZFLKr+q7gelFbtVNXpCdz8ZEC5YsWXPEYhguwaI4uFuvfSmDmo= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN6PR12MB2782.namprd12.prod.outlook.com (2603:10b6:805:73::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.19; Fri, 13 Aug 2021 06:32:09 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::e828:5445:a5aa:94cb%5]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 06:32:09 +0000 From: Alex Sierra To: akpm@linux-foundation.org, Felix.Kuehling@amd.com, linux-mm@kvack.org, rcampbell@nvidia.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, hch@lst.de, jgg@nvidia.com, jglisse@redhat.com Subject: [PATCH v6 09/13] lib: test_hmm add ioctl to get zone device type Date: Fri, 13 Aug 2021 01:31:46 -0500 Message-Id: <20210813063150.2938-10-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813063150.2938-1-alex.sierra@amd.com> References: <20210813063150.2938-1-alex.sierra@amd.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 06:32:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7950325f-1441-498b-87ac-08d95e2413a6 X-MS-TrafficTypeDiagnostic: SN6PR12MB2782: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xHMFYiIYJ4XMADOEx3g/HpJ3N/Ac43Ib9Y3pK62P3bynBpqOEyZ3oAmHj9ymRleAeVFghC1VVX+KcKVwI11T3Lb2Jdks9PyB7RCHrjGg6CO4/uApJddKmU6bP7Iy6iTZecqP0FGk3RfzzwtR2clOMgLD+W29Bw9OgA0V5Lnfdnr7Ahp9be3eeouovSUxmAZDxA4JJvCH7XA3/q34DYUTmw2wP/J+fWcET5mwSQhA4xXGsRHs3afiKj+k0ayGoTN3QhgGL6cSAbDpHc5whE3o7wRl+r/v5+q2UbqSEp2ZwCeBh2v0c4nrLoAoiyAoLTWE5WPZFTz96Ld7qh63PkhA1b+f9+uRKkLrixjZY20EL4le9WunRvHtE5vUlq8Yq87rKVJ8tZkSKefP8JWUP8PgKHVoNKfQS+zDHNyCyBZivlgmYEx3kfvcUxuNNaxC/hsr79i8FV6r+l/8avJcxa4+3eII8zAL0Qy8vMe7wGr4OguaMsYFGRk4OMdjuzQSbyApyk01TOlNMvUBYUXVPK4GgAhZhRLnIkacwruwUgV2rTHaey8dcMoxKibCtXAskAUAuMebWPlcObFS0ZW7spIsQZ5bpa3PCiu8SOAikpkVaiDGwcf8+imH87zq9alGnP1HMVyPXSjG2CR7lWThKzZkda1siy98KSngyDfOUoI+Zn01+EAtdmmyLGiaW+tHn123 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA0PR12MB4430.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(346002)(396003)(39860400002)(136003)(316002)(2616005)(956004)(7416002)(38350700002)(7696005)(38100700002)(66946007)(66556008)(4326008)(52116002)(36756003)(6666004)(66476007)(1076003)(8936002)(5660300002)(83380400001)(44832011)(2906002)(478600001)(26005)(6486002)(186003)(8676002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YaTcSpaGInWmNGP99O6ENAsCr3IlaSsP1TRYCk5Yunq1zzCyhP49AolG7f8ozaELPhR4RSABnjH4NKGrwIoXitfqW7b/DjCh5v7BrficsLjC8oSOVD/yBgD/QIE/IdSXrdQPDx1yOAXJ9yYg2IhE2AnLPGYgu9VRHpIkdlks4a10KRvGlMqJlTR6ZKHPo2oF1EsFq79a3GXnTPKks96Qs/rhSJhaXLeg8eVZflmmUpxdkZZuzvxYOCA135/vO3qu7NQpwPhb+md1Z2Nzr4GPJy+oaxd62Zk1dTFSLDeqnjdnCwHPvdmGNUQn2fi1gGMg+IDtAKGootesr6A1nCxcYif0If/o6AZlWLZz6TWDzmw1PIuRqCj0W44RyEhYLTt0SoroBArV5u1Q9lXdQQj+/eJJ7wru9TfpXvn7s3l2pppp8ZR+F2Ox9d0iyWRD7Sf8DHGT0Ripy2byrkbDKn5FbqlO30Jigd2Xyguj0HtJE3nRfGYwftk+CEv6IAV7vIttdN9QDv/eYxfE5+nvt7kQmQ7Xi9/B3HMkNEqcXvKiPHe8TX82xVe55XcBWRRHtEO5CE1OrpRXQuRT+tU6fxodiXGU5wzyVTzNbF5xYlM8CVhewQZwg8Is2Nvk4CFf0d+NUwcitMnMdBjrp/mNKU0EcB/2kz1O5rHek25bDUli5gY5wF5JlSTJ+bIcyb312oXW826R4+J8LyvllItOqUYObIkai8UrKaarEPmw3TIHMhPq2OJa9E4ZSFGDuL5LAqFxWzLmnxEH0GUBgZ3orjnOBQwWbc4g8KJRGMkp7R3GccL7J6lux4lcwRo5n8BzZR/bbOnbN85EIekRVTK27kSnXfwsvjVewm1ONyvb1yz8WPLjd/2V9gh/USgggRNFhT678GkAzF1czjz0+uDLvACCOV3J50HmmdZpP0RnHtmqVKywxZoSGnE6joIVYHUYaYgRZHfHT9JKN2NfBQCkDjbrbC6sMNYJ/FbER2MtOaK7X4aZr4oBWsO0INk1X6gjURLT/VHCX0v0dh36D0+QBzMdr9w0S3uA6ga/0ygvLz3Sg6iMopyOGZI5jTubBCziBTI50cNVbN2kzlbAQOyecgWgS0tCLjKkRiVpNdigdMubIV34n/aalD/oc9aue4iO4LDbLPcSCK/EwRIy8DzrVVL8Tqtgf5+TnkTeON4PWsO+zus7sYQH0jpqGVXCVIpuLbxo6SMM89Eeknq5A4AQb7xPbpLGCkCn7qKFDxk0xw+nzw1hTnIwNp6e5c/8hhE+7C0B1nzlaJbAB+OZVu+jx3iLXvpyDYToiTo8v4Axr+Xu0JCjDgEQ6qDM+np5r+B/NP6I X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7950325f-1441-498b-87ac-08d95e2413a6 X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 06:32:09.2305 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Se+77Pgv4nwaXO0ni4QWQwVe551eqtFH/83Ant/uFuckdZmZyRoikpIEmpTtyJLNMwD+ivzPDxwItB3uEhtrIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2782 X-Rspamd-Queue-Id: DCDF7F0011FB Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=B4VhvBwj; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.220.87 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam04 X-Stat-Signature: mtdfwsep7d5gb3in1hz3347496yp5qtm X-HE-Tag: 1628836330-223268 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: new ioctl cmd added to query zone device type. This will be used once the test_hmm adds zone device generic type. Signed-off-by: Alex Sierra --- lib/test_hmm.c | 15 ++++++++++++++- lib/test_hmm_uapi.h | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 6998f10350ea..3cd91ca31dd7 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -82,6 +82,7 @@ struct dmirror_chunk { struct dmirror_device { struct cdev cdevice; struct hmm_devmem *devmem; + unsigned int zone_device_type; unsigned int devmem_capacity; unsigned int devmem_count; @@ -468,6 +469,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, if (IS_ERR(res)) goto err_devmem; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; devmem->pagemap.range.start = res->start; devmem->pagemap.range.end = res->end; @@ -912,6 +914,15 @@ static int dmirror_snapshot(struct dmirror *dmirror, return ret; } +static int dmirror_get_device_type(struct dmirror *dmirror, + struct hmm_dmirror_cmd *cmd) +{ + mutex_lock(&dmirror->mutex); + cmd->zone_device_type = dmirror->mdevice->zone_device_type; + mutex_unlock(&dmirror->mutex); + + return 0; +} static long dmirror_fops_unlocked_ioctl(struct file *filp, unsigned int command, unsigned long arg) @@ -952,7 +963,9 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp, case HMM_DMIRROR_SNAPSHOT: ret = dmirror_snapshot(dmirror, &cmd); break; - + case HMM_DMIRROR_GET_MEM_DEV_TYPE: + ret = dmirror_get_device_type(dmirror, &cmd); + break; default: return -EINVAL; } diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index 670b4ef2a5b6..ee88701793d5 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -26,6 +26,7 @@ struct hmm_dmirror_cmd { __u64 npages; __u64 cpages; __u64 faults; + __u64 zone_device_type; }; /* Expose the address space of the calling process through hmm device file */ @@ -33,6 +34,7 @@ struct hmm_dmirror_cmd { #define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd) #define HMM_DMIRROR_MIGRATE _IOWR('H', 0x02, struct hmm_dmirror_cmd) #define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_GET_MEM_DEV_TYPE _IOWR('H', 0x04, struct hmm_dmirror_cmd) /* * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT. @@ -60,4 +62,9 @@ enum { HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30, }; +enum { + /* 0 is reserved to catch uninitialized type fields */ + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1, +}; + #endif /* _LIB_TEST_HMM_UAPI_H */