From patchwork Mon Sep 13 16:16:00 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: 12489915 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 F3B61C433F5 for ; Mon, 13 Sep 2021 16:16:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6D9860F58 for ; Mon, 13 Sep 2021 16:16:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A6D9860F58 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 1B80A6B0080; Mon, 13 Sep 2021 12:16:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 169FE6B0081; Mon, 13 Sep 2021 12:16:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F26DE6B0083; Mon, 13 Sep 2021 12:16:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id E3F076B0080 for ; Mon, 13 Sep 2021 12:16:25 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8DF05299A4 for ; Mon, 13 Sep 2021 16:16:25 +0000 (UTC) X-FDA: 78583052730.40.C26F5A9 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2076.outbound.protection.outlook.com [40.107.100.76]) by imf16.hostedemail.com (Postfix) with ESMTP id 2A251F00008E for ; Mon, 13 Sep 2021 16:16:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TX3w5kUexJUMhoC5qIyYzd0gVokdEVhGrOOnrOYrTDTojF1MLBBeiuYjmy5Tv6fZjtS8IyTL7PgjvSitU5jiyiyOg9La/DGEHUWXZJ9IXjSmqtmDHwNHdmWaO/K4xtHUQyLtmRx9JX8/Qmr2/2QkghWJzFXa6eoe/Z1lQ/tIyzkP+j+z6W4dr5HgpVUnu0RxnfX6HdmDkZrIDbE2ObRc1v+bq2Ptxp6lqTEDg+KIs34hbhhMfDxxFBRdhCiNep53/bwue6iBzitCzLyRl8z/uXtKtZ3wHOaJO/fvzIjDWFaQuOPAKBZEfJOSOaSvcLGg2UEVFpKPxGNwfTUMubDDvw== 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; bh=dKC0SDJcXNMoavar9nuqOgDG5SsEzpi3aevSualtrlA=; b=NzL4yqV7kgRABOtmIJHdflqS2WaQtDrTgWs+a4D3DW70NKfX0shYmDtpK30as6Uy14O9G54S4K8hn4uWxxiSfaigyVQRodxu4gBJY+UqoyRTgERUXYv5vkDjb15OoFdCrsCa+OkqJnxTNKA+YRd5lA6687WY3fMsSCkhsMfnZ5d7bWheyOK7zohZ1/2p3YzAib2NT0zXlmjslqJCMLFWUvC7LF1JQaCpacJ27JeOau+HBlGEAxIRRerlcGUdZFQYAp7LnOIT5pAQEFXA3opDFTXoESGLVgqarUYs3hZ9xJYq2lBzPguXrJU6qQgWNxENzsVW41Y4oKPv2N2uYyjkGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dKC0SDJcXNMoavar9nuqOgDG5SsEzpi3aevSualtrlA=; b=keO9mHR1ET6lgbJZbLNocY0/3JsE6uFHEUNadunKKVfhh1LG1E7zI4HGRETTteLyGc8giqFeze+5d2WSHuJaLP00KeQdWQ4RGY+/VJOmiNm7p5+81rjOilGpZH6lMTVqC3yvg5DfFuLCU0II442NJQKbqwTqsr4BvqAhwNoM/B4= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SA0PR12MB4349.namprd12.prod.outlook.com (2603:10b6:806:98::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.25; Mon, 13 Sep 2021 16:16:23 +0000 Received: from SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::f1aa:9adc:b4f:4d14]) by SA0PR12MB4430.namprd12.prod.outlook.com ([fe80::f1aa:9adc:b4f:4d14%7]) with mapi id 15.20.4500.019; Mon, 13 Sep 2021 16:16:23 +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 v2 08/12] lib: test_hmm add ioctl to get zone device type Date: Mon, 13 Sep 2021 11:16:00 -0500 Message-Id: <20210913161604.31981-9-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210913161604.31981-1-alex.sierra@amd.com> References: <20210913161604.31981-1-alex.sierra@amd.com> X-ClientProxiedBy: SA9P223CA0015.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::20) To SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) MIME-Version: 1.0 Received: from alex-MS-7B09.amd.com (165.204.78.1) by SA9P223CA0015.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Mon, 13 Sep 2021 16:16:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f7d4d8e-e771-4e9c-1771-08d976d1d42c X-MS-TrafficTypeDiagnostic: SA0PR12MB4349: 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: gt7CixnATMIwlAqO65soFRDWyZfxO6BJMk8dcRb2pCP5LqTuq4N99uyluTgA+1hYAwXMPEBLkqSi3srqRxDYU3FYDgBZuOV6/V3e8vorj/CnBBqOeajH/J3/HucKCvfvXAAN0KZn0t7ZYQILnBJh0zPbJ3BxPF0kdFA7bV8yTdJcp7Q8bnk3CB37kZd3f5C7Ua1Hkj+ItnKR4oynv9R5x1YyJxxVMOL7dVeZRQNA9o9/hImepSwJRsRUzaQMFqFmSBo580YvOZQtIJyzn2fpeTTHQWI12Xz3lChj5aL5WMSRF9w5IbAFcKfinpxDSk68MGrs0mSLbrjWQ5++Am4OCwcvBXV5fPuXRfbq19k06EUrWg4skxm0eOBn1WcG4mBJAgM3RXZG72NZdKHVicRJGKuht9ft49e7jLU7CzMeZRM51vf9qqPBN+mqGpi134qOaINQw2GILmLlGCWdTMVGSrzf1fy1bkqCq90650wp5cTLT9GXf3HcpbHO2yC0YFcNiPf60JuZvCFLXHRht5ojzEORiNX7DPRl2Et0WLIjNXJRNonjMXVzWxphGaZNdFQWTFcIKJlYv3Z04aXXl0tjVoYdEJi0h2G/PImpvcJy19sYCH1ouXn9R7QeyoRwrf0KCsN43IaSu3nMxfWLKF14f5y+OYoec3xNZbBimvzaTd9Mw55PAPnGMhXfdwPWppya X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA0PR12MB4430.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(366004)(396003)(136003)(346002)(376002)(66556008)(52116002)(86362001)(66946007)(1076003)(186003)(7696005)(478600001)(44832011)(6666004)(38350700002)(26005)(38100700002)(66476007)(316002)(2906002)(83380400001)(956004)(2616005)(4326008)(8936002)(36756003)(8676002)(5660300002)(6486002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QJZpihtJDtk9j3wSmqFQsJPY6gdWi6fVuAzkn0jfueGyyxg3d7oPlpgU/IlMXEnBzi7YEzY/PVbh75Fy2Gzw8I3BTJb3yK4Nv0KH2347UruRGuTT190gdnHuWumSVV7iiKKCMgBXrpGmI+9uIinFVI4rCHO0udowL6CaQjOaXDjdI2pPU02WMDSY5c917BTcaPTNXkF2fxA4bo9Ws/dsQJydVjnnStirDV9EW+QxfNUza0Hib4X0U0xnGFMh26MbxMQJcIfqMCX6mUOdg5/mrW8YoWvvXpFerkKBub4pQVmWshRILfOYkMQx8IQPOARHGlAGlQePyYf8Yx9lxWEZGzL3CXPDxoVjKi3LW0MDej+2I4NAx6iZTwZbF6m91swjYaF6zz0mBVb/hU48TOT2iVn1soxFbryFzfiM6lyKw5ZarJIUh9al21e00kN2IkwyHQY6sJsBq2+vkTAfO0TJ6PYtCciqhiiSV8cp9fxpvEzXe1xuBxp/w+x8K82vUn+ZZkQyU6w/osPyLbCI7dDcUHIQl8nT+khucQ2I3Ng4vhdHSeWspdAjIDjSDf1K5RwLkTifru9ueOGeWjP6qClf3i7WZqlakKCXXblIU0JOcVFNAEtoxSt8JkygSTgpGoz1gUwJUlWscGsySNVJkIodQnh98vwT1Redus/Ce+I0MImDu+tJYK+warb2UawJGo+jpZg0diEYcAiVQ+jeQ8wSJGS60C2a2l08JsHhc4FPjtOu24pkgo8Hdllafqzb9lIBGeVgGlVAFj412m31j7L3e7F6lDVQNWMjf0po8zkLH4fDLl0brVPn2afZPNF8j7rAS3UxUsMReqGIRUm4LRMPFoGNTLyXw5bm51N0mOGIdOopmcyTQN+lRDGk9srJqu4XjKmxDZ6W7hxnvyUBsqB94QJHTFmXrrw4ahFc32AUHdt6KPv9ZTk41gg9zlZZ9o3gVzkBMbWj9HNhBCwbJK0YN5HEgDXsKzU3YlSS9AlojcVxbA363XsC4ZtDRfEm4dBvJB4knOy7lxeUw9M7D4X8rjsawxREdXUCLdZJfGZQfgW3CxVpmI9416cHO425KxFjJWdaQVuE+SDkICOvmC20lz75pFqX/Qf+irpne1Qn/5INFqF0gmkIUVTr+mmg8v4KoRZ6VklGbYvlVbj32osFGNwkXM78VUGJNQ1wC1cPeIprsOA5x8ikC+KKTmgYbONAxxuFusp2UkF2A/ySi5WQPfAWBpgSmgdW5v6QDpNaKQiXwz2MXjiyrB9YW/l4JWXoIvYBdSwKGe2ZztdjmCrZKfgdP0MroSUUMYsd1uX3Hq0Wqbu/HA+9KEoqOWF1hmUX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f7d4d8e-e771-4e9c-1771-08d976d1d42c X-MS-Exchange-CrossTenant-AuthSource: SA0PR12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2021 16:16:23.5820 (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: pgne6P/mS3B5DWF1burbTt8qgSDrHjYRawWXBMGwDGL//PwCdZrQlgNctGJNTLfW0/KjauHU5Vx+zjC7Sh7SLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4349 X-Stat-Signature: yjumzfu8umkhqud6p65qmct8997fiabh Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=keO9mHR1; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf16.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.100.76 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2A251F00008E X-HE-Tag: 1631549785-927869 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: new ioctl cmd added to query zone device type. This will be used once the test_hmm adds zone device public type. Signed-off-by: Alex Sierra --- lib/test_hmm.c | 15 ++++++++++++++- lib/test_hmm_uapi.h | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 6998f10350ea..3cd91ca31dd7 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -82,6 +82,7 @@ struct dmirror_chunk { struct dmirror_device { struct cdev cdevice; struct hmm_devmem *devmem; + unsigned int zone_device_type; unsigned int devmem_capacity; unsigned int devmem_count; @@ -468,6 +469,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, if (IS_ERR(res)) goto err_devmem; + mdevice->zone_device_type = HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; devmem->pagemap.type = MEMORY_DEVICE_PRIVATE; devmem->pagemap.range.start = res->start; devmem->pagemap.range.end = res->end; @@ -912,6 +914,15 @@ static int dmirror_snapshot(struct dmirror *dmirror, return ret; } +static int dmirror_get_device_type(struct dmirror *dmirror, + struct hmm_dmirror_cmd *cmd) +{ + mutex_lock(&dmirror->mutex); + cmd->zone_device_type = dmirror->mdevice->zone_device_type; + mutex_unlock(&dmirror->mutex); + + return 0; +} static long dmirror_fops_unlocked_ioctl(struct file *filp, unsigned int command, unsigned long arg) @@ -952,7 +963,9 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp, case HMM_DMIRROR_SNAPSHOT: ret = dmirror_snapshot(dmirror, &cmd); break; - + case HMM_DMIRROR_GET_MEM_DEV_TYPE: + ret = dmirror_get_device_type(dmirror, &cmd); + break; default: return -EINVAL; } diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index 670b4ef2a5b6..ee88701793d5 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -26,6 +26,7 @@ struct hmm_dmirror_cmd { __u64 npages; __u64 cpages; __u64 faults; + __u64 zone_device_type; }; /* Expose the address space of the calling process through hmm device file */ @@ -33,6 +34,7 @@ struct hmm_dmirror_cmd { #define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd) #define HMM_DMIRROR_MIGRATE _IOWR('H', 0x02, struct hmm_dmirror_cmd) #define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_GET_MEM_DEV_TYPE _IOWR('H', 0x04, struct hmm_dmirror_cmd) /* * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT. @@ -60,4 +62,9 @@ enum { HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30, }; +enum { + /* 0 is reserved to catch uninitialized type fields */ + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1, +}; + #endif /* _LIB_TEST_HMM_UAPI_H */