From patchwork Thu Aug 12 06:30:56 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: 12432587 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 AD0B1C19F33 for ; Thu, 12 Aug 2021 06:31:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3F6A860FC4 for ; Thu, 12 Aug 2021 06:31:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3F6A860FC4 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 2F1676B007E; Thu, 12 Aug 2021 02:31:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27AB08D0001; Thu, 12 Aug 2021 02:31:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A78B6B0081; Thu, 12 Aug 2021 02:31:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id D4BDD6B007E for ; Thu, 12 Aug 2021 02:31:27 -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 7EF03248A5 for ; Thu, 12 Aug 2021 06:31:27 +0000 (UTC) X-FDA: 78465457014.21.050E8E0 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2063.outbound.protection.outlook.com [40.107.223.63]) by imf27.hostedemail.com (Postfix) with ESMTP id 1236D7004E2B for ; Thu, 12 Aug 2021 06:31:26 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fXBW1NXUBoZVQv1IY3JYEy9QetubdreVd4S6En5Lw4xs+3MKwnozJILedUXB2EYf9YfPR4ibOvZ9LlAGF/avhnc4UGGpkF/aptJG7iorFDvCrTM3zgJr5z52pz0ddjnXbYMO5Gm/TmFj9VyAPMcK0YzzQlwSGXlBSDczs+pOuC6j+dqlOn6Nv6tesZX9LRBbptBRIo1Ye5aj+DojZe4F9qI5c3FV+UmGrfDbfGjgWvFn5GNcyrEIRv3zXP8UvJTGoieEbSFYm0t6+vGkQrkU+rb4s0WPNpDEflPxe0o1gmiJZRCr10WaDMXZMr+2lDPKmWgWjjmVOa9u8od7z0MJdg== 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=Et5NpZNp6baPuoO1eo3/+HoNUaFi1qAFbcizlX1n3SsFAG7F7tIAdZ10BOx4j9wIgV3vd73lgMRMZ9/GCPOEO2kSK2UQfZAJ2W1iiXLinAE2p0ZEL52Aeaef77PSZfo3AEvyC1V8lk2/LqxEEJ/g/LKUuv78SzsNwRUBDl1IIDRekYLFhbzenF9tD005r66+8urK5rmVvhtjHW+CQrTmzbZhSMGBfBPdKEMi7Ol+X7IWomElD0kLJJQ6b1XXEKn2XuJ6y/oOZaGRR9y5+I9dlieym9tBxLHLITzKxixxROKE/ADFdyoCp7qYV5tuaO/B843T4yFfxH9kJvzl6ekNNg== 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=W5t7Tfju5mavhj1U2HXUYuU2qDZoLSx3m7KYTy9MNpcG/N0QL3Q55vyoMJHuHiH1GTemT/NUCKBzw3rc2Y1LP7OHWaC1sfbmT50tWLsmV+CBK3ZAKgVPTlLjXw7P1Dm3X7k3Hv9EkcUJZf93+wFs8+kgAjo8FtBh9Asq1iG4jqk= Received: from SA0PR12MB4430.namprd12.prod.outlook.com (2603:10b6:806:70::20) by SN1PR12MB2448.namprd12.prod.outlook.com (2603:10b6:802:28::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Thu, 12 Aug 2021 06:31:25 +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.016; Thu, 12 Aug 2021 06:31:25 +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 v5 09/13] lib: test_hmm add ioctl to get zone device type Date: Thu, 12 Aug 2021 01:30:56 -0500 Message-Id: <20210812063100.31997-10-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210812063100.31997-1-alex.sierra@amd.com> References: <20210812063100.31997-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; Thu, 12 Aug 2021 06:31:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f273485-be94-4762-106f-08d95d5acf39 X-MS-TrafficTypeDiagnostic: SN1PR12MB2448: 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: /PbL72d9snV/S9kCgd1XEIgwHDVafD7+zf+IUQNDYm1czKMkgulr9/r5G7P7fA7ftRcdC30lOGpVmthUL3zQaGH4K3Cgmg1QYt+BLKfp5wdVaWozf42IP1ZC056x8yc8O+p9VZ/p/lq9x0lwJMPs27NYpQJN8mIRJb52Twz5+TuLgKd+EA556ePXJSdW/3w2514nz307CqiENlQ76NFiWWNhIJ5Br4fjiYu9sHuMUZMNFTtdFsyKZBms/9SZq6b+N+EYUBvITtLAQvS8PaeRsFkXTS8tJKs2Kuu/yG17hS6ILLir5xaFA6ktJi9PHUDSA0YjuO01cJ33sfbTmUWiv6yYqIdWcXtEGkUt9ebUmKe51ywatqmZP3fHGCQB4EDmPrO5OgyuHvwn9xUQeSenGuQkXxuVabUnKD0Xh2+JNTck8CMXmEh3P2zpfL70kJs65c1lO4mgCghAjlTE1f9Xyg2YoS8MG0Ros51cQDlOjlCWOOeBBfIyx+qOmy0Mk2yAZmzprXdAqNkblX3xcNYBlFpkcJvK98VgwVTfKr3gd+PRF1dduY/czuUI57CvBQu+L87vJXNcZnBbC+JdfG3zGm6ShVJjQ46Ijw6KKdsx3+BiYLldzWEjoTWAJ9LExwzT21alJerrQpVA5S6MSRQDfMCLd4k2S6ni84EldueFdFW6uzQ2aDRle1tuzq0GHlzL 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)(39860400002)(396003)(366004)(136003)(346002)(38350700002)(6666004)(186003)(66556008)(66946007)(2616005)(478600001)(83380400001)(38100700002)(8676002)(26005)(44832011)(2906002)(66476007)(956004)(52116002)(7416002)(1076003)(4326008)(86362001)(36756003)(6486002)(8936002)(5660300002)(316002)(7696005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J9vZEI2f/bSXkMt8lE3+xSx1n6w89cIXFPeXBzXrI90q1qBsqrSQ8QgczYnmebPmBYggX04oKlZWQE+8AOQGYQW5QnuyxGFaFEmYzb96mEquOQKip3h5rDrolvzCRJPOU35nmVRLICXJq9w4XWjeDYETBx2qu2EBM77uQKRbJNMVGXsSOzQ9mTGwp+hVMOm+DUC2lWeo3kp0vV4OscJG9MINhdfIk5rfIFAdM/czt+sF60u4Zs7DrT6jrGR0hnvmTwTt6SC9IRMrhtHIrWvodsV71XBuchORTP95RSpiYOAh3aTdePiwss+OFqYYYSkd4r+5B85UlQ2KVH1jqmIkh/obl5YJaq4GihnAW3OCD93CKoqjzIAAFlJwb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R12MB4430.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2021 06:31:25.5943 (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: 2nd1p0qoCZFgifYLU80V7+wD1yc3j6HOaHe0R6utkozNZfd55Ke6/v5yrZJ/BRU+Z2eNXlN9XwrR76VOmOHvgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2448 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=W5t7Tfju; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf27.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.223.63 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-Stat-Signature: mbe5jogntupm893fsyz6epcmd1xoup99 X-Rspamd-Queue-Id: 1236D7004E2B X-Rspamd-Server: rspam05 X-HE-Tag: 1628749886-424974 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 */