From patchwork Tue May 31 15:56:23 2022 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: 12865888 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D77AC433FE for ; Tue, 31 May 2022 15:56:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 747916B0080; Tue, 31 May 2022 11:56:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60A6D6B0081; Tue, 31 May 2022 11:56:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42F316B0082; Tue, 31 May 2022 11:56:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3154C6B0080 for ; Tue, 31 May 2022 11:56:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 00744510 for ; Tue, 31 May 2022 15:56:51 +0000 (UTC) X-FDA: 79526491464.23.557BC48 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2054.outbound.protection.outlook.com [40.107.94.54]) by imf10.hostedemail.com (Postfix) with ESMTP id 4BE74C0063 for ; Tue, 31 May 2022 15:56:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YazggbAUpZO7V2n9VUBwqymcxCWBBVAtj797+qmOVqrW9qQnVG0Viw7qW07YrT+xpJKxV3cYL/zNId5AljomwgMX0jON7+m8+mQ6wioc/XzPqRQnD6ilAABkqiYetoEs7p1GdaBYtOvT+y91YzmKZSDAGvCGWudoSKAaVMDkqaOI31pbmrBGLdKczpT8UFZeBkYnS6FXfo7xIKzAUybYXHWcmpoxRiCuUbAFuVQlTdRKmtDGX63n0vumH06SujuYYCLlvS++pzkI3lZIm8qaAvtRQwWFhxPlPT9muRDvSGyBWxTWSVv4KpujtHITD/GzBHzP011//yP7yQWwhzEzbg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BO1XgdLChGhcmXQYgQRlktGItGh1h3zZzS9U0EV0V6A=; b=RnyGRNfwHmHQ9ksEDrCxMo9gVB4E7euoQ1miU/KUZAoVBtNKai983tcXfZRV64fztteHDnqs779bldVpHShBJ1zmoJJMHyqemKfj/l9zMnVCZTinAi2A4iZ0CdjATFjqOFHAm7DSl9KDnOF81HJU1cs/iln+HLXXMpi6pNGk4AiDeGELGS7C8PCJcW0gPz2JoFxceVTPLDmq89+Jso7brpcxz6oKcVkPo2Ze1hlYhXZNToL3X9lir1ulB3HDH7s1WgJ2jsZL5rPWZ188ZGo/FbRbGHF6FnDfvp6uuuQcbR0Ji15ybVNPptc1kFzoj3g25ptuIe5xb6nUoLS0J7vqHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=BO1XgdLChGhcmXQYgQRlktGItGh1h3zZzS9U0EV0V6A=; b=TRHDKlMp8Ik7n+RSv+45ZizypaNGUYqCJHoyeRGlRrcPYWvIKWtyyh4ZRR0MNEJ0VWLCOxSxFPFTdOR/vH5YLzVvXDA0MRb0idOqcQLjGRO43T0ICYmckwiVf+rNIw7LUTn+gg56pK6x7NjWSD3HY9p3wJdF60rg0sNpdJDnGqw= Received: from BN6PR16CA0040.namprd16.prod.outlook.com (2603:10b6:405:14::26) by DM6PR12MB3996.namprd12.prod.outlook.com (2603:10b6:5:1c1::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Tue, 31 May 2022 15:56:47 +0000 Received: from BN8NAM11FT043.eop-nam11.prod.protection.outlook.com (2603:10b6:405:14:cafe::e9) by BN6PR16CA0040.outlook.office365.com (2603:10b6:405:14::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19 via Frontend Transport; Tue, 31 May 2022 15:56:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT043.mail.protection.outlook.com (10.13.177.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5293.13 via Frontend Transport; Tue, 31 May 2022 15:56:47 +0000 Received: from alex-MS-7B09.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 31 May 2022 10:56:45 -0500 From: Alex Sierra To: CC: , , , , , , , , , , , , Subject: [PATCH v4 07/13] lib: test_hmm add ioctl to get zone device type Date: Tue, 31 May 2022 10:56:23 -0500 Message-ID: <20220531155629.20057-8-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220531155629.20057-1-alex.sierra@amd.com> References: <20220531155629.20057-1-alex.sierra@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c0ff19af-07ea-4dd9-d2c5-08da431e2ae4 X-MS-TrafficTypeDiagnostic: DM6PR12MB3996:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V+4wN5PvA5HX4SqadOhXLZahps4qeoiyH7oyPljLL2zj/8E0FAQUGapWSE1s4dUIyWBuaknhB6x9QUD84ZRaws0ye/fYlbQeK1iI6xojQ4H9KVfDoXwbkDPTIGGoGnLDQaSvYslNp8BO4VDcnBwazr3FRu1w3EjeiyP0mEl0NyCZZxCualNuGzOUM/AeibsaeINqzsvH0ivFIGLO3gVLLw3cvczWb/ZcgTB0PVLk/phN5hdX4QuAyJdya0cL5qk9/uacJwNRqi7HxQhBI5Rk4p8x6cw7gJ55IigesCA4TQbDlAJAbAv7PA2OEYpkKg8aBlqKdUHqPhDflSp3htKVBRd5U9KKGKBRGw8n3zaDjKWWQiv4PaAcF4sV4cRY9+sBP+IT2pU4pwiP3XriT+cVQhSd4QcsJcs0PqQlWPhUYQZHLrO1tUVXbTBT10RP1hpRDaXo0GYOoymJ61ynYCoLmbGHYFv1Nzipp+sjM02VYNtZWLWVbDjpC48piGyHFhXBOLxdqAQLENHcsE9Pf/25urGq4x/d/Hr4AyvLMqtA9aTjBYUaGsMDuidXvWVIB2LeF2Te5ioFIFYFrWMftnt/T+pcaRUjlCZ0ExclRz8KeWyJJG1DbYV5GtbU2iV2rfO2a9QJfTDCuEYBuV3wSUdIiro9BrD5ctof7jKMxS0G5DeaKQN/eUiNum6MgMEdWcKTDc/BNYmwy+W+LaQjLKHkTQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(426003)(1076003)(336012)(2616005)(5660300002)(508600001)(186003)(7416002)(82310400005)(44832011)(81166007)(47076005)(86362001)(36860700001)(16526019)(83380400001)(70586007)(36756003)(4326008)(54906003)(316002)(70206006)(7696005)(6916009)(8676002)(6666004)(8936002)(2906002)(356005)(26005)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2022 15:56:47.3440 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0ff19af-07ea-4dd9-d2c5-08da431e2ae4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT043.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3996 X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=TRHDKlMp; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf10.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.94.54 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4BE74C0063 X-Stat-Signature: e1gm6edg7fyumu9kmcdnfbbqztidx3er X-HE-Tag: 1654012568-771603 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 coherent type. Signed-off-by: Alex Sierra Acked-by: Felix Kuehling Reviewed-by: Alistair Poppple Signed-off-by: Christoph Hellwig --- lib/test_hmm.c | 23 +++++++++++++++++++++-- lib/test_hmm_uapi.h | 8 ++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index cfe632047839..7a27584484ce 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -87,6 +87,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; @@ -1026,6 +1027,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) @@ -1076,6 +1086,9 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp, ret = dmirror_snapshot(dmirror, &cmd); break; + case HMM_DMIRROR_GET_MEM_DEV_TYPE: + ret = dmirror_get_device_type(dmirror, &cmd); + break; default: return -EINVAL; } @@ -1260,14 +1273,20 @@ static void dmirror_device_remove(struct dmirror_device *mdevice) static int __init hmm_dmirror_init(void) { int ret; - int id; + int id = 0; + int ndevices = 0; ret = alloc_chrdev_region(&dmirror_dev, 0, DMIRROR_NDEVICES, "HMM_DMIRROR"); if (ret) goto err_unreg; - for (id = 0; id < DMIRROR_NDEVICES; id++) { + memset(dmirror_devices, 0, DMIRROR_NDEVICES * sizeof(dmirror_devices[0])); + dmirror_devices[ndevices++].zone_device_type = + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; + dmirror_devices[ndevices++].zone_device_type = + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; + for (id = 0; id < ndevices; id++) { ret = dmirror_device_init(dmirror_devices + id, id); if (ret) goto err_chrdev; diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index f14dea5dcd06..17f842f1aa02 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -19,6 +19,7 @@ * @npages: (in) number of pages to read/write * @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,6 +27,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 */ @@ -35,6 +37,7 @@ struct hmm_dmirror_cmd { #define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd) #define HMM_DMIRROR_EXCLUSIVE _IOWR('H', 0x04, struct hmm_dmirror_cmd) #define HMM_DMIRROR_CHECK_EXCLUSIVE _IOWR('H', 0x05, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_GET_MEM_DEV_TYPE _IOWR('H', 0x06, struct hmm_dmirror_cmd) /* * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT. @@ -62,4 +65,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 */