From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A6F4C021B2 for ; Thu, 20 Feb 2025 21:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:CC:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vkqVTrjN7uBVQcVWCYTofvUUoNS8+3Nl4/ATU1ESurg=; b=uYPKSlHkhK2gXXkDW7o2a+eh+7 sHQz5Lo1AwqB5H95ITXMd3Ehhd70kL5xwsn4aB6SGnSBSy1XXsulYcaePScRU4/j2ORcIIgjv4jjo riwK2ltUhLMmvA4Ov1ubTEtWac89ZLlrQen+ORXhgth+x9UZVi25pxPhkCJ1EOUxM+LjxgshuVdxa I7TEjYCgFl1yEuwahTeT/WLwU6wO0B68ANfRjnoc/MyTjudgFo7bpHX8u2kgqQJoEJ7xHgeAFB4F7 hSfc+c5i5Wk0gLqST26HnB1Hd/U3FKcfASdp4sCaNBTYggVPv7Xq9Tu8madSYBXO1hBBpZe/TGyBN 7o8Lqb7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tlDwD-00000002vbx-4C2P; Thu, 20 Feb 2025 21:18:30 +0000 Received: from mail-mw2nam12on20606.outbound.protection.outlook.com ([2a01:111:f403:200a::606] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tlDuh-00000002vDx-3gbl for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2025 21:16:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T1JN86LcWdMLkDqXXcFSE7cDYQ/2S0Y5k8DNtihOuXyBpObQkGkQefLynWf939g+T2B5bN/XWtHnDhcKlGE5TJUcNGsFWGGgEmK7elMO/rJbfhhiFT8R2NFgVnw+BRxn7M/A4gMG+h02qkp+RhQ7SL4T675qLyiuv1McozkkiEFbLUxZftAm6b88tyRYdkVXAZE1LZGCFu6218PpDsdq49LLEPTt/26j2kBDDToe2bBwmn4uO3gIrHxUO8WS1Nwg2FYJZtDmaeNQlx47xsUreLhyI14NgPeWUT5jVUDdWXO9aC0PxBuvrVn0akonM56kD0DV62o9s6j/zQ2WdSERfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=vkqVTrjN7uBVQcVWCYTofvUUoNS8+3Nl4/ATU1ESurg=; b=Cxz+556b4MFMxClJ5/qjxYnW0DFbNOYoN455bFFnUg741wAefNOLpBf+H1g7Zw4Fr92PCQ1H2oqt8lE9FF9Xas0XZna556WJV2ezFF8O49YVZ8YQEDIMJx07ySPa0PPQvAV0JJ152GQtrJAt6mGyhGBtlgEh3uPeaktY0sTJ/5IhRofRkSZM2jpe6JShEO2UaR+xosMkjCEVMQO5bcA5a3kYWzT2betoFo0XBtL+4TOfXU3/uj61GtLuLKy5D5bn6lyD7mLJ1A4wJ4bthefZBWezD80kCLUq0aeeJ/AkSpD7GlwuAAKI5MNBCurPzvHgu1mBZ+M2iSTA7LGESvGoOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vkqVTrjN7uBVQcVWCYTofvUUoNS8+3Nl4/ATU1ESurg=; b=GbNKrurBr/zzYriMknQPcGT8CEQHhYqSKn7Ica74p8lSJMZdqMpETphEycjlN53SSjPUY+WpN0yu8PJfy53GaZ8lhcqmmM9R+vbqZbjBoMZqi6lPaVphWwUSEHXhNDiBkUfd8zTdouYeudFpZtBzTLq/D/kTfGsyDdMFawnxbijjRryLUHvAn70yHpdLnA+kQrui6oeIiF6377ZiqEtoHk8zB+jAgu12FdWNUnPSyRLoOTALFIvf/a9KQ/Lr4CWuVXB4inpIb4XzQwewou3eOvJm0ISjWl6oqiEEvW0oXEH+X5NbWs5UrDlQ03d/izKflolYi71ntW6Kijt0ACRRJQ== Received: from DM6PR17CA0009.namprd17.prod.outlook.com (2603:10b6:5:1b3::22) by PH8PR12MB7445.namprd12.prod.outlook.com (2603:10b6:510:217::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.19; Thu, 20 Feb 2025 21:16:44 +0000 Received: from DS1PEPF00017098.namprd05.prod.outlook.com (2603:10b6:5:1b3:cafe::9b) by DM6PR17CA0009.outlook.office365.com (2603:10b6:5:1b3::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8466.14 via Frontend Transport; Thu, 20 Feb 2025 21:16:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS1PEPF00017098.mail.protection.outlook.com (10.167.18.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8466.11 via Frontend Transport; Thu, 20 Feb 2025 21:16:43 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 20 Feb 2025 13:16:28 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Thu, 20 Feb 2025 13:16:28 -0800 Received: from Asurada-Nvidia (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14 via Frontend Transport; Thu, 20 Feb 2025 13:16:27 -0800 Date: Thu, 20 Feb 2025 13:16:26 -0800 From: Nicolin Chen To: Jason Gunthorpe , "Tian, Kevin" CC: "corbet@lwn.net" , "will@kernel.org" , "joro@8bytes.org" , "suravee.suthikulpanit@amd.com" , "robin.murphy@arm.com" , "dwmw2@infradead.org" , "baolu.lu@linux.intel.com" , "shuah@kernel.org" , "linux-kernel@vger.kernel.org" , "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-kselftest@vger.kernel.org" , "linux-doc@vger.kernel.org" , "eric.auger@redhat.com" , "jean-philippe@linaro.org" , "mdf@kernel.org" , "mshavit@google.com" , "shameerali.kolothum.thodi@huawei.com" , "smostafa@google.com" , "ddutile@redhat.com" , "Liu, Yi L" , "patches@lists.linux.dev" Subject: Re: [PATCH v6 07/14] iommufd/viommu: Add iommufd_viommu_report_event helper Message-ID: References: <3d952137a7935608f9cc6b05bd561a58a0c5da16.1737754129.git.nicolinc@nvidia.com> <20250218153541.GD4099685@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-NV-OnPremToCloud: AnonymousSubmission X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017098:EE_|PH8PR12MB7445:EE_ X-MS-Office365-Filtering-Correlation-Id: a285de5f-d756-4518-8513-08dd51f3e055 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ez+Ie99B+KPppWu/JMauspeHInXEWCfKaO0BGf8ADSihLCnZntxLLS91KfYS?= =?us-ascii?Q?Lc53HopzP10a720FhP6RlclTyBS6/9vwKRl9oqeuAt2sWe0fit+ALEgYZepN?= =?us-ascii?Q?5X1EiZFwR5zsukXrkKqEFFAPhubwFGdf95wuCs9E8Z75V+6sY0MVV233m9Ng?= =?us-ascii?Q?9MaJ0GymBvSaXou7p+8nYEs2rPyv3vLOUqEvYYCPEDE6WHRCxXl7Ffvu3eYC?= =?us-ascii?Q?0+ll645jnA6T/teNQc22Em1H74ZWW/MT8FE3DSM/xnh7Zez7rLHU7/sPiIMc?= =?us-ascii?Q?3PSQHEQEEO4UrQN5V2PAV6gcIahyQ0YyNDPAEP2Wf+dSnrabX92TuVw2M5sy?= =?us-ascii?Q?UWwxKV+mwEQlHunATvLldve8sQ6/GSPb4sssZnlvqDw8m9/rOCJ2CSZRlf0z?= =?us-ascii?Q?XHEzj4ZYmC42IvVCeKG0oZ46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= =?us-ascii?Q?wnOEtG0zTDf8tvkrid5PdJiYUe/PDk29MP9ycgrfkHiolekiRBB1XScVtIIM?= =?us-ascii?Q?teLWD3a+jDxESYermvbrXAQVpiTyCUoIA9ddN0nsFgWeE6ecq8oLZHkpqnmh?= =?us-ascii?Q?7XdHL1yYPVqqNJnmUsD+8sONYQuibVHjgnLhZfpFz73EycqwZnOOQjRiYzgo?= =?us-ascii?Q?V4A0tmQZFoHTbdY=3D?= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2025 21:16:43.7675 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a285de5f-d756-4518-8513-08dd51f3e055 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017098.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7445 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250220_131655_917110_8DE7DC54 X-CRM114-Status: GOOD ( 16.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Feb 19, 2025 at 06:58:16AM +0000, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Tuesday, February 18, 2025 11:36 PM > > > > On Fri, Jan 24, 2025 at 04:30:36PM -0800, Nicolin Chen wrote: > > > +int iommufd_viommu_report_event(struct iommufd_viommu *viommu, > > > + enum iommu_veventq_type type, void > > *event_data, > > > + size_t data_len) > > > +{ > > > + struct iommufd_veventq *veventq; > > > + struct iommufd_vevent *vevent; > > > + int rc = 0; > > > + > > > + if (WARN_ON_ONCE(!data_len || !event_data)) > > > + return -EINVAL; > > > + > > > + down_read(&viommu->veventqs_rwsem); > > > + > > > + veventq = iommufd_viommu_find_veventq(viommu, type); > > > + if (!veventq) { > > > + rc = -EOPNOTSUPP; > > > + goto out_unlock_veventqs; > > > + } > > > + > > > + if (atomic_read(&veventq->num_events) == veventq->depth) { > > > + vevent = &veventq->overflow; > > > + goto out_set_header; > > > + } > > > + > > > + vevent = kmalloc(struct_size(vevent, event_data, data_len), > > GFP_KERNEL); > > > + if (!vevent) { > > > + rc = -ENOMEM; > > > + goto out_unlock_veventqs; > > > > This should record an overflow too > > > > In that case probably we want to rename 'overflow' to 'lost_event' > which counts lost events for whatever reasons (overflow, oom, etc.) Naming-wise, I think it may sound better to call the overflow node just an 'exception' that concludes with lost eventsfor different reasons. A complication is that this 'exception' would give userspace a very implicit reason as the node just report the number of lost events v.s. providing the reason to each lost event. With this, maybe the IOMMU_VEVENTQ_FLAG_OVERFLOW in the uAPI should be just IOMMU_VEVENTQ_FLAG_EXCEPTION? Any better idea? Thanks Nicolin