Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp302848lqp; Tue, 11 Jun 2024 05:18:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2rnQdsKyNEjTMJwIGarkaxaGMEk6d1heBRZ73Frq+ATzK9D43U/GaiAw2GxU6rKZml/8Y0nfrmtxVCi7hOWsqZ56M2wLUjOu0P+ILeA== X-Google-Smtp-Source: AGHT+IHn7oMtF/lfxCFBRjGzjaOx9Mtzw8EbqHvwtkh1apFbL/dQWs1KLItBajCgClGJ4Uv7q8Xj X-Received: by 2002:a50:9eef:0:b0:57a:3273:e648 with SMTP id 4fb4d7f45d1cf-57c508ffe2cmr8076316a12.18.1718108314457; Tue, 11 Jun 2024 05:18:34 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c810b6401si2257055a12.647.2024.06.11.05.18.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 05:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209843-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=mkxYghIO; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-209843-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209843-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6E53E1F21D0F for ; Tue, 11 Jun 2024 12:18:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEFC917C207; Tue, 11 Jun 2024 12:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="mkxYghIO" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED09817623D; Tue, 11 Jun 2024 12:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.67 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718108283; cv=fail; b=YwaL1yE+0jfKIRNvgrQm1FdhibmodFV/z4LofT3a3GtuBPp2vAWn1Wr29yShQ2ADwxhlhrc0C/1TqfGnrO3uV/yzC05KZsMDVekuPa0x6XJ6i3/pb4FZBZpLL02zNygPctE43PZbfzVb1cBk9gBzvZVyuIJz2F/mOnXU0xfSvik= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718108283; c=relaxed/simple; bh=v/63263NSBf/8wg9m59K0/ccB6xRDC44IhXywTdruWc=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=br2n+j+QuMAGIw+s3JOOXfOHAdTyTH36+jZz9rLgcBiJMQWaf/2vaRmA40+podb9zBlJxjpCm9zOlVn1ln7AgrmUeMCJBhk7qWaZuiwZvWQP0st4DcZydtj/xoSMra/nN+FM5k6ToJH8aGrIgByGD6HuM/FnDkhmZqUSwenTwUY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=mkxYghIO; arc=fail smtp.client-ip=40.107.94.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W8ZwVlxP1frSYbJqHEeolr+7yoeWvRGyBtU2wBx5hPEm6DFbTDYnoLmPtG9q+ukHS6mOFKz8yEQpVbxuOodqyjqum3ODYJlvLeX/QKHXlD+NjUzq+2gAJk5M0GiNZB3N6fRhNGfsfz3cYL03LcUOxrs0eZu7CZEZjfgKQNKlewtrR7z6VtIDSUSgdn5ncOu1HkBtHRYjazwSSWDGATkKHYC4WbqhNoWPZ6fj3vGYWi8S2AaXKekGUERmaQllIv4vuzxQ04A2UoEqVoum9vV6AuO0cTepN5Bip2o5wMoqIAr/RE3H1Zi9TA9i04UbGvbf+PXSQBgEL6c5ebE0FrzeNA== 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=2E5H23x40fxmDog6KH2x1and2Kh2vzQED6xjhx5qr0c=; b=nWFl8UJXjkhSu+TrPwAMrFms3N8R1uIHXIFI0PkwwIGoFwJo4ecqB6w91tYMorsMEG2WbiZZimeAJA0WSqdeZHxU7BkdLGRFb/V5kzn9dXtFfU2BXdB2e3IaoBEo/al/E1+dGNzdNieC6znH0EV+/31m/jb3T4oISP8Z7ay1FoXMieXCP0RinkOh+3oHBqqkeF0NCTOyunAXOPOBGMKjvyRWltnqN0mDmLD5zF1v9C2Eh3E5FiwJ3a4BqX7WF3RGqSFdw1fYHGrDECXnOxq94x3VRJBPqxX2zOrL0s1PPCxG1buVNE4MXVHKTdZqDvjN5mF7o+pP99IAAXLo2zOvTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none 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=2E5H23x40fxmDog6KH2x1and2Kh2vzQED6xjhx5qr0c=; b=mkxYghIOqI+HuqpGvoJXtr3PAIXyxanPdAepQZE3dWk5bC3jHxPE63I6RXXM8BeEWR1HDixjPQUjgIN/U/u4aVdvjGUcFA8oPojXkBofmDm6S0nI1/iAKcV4i5r5fp2cQOorTSAOGEHXWTaR3/BsB8ci6BOv+bqx+ORMw3ktdX4OJNPMYJQAmGI7BJjN4t5Un8VdrEUd0kZrtL5nMR3QO7AtuKQfYX+/0fpYTV0E3Egq/H7GCTNZ43l4Qbfsdei+G0yRAvDbd7xM2MhC35lTFGP7mx503knm+hjWGja+tyBp/shzXDyo2bB5GdHUX+4mIk6RK/Aa6ifERhzSRdO2kQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by SN7PR12MB7156.namprd12.prod.outlook.com (2603:10b6:806:2a7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Tue, 11 Jun 2024 12:17:58 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%4]) with mapi id 15.20.7633.036; Tue, 11 Jun 2024 12:17:58 +0000 Date: Tue, 11 Jun 2024 09:17:56 -0300 From: Jason Gunthorpe To: Nicolin Chen Cc: "Tian, Kevin" , "will@kernel.org" , "robin.murphy@arm.com" , "suravee.suthikulpanit@amd.com" , "joro@8bytes.org" , "linux-kernel@vger.kernel.org" , "iommu@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-tegra@vger.kernel.org" , "Liu, Yi L" , "eric.auger@redhat.com" , "vasant.hegde@amd.com" , "jon.grimm@amd.com" , "santosh.shukla@amd.com" , "Dhaval.Giani@amd.com" , "shameerali.kolothum.thodi@huawei.com" Subject: Re: [PATCH RFCv1 08/14] iommufd: Add IOMMU_VIOMMU_SET_DEV_ID ioctl Message-ID: <20240611121756.GT19897@nvidia.com> References: <20240607002707.GJ19897@nvidia.com> <20240607144917.GK19897@nvidia.com> <20240610120446.GP19897@nvidia.com> <20240610220110.GQ19897@nvidia.com> <20240611002839.GS19897@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL1PR13CA0072.namprd13.prod.outlook.com (2603:10b6:208:2b8::17) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|SN7PR12MB7156:EE_ X-MS-Office365-Filtering-Correlation-Id: 895f63c2-d6c0-4876-1958-08dc8a1087d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|366007|7416005|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xFecqQpVwBNr/YtdcFIPyB15X/yUe2RFjDChmQ5RFR/KgKV/Bj9jTbQpgq9E?= =?us-ascii?Q?9L18uDU6XV2n/iGE2Y7U1hOwrEoz+lzrAtmY5KdbvXV4u2yfjfmLgTXyntdZ?= =?us-ascii?Q?LeyDOTTQLxro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JBI8O?= =?us-ascii?Q?Dui44XXC4jUMsSxvr/2n/zGjgBlaJ+2InCHiAU6ot01rga6wuaMv2rvK9F71?= =?us-ascii?Q?HR6I02eHXOKCCpwPtrvEFr/rR+HyeJLpjthcn3kyQiSRGdjfTISxup7J6m8d?= =?us-ascii?Q?+5BlyAB1Rboh+wN0ntXy20/yD4d7Vs6ETkx2BUCZwTy2n+y93pIYwFwAmjCP?= =?us-ascii?Q?uQ3tH2+O/Hkdd82OaHhHXMcVGEzTnug6WGaXv8uzsW6F3m+zN0JsJjMgE6Uk?= =?us-ascii?Q?+6LT4AnpOsZcePI7sO/5RDCfbsJSouD+iMhLZzjQeIgTAq8q9XRhBEhknm8A?= =?us-ascii?Q?mgt/TN9zsT8MOyjXkZOHCiyD?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(7416005)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?A5u/+IQ9LcwYjfzSFifxumpscmkGRcZUo23YuPawIP6pGlQET9qI2CGm+oe6?= =?us-ascii?Q?/BT6KkWhyDhNmjCsrFwor++MLvzVyNFxr6s7k+Wzk6SBoXKklnbR3O3Yl2nv?= =?us-ascii?Q?Ypi8Ar0QwrOy7G0I9EjJbg1yMNAkpxCee702/+fjNzI0j6aMzHDowfIYaIdh?= =?us-ascii?Q?2VsTo/SP/xu+blwaV6Q5bYUs5H7orKxa5hT174mgjKkxR+qk6jvz9myWlv9i?= =?us-ascii?Q?4CoykPo8pOa0pEmCORXFXj0QptkE7HbCTtZZCR253al+YGpV9pWq1Y79H1Hp?= =?us-ascii?Q?hth7+I0033MzfK6rn34Xh8TG40N/96kTOxSqk8c1YHnIPwBXDTmLMVOEZ7k3?= =?us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ay/8k0lG+9?= =?us-ascii?Q?DJuiVjfxGcT4muK2AQC3qI9+W8jEqx7sjoRPA/0FL1+9luSWFY64vToKYm2z?= =?us-ascii?Q?3ftSELNewRso5gCybXYVYP16NRHWNVm/rhQ6s9b5IeHAshphQgdsvoDOhbKN?= =?us-ascii?Q?t2hSt0QrHhsnCkXMSHnyJ4PvaRSjbvkOnFu6QIj0CYGJZUNo8Q/96rK2QboG?= =?us-ascii?Q?iSKr8OOWf1ye1/qEravMv8zFRX0ZElxXoFrIe7jCQ53MADOSLUjKgcz4l6c5?= =?us-ascii?Q?7x5CAKNc6rXioO7gb72QCSQy0DuJlr5nUD1X6o3NNS3/SNyrnOBIaQtNtbIw?= =?us-ascii?Q?Nyfz/h9Qtk2CKTTJfJh0YzEf6fF1TyV/3x9BlWRI?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 895f63c2-d6c0-4876-1958-08dc8a1087d4 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 12:17:58.4193 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pfUqYGA1Ly6++3H/P6Axji1Xzy8z6lw1SlKsQUWBU4rDS38YaHS+llXbJOcDoqGm X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7156 On Mon, Jun 10, 2024 at 05:44:16PM -0700, Nicolin Chen wrote: > On Mon, Jun 10, 2024 at 09:28:39PM -0300, Jason Gunthorpe wrote: > > On Mon, Jun 10, 2024 at 04:04:30PM -0700, Nicolin Chen wrote: > > > > > > > Actually, even now as we put a dispatcher in VMM, VMM still does > > > > > decode the CD table to link ASID to s1_hwpt. Otherwise, it could > > > > > only broadcast a TLBI cmd to all pSMMUs. > > > > > > > > No, there should be no CD table decoding and no linking ASID to > > > > anything by the VMM. > > > > > > > > The ARM architecture is clean, the ASID can remain private to the VM, > > > > there is no reason for the VMM to understand it. > > > > > > But a guest-level TLBI command usually has only ASID available to > > > know which pSMMU to dispatch the command. Without an ASID lookup > > > table, how could VMM then dispatch a command to the corresponding > > > pSMMU? > > > > It can broadcast. The ARM architecture does not expect a N:1 mapping > > of SMMUs. This is why I think it is not such a good idea.. > > Hmm, I thought we had an agreed idea that we shouldn't broadcast > a TLBI (except global NH_ALL/VAA) for invalidation performance? I wouldn't say agree, there are just lots of different trade offs to be made here. You can reduce broadcast by parsing the CD table from the VMM. You can reduce broadcast with multiple vSMMUs. VMM needs to pick a design. I favour multiple vSMMUs. > CD table walkthrough would be always done only by VMM, while the > lookup table could be created/maintained by the kernel. I feel a > vasid table could make sense since we maintain the vdev_id table > in the kernel space too. I'm not convinced we should put such a micro optimization in the kernel. If the VMM cares about performance then split the vSMMU, otherwise lets just put all the mess in the VMM and give it the tools to manage the invalidation distribution. In the long run things like vCMDQ are going to force the choice to multi-smmu, which is why I don't see too much value with investing in optimizing the single vSMMU case. The optimization can be done later if someone does have a use case. Jason