Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3838540pxy; Tue, 4 May 2021 11:02:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWHGI+mfKrrFG96//DcPyuXOp/AkwWOYeqJiCkpGRVBHqfxJaAIf+RFEWK2ZXXSAqW8Tl7 X-Received: by 2002:a17:906:eb43:: with SMTP id mc3mr22712798ejb.78.1620151354802; Tue, 04 May 2021 11:02:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620151354; cv=pass; d=google.com; s=arc-20160816; b=bvyShE1Sy3Z5HY0GTYoq4luY77H6Ku6jgMHVi8OnuWUHrslzhgb4FF8k1+uqNQ3Glm jLT/Zh9hsSnSl1UgAMJDLFk5DEtTEQCl2xzoByIuK5RHDzmnXeV86Nzvo1jfwQdLoQu/ RC0Kw7Ajm7I59EfQeEhOchvUdY6kZHToEvVKEDNSpnvAsn4uc+pZ/utn2o7+wz1B4sJm 2IWnBBSPBg1uwm1bO9OilliikEe9PxDGmbzahhftZxHGp0r+HSsWSW0Z4u4gZpavC8Og c/mXFlnwq8revBZpElKNudNjnzmyhODycbkFZH5WIxjoIrlBvSBvEfq4H3o+MvWrcepR 1jfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tES7OamPG2yhB1EsQjtDi+wmW2DPq3IAhbWd332A87w=; b=T4wGaQFQZA4+v845l/Gvh7xeo06Zop8W9TL2Y/CXLoyFB+zNMEYiOqtjbBVWiceW+7 zKXiWAw6MtQ4tBkCebqkJ0X1EATqsTWP91t1Nl3QOgtmy4ZuXkgjOvbrgOsqz0gFZwb5 gsjqPsb90EzcIZLgZ/Z52YMD28ULooJa6FAs+zpG7jRsaYh8KEDy/Pu6zgQvQDWQB3po QDQhwUNon8x64EVoL2mQ4ZGTdTYcoZ0gZ+JSLFPq0S0A2a6pGFAFgaQsbxE8efbtV6C3 s8SmF77muTr+6nukYxcHyQzXpz/In8S+IyllKV1SWWwV7E2Lz4u4FaBi/7UBItViUYiR kCyg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=pCoR8Rpz; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si3618572eja.397.2021.05.04.11.02.08; Tue, 04 May 2021 11:02:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=pCoR8Rpz; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232049AbhEDSBt (ORCPT + 99 others); Tue, 4 May 2021 14:01:49 -0400 Received: from mail-mw2nam12on2083.outbound.protection.outlook.com ([40.107.244.83]:19585 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230285AbhEDSBs (ORCPT ); Tue, 4 May 2021 14:01:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hmNpu9UT0d4FQDwxy93P9PB/ZSUoSyR7DImgaLwa+Y4/NfdLyoyoMCkK2xNMYfQxHdBnBBS4FV9RGIg/zsI5JfNTVVy8BoQ4jGzcaAeXJzygdCQrE5yltZhrZPc3GKM+JJa/mZiR4pmG3FAZ5BCpeLpiRtHI7yjyBEvlLUV6IKNGOiKSzHqjTeRjxmgSYKxF1H9sS4GY6PlXjsTzufluZE5L6OAO3h9GyVcMuS+sVD9M8eqMWDLYfyvOVtUeZgHzjmWETNx7eAjC1tjWxgSU9uU19Pa5X9VqiMVAUCYE7qsQxSlFQDkuYUOZBygbpEiCEvYcdMCBKvIa65lmN25AcQ== 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=tES7OamPG2yhB1EsQjtDi+wmW2DPq3IAhbWd332A87w=; b=g5VKMtT46muXRiukkP235bFYGji9c8D0kFVSjAl6d+i5a/nY4AwstnEyVAjxNINrvNneKaBFuTWk/CUuFUJGyI3savG1IWGmIG8/WuBoKzE7z250rQMEg1L2Aq9qO3OvOuXwCDn9jPspm8pJyG8pagu1oy+Gc05zDz5kKVUL8Gj8REC9PdjRR61FrnIwmJZ19lOisrUyBfZbo3t9d7cN+Bs8xhyM8ZoVElkRyVwAEF3qJrFDUOpKEa/8lrMEEypg7m6YYYGnXgAKnghKU23As+oayj9SCCbAnikJIiIuGaStHIEHoYHRYolYo5dzkQGGkT6OyOxMnLNVzgSCE23nDA== 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=tES7OamPG2yhB1EsQjtDi+wmW2DPq3IAhbWd332A87w=; b=pCoR8RpzDIRFKAgAqVijxTfGIfVEEiXzE3iq5fP0oum8pe7jbZHPP7h8I41gXArpj8OozCYE8K4NyI19ZmfIORliZ0F60tM0zffvoqib2XXFhf77YspOEcfExLL6iZD+pKZm9k7FKw2PKRceVBbWKEvRfVqVRsGFOux21OFNG8RBUK3Uz9Z9U1mnN3I7TNpbGaGl/DHX90BIOwslNu5zyfTEyaoELCTpLMt5rkAo4NYWvjVfUSaIX3hGouMAGYgY4ORTyQcEsPOdekYzSi1RhryurLVEFqkZ6xsL6MH9O2jozpfilax6t9Pmrw2Wclc097fHWMbfay/rTzPTS1//5g== Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none;linux.intel.com; dmarc=none action=none header.from=nvidia.com; Received: from BY5PR12MB3827.namprd12.prod.outlook.com (2603:10b6:a03:1ab::16) by BY5PR12MB4067.namprd12.prod.outlook.com (2603:10b6:a03:212::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.26; Tue, 4 May 2021 18:00:52 +0000 Received: from BY5PR12MB3827.namprd12.prod.outlook.com ([fe80::81ef:d824:43ae:aef5]) by BY5PR12MB3827.namprd12.prod.outlook.com ([fe80::81ef:d824:43ae:aef5%4]) with mapi id 15.20.4087.044; Tue, 4 May 2021 18:00:52 +0000 Date: Tue, 4 May 2021 15:00:50 -0300 From: Jason Gunthorpe To: Jacob Pan Cc: "Tian, Kevin" , Alex Williamson , "Liu, Yi L" , Auger Eric , Jean-Philippe Brucker , LKML , Joerg Roedel , Lu Baolu , David Woodhouse , "iommu@lists.linux-foundation.org" , "cgroups@vger.kernel.org" , Tejun Heo , Li Zefan , Johannes Weiner , Jean-Philippe Brucker , Jonathan Corbet , "Raj, Ashok" , "Wu, Hao" , "Jiang, Dave" Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Message-ID: <20210504180050.GB1370958@nvidia.com> References: <20210421133312.15307c44@redhat.com> <20210421230301.GP1370958@nvidia.com> <20210422121020.GT1370958@nvidia.com> <20210423114944.GF1370958@nvidia.com> <20210426123817.GQ1370958@nvidia.com> <20210504084148.4f61d0b5@jacob-builder> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210504084148.4f61d0b5@jacob-builder> X-Originating-IP: [47.55.113.94] X-ClientProxiedBy: BLAPR03CA0090.namprd03.prod.outlook.com (2603:10b6:208:329::35) To BY5PR12MB3827.namprd12.prod.outlook.com (2603:10b6:a03:1ab::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (47.55.113.94) by BLAPR03CA0090.namprd03.prod.outlook.com (2603:10b6:208:329::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Tue, 4 May 2021 18:00:52 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1ldzLm-000XJA-HA; Tue, 04 May 2021 15:00:50 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0b3456b-1dd2-4322-d232-08d90f268e5a X-MS-TrafficTypeDiagnostic: BY5PR12MB4067: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5pGOoH6MvliesIB5f7UBBHXtZ1tyrUFS+FmO3RfDSypVMTwzBr6z7AvlEjMCZTxlvY6L3rtrhZxZjSEtSOVw7ja0UvfjW5yPCjpFFC5imZWEVuKaVXARQt2j7OQaCdKzIuQMKDKVn+wgqVQX+OFefneOjB/yz1LXgFdC1IcUdtoj+KUVGxa69cUWcXkp9hsWU1pkMaI54VCqMCaXgXeYzCfRR9iA65a4z7GBfLOZryiqEHriVlzQThc6+rPfgLq2GcpYZdSUzZWTdEHhu7H2qBuFABk5Uug0ZvmMiPzO/07uUBfCqYsQFjOLYpu19dunXP8sG4NXTKuunlfW1eVfgQui6xEyLyHbspSX3OAUaO8iCYwwXVk3vm+vWUMyp68E2k4B7cld+093YD6RgKjxZz37+oC2fmcvEoNiR0S7aJz4vMTFDJn7RTA49Xgaoq4dRhto0za/oE1YP1Pdfa9RT87LLFhwAyDJrB4QebjlxzrTFUW5SWjG5aX/RekxLPyzW9cmjSX+svSrDj/WcBNbfmGUGIH9JZJqmG0KJgo1OFuH+aREpqI5KelHVVlqixtzIc1fNtbAhZrcK5zS3ef4+04qSvNSupWKvmd4PTEqUPc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB3827.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(136003)(376002)(366004)(346002)(396003)(478600001)(26005)(4326008)(33656002)(1076003)(5660300002)(2906002)(9786002)(66946007)(66476007)(86362001)(36756003)(2616005)(186003)(8676002)(8936002)(83380400001)(6916009)(7416002)(9746002)(426003)(316002)(54906003)(38100700002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?iaY2CYjaLXDy5p9iIQURMD6Vsgr1M3WZhs3S7NjLgYufl/gLO8VTwGMvrvst?= =?us-ascii?Q?In9jNjOX8rBydBljNubQZWvVVRavZDdYxKOATIxlaixS1r/AiYbuZH8FT9zO?= =?us-ascii?Q?JHJsl7Ttl/ydMIcu4fkyhvVwqfZ9fguVz8Y3j60fN0OFWOA6A92MUWap0nMg?= =?us-ascii?Q?+Kc4WOm0tNXKQIeCvkfz3FehifjpYIHSHRDIIKm9tm4dhEF36EYCZ4S+aSpM?= =?us-ascii?Q?2Ud9n2YT7xiupCW8DF4P9puRs0VhED9XhIT+1tssHZE8K9RhuhysIyA8WuBi?= =?us-ascii?Q?KT0dNwBFrMS+p2kP6yEjjoPLeXiPZW6lGYi3Btw5M1sPt6p16503RmBR9vx+?= =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AaSnty1+3TZGfcnnME/ikcKemvJBmWfm?= =?us-ascii?Q?h/LXyXFdl8hOidqoTh9EyL13lO+Vcb74tkk1YdzYPTw53o5fY9ysJEKHOET0?= =?us-ascii?Q?U5ZucBzdfq2kaSlCZ1odxDNX?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0b3456b-1dd2-4322-d232-08d90f268e5a X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB3827.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 18:00:52.3744 (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: KWpAzv8dPFPy9NwXobWlQBST8JDIIAMZRS5lfcJvKL/3xElwOaRsA9BevUmasAt2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 04, 2021 at 08:41:48AM -0700, Jacob Pan wrote: > > > > > > (also looking at ioasid.c, why do we need such a thin and odd wrapper > > > around xarray?) > > > > > > > I'll leave it to Jean and Jacob. > Could you elaborate? I mean stuff like this: int ioasid_set_data(ioasid_t ioasid, void *data) { struct ioasid_data *ioasid_data; int ret = 0; spin_lock(&ioasid_allocator_lock); ioasid_data = xa_load(&active_allocator->xa, ioasid); if (ioasid_data) rcu_assign_pointer(ioasid_data->private, data); else ret = -ENOENT; spin_unlock(&ioasid_allocator_lock); /* * Wait for readers to stop accessing the old private data, so the * caller can free it. */ if (!ret) synchronize_rcu(); return ret; } EXPORT_SYMBOL_GPL(ioasid_set_data); It is a weird way to use xarray to have a structure which itself is just a wrapper around another RCU protected structure. Make the caller supply the ioasid_data memory, embedded in its own element, get rid of the void * and rely on XA_ZERO_ENTRY to hold allocated but not active entries. Make the synchronize_rcu() the caller responsiblity, and callers should really be able to use call_rcu() Jason