Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1157985lqs; Fri, 14 Jun 2024 18:28:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCNSgfhrO4wa8EWmlaAS4/zKGHFGx0GT7ZkPbkgX7uwbQPIY85s5uv3ZBt49RIZZ8nvN42iWl5tPkImsEeLYqXnZnlVX1MXAhMHAmevA== X-Google-Smtp-Source: AGHT+IGU/k1mfgF4tl+dweb3cGUSxJRfBPWWitoYt3g+UmqtyxF1mGXAIkZYQ4qH3hEzCuOEUNJi X-Received: by 2002:a17:906:398d:b0:a6f:4bc1:276d with SMTP id a640c23a62f3a-a6f60ced492mr245873266b.12.1718414922098; Fri, 14 Jun 2024 18:28:42 -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 a640c23a62f3a-a6f56e7d601si222971766b.931.2024.06.14.18.28.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 18:28:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215632-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=rVr2WWKJ; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-215632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215632-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 9F4391F226E0 for ; Sat, 15 Jun 2024 01:28:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D4ED748F; Sat, 15 Jun 2024 01:28:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="rVr2WWKJ" Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2070.outbound.protection.outlook.com [40.107.94.70]) (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 5E62F646; Sat, 15 Jun 2024 01:28:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.70 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718414906; cv=fail; b=KAl2sKYyehg10i5EtCLz5tqzf407MnJMWuW5mv4s+XBRKkNP5qWeuu8Yk57a83tRGfVKLK4BArtC7xF9fh3C4FGJ5nE7uaTwxdFcI9yHKiri+15CF3BeEykQL/n+kLcD0MJqNr4EnHFLQbdFPz70hFhe6m6fj8LELDevSOBhkZ8= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718414906; c=relaxed/simple; bh=NWW/aCaCWMWKQp1pLV4X8RbGYCw+aMO6gAIgyhDIyRY=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=GQvWsnfVblJkwTla4YJ3rM5+WzdU3AyXIrR02s+PaT/fU1NjNEMQjT1lqn4/wnoKonWB+SjH0B8x9KlV+8MT6Z7jTp07pKpe+AaBhDhQbCpzFtXpOTncCge6n7+veu/PV34HmRjgLGpAAdVbQCS5Pz8w027+oPVMJFRqt/oKbsM= 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=rVr2WWKJ; arc=fail smtp.client-ip=40.107.94.70 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=Eqq9eeaOVSx6Bqd0n3SrMSIlVN0NFqENrXqyFNkseALYZOjsa07tX7oMYAf6VztLy/16mZY2MxFN6Oangp28GJJwnA5r7C40OJAiqFWW3Wp+k8qemdziVwpOXAjjyObFt1GX3KAV5Xmc4kEoFPgmknzU0XJRRMpRZes5eMqQXiMwA9f91grALBzJDFOI3O0ahfB15xOyLiXOTc4Pjl7b1Rs702KaxAxETtaLNnY+N+XQ76oBrKK7+TBmauYyRQMDk5daAaL0XWi04g3xBIEHh2yg2fL6m/lBXjGRQy6rvn6C+o9blMGkEVf/apXRxPFd6Mkjpj40U9qV1BIfAVTOJA== 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=f2/rjzXXkpwBA6c6BnfO8fV8uGpWRE1kPpeoc687ayQ=; b=gsEp55naFHZn0PdmAmJdZlJ/YiXpFv7EK4m25RB9zcKo8+xUC51/osobBOV9+4ZMRC7E3fPSB10xL/bMzBMS9uATzlsgFm7JSUV6+5iFl3S1QrnGUPS69aE/3EE11A5lTEw7+M3ZrRcqMAixuX/+RA5eFqs9ClKlasVd7Ow154SWX1CEmVIo3mnwwW1vz9ud+JFfI5nlArXU+dDhwcxs5iPTCHeWooMNCtq016Hmvx85MCEAJ6ptuO7wOQBPrz+7VgbhxXI5Gehnx8vz0KDpJQYdyVY8u21bHnfKpBMPs0mO7+w2B5OoH5LPS8qv15tEUHQvfq7p6NE/Uan0RUKrAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=gmail.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=f2/rjzXXkpwBA6c6BnfO8fV8uGpWRE1kPpeoc687ayQ=; b=rVr2WWKJ1e7ogsI0y0+9VmEMkpJggje4zW571DonmrOvC3YBx8GSbJW38p6d4/A8n7m7j8IYur+NVYP/JlgmtvqHdkfW4yvrM1vzGyn4oqQtnWTgXz3RTH88Km0+ZiKShVSWDGkyGj0f47KYIXLAe4LBN4cmBf49sTZeCllHKG55bGm2Rwfjav9rxfZqgcWSvp4+T/bffiau1vbMf/wWuHm/5HJKDhDmKxYjmjZsurICHI0kVkvkdzLlCZfz0YEWUfUladXVGHoKPINOa03f6nkmJ/hipQ4EXRcaua8s6GLp+6/fb5UBBuhaFjI7EIe9jkBbtmnkRQGRpLIsQohM7w== Received: from PH7P221CA0029.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:32a::12) by DM4PR12MB6423.namprd12.prod.outlook.com (2603:10b6:8:bd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Sat, 15 Jun 2024 01:28:16 +0000 Received: from CY4PEPF0000EE33.namprd05.prod.outlook.com (2603:10b6:510:32a:cafe::f0) by PH7P221CA0029.outlook.office365.com (2603:10b6:510:32a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.26 via Frontend Transport; Sat, 15 Jun 2024 01:28:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EE33.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Sat, 15 Jun 2024 01:28:15 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 14 Jun 2024 18:28:02 -0700 Received: from [10.110.48.28] (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 14 Jun 2024 18:28:00 -0700 Message-ID: Date: Fri, 14 Jun 2024 18:28:00 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 2/2] rust: sync: Add atomic support To: Boqun Feng CC: Miguel Ojeda , Gary Guo , , , , , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , "Alice Ryhl" , Alan Stern , "Andrea Parri" , Will Deacon , Peter Zijlstra , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , "Akira Yokosawa" , Daniel Lustig , "Joel Fernandes" , Nathan Chancellor , Nick Desaulniers , , "Greg Kroah-Hartman" , , Mark Rutland , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H. Peter Anvin" , Catalin Marinas , , , , Trevor Gross , References: <20240612223025.1158537-1-boqun.feng@gmail.com> <20240612223025.1158537-3-boqun.feng@gmail.com> <20240613144432.77711a3a@eugeo> <79239550-dd6e-4738-acea-e7df50176487@nvidia.com> Content-Language: en-US From: John Hubbard In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE33:EE_|DM4PR12MB6423:EE_ X-MS-Office365-Filtering-Correlation-Id: 4eb900a9-a36c-451d-aa63-08dc8cda6e0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|36860700010|376011|7416011|1800799021|82310400023; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YU5hbDhvUEkwak1JS2hKSWxzNXdRVm9wa2tubzZ1djZ6VjIyZTBjL1ZZd2w2?= =?utf-8?B?bTNHZk5ENkpqa2wycElIVGhra2lkdzRmb2U2bk13T0E0eE5xMHRpRnFRSUhN?= =?utf-8?B?SnZmTVhXcFZkOS9XdGd2ajdrSkV0VTY5OUdKY1dKUFpRdEQzTWk3RlRYZjNu?= =?utf-8?B?WU1pK2EzenpCempuS1YrSjJSZTMxUUdnYnBOa3JCVHduWThocDJWcWZReU9T?= =?utf-8?B?UGZOcVI3cXZRUlF3cHpEQ2N2NGxxQnlDZUg1ZG5hUVVOMklYRGxtWnN1RHV0?= =?utf-8?B?QWIzL1NGdis4WE5mU25NNXZEeWpONnNWWjZWbERsc1RRK1h0QTQveFdQWDBW?= =?utf-8?B?clY0RXI2TVlZaHVPMTR4WHd2M0xsUzU4YmtFZUx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IxbzNlNUNJWmtodlBlZnFTTndOV0c5cnZFNkZScWhEcHN0WWw1?= =?utf-8?B?OFhQOE5aT3BSczkvcDFETnRreENvZHhtN1poU2pBWkMwWnN2THZwVTBNTS9W?= =?utf-8?B?d2ZWMDRLbGxwYWF5d2ZkS0RubjdYcGxsaWxlOGZ3S0NmWnlEcURlc1JvT2tW?= =?utf-8?B?WmY3dkJyL0p4OVQwaXRpejQ5NUsvYVhVdURsQU1LbEJqNnhaSzlpaU5sS3lE?= =?utf-8?B?WEN5blFhWUx0bWpzdTQ1bnRKa05tb2l6NXYvcnVQNDBWNEJ5Vys3RnMvZ3JJ?= =?utf-8?B?aW45bTVlZWdsUFJkZ3Q2ODlFVHMrQ3Z3bUswazFsNDRMUC9RdE5jSjYyNDdS?= =?utf-8?B?ZUkwQTJsRHhBVmI0Y1V4MEhDUXJBdTVHOFIwQkdJd2RxN2dvMVpBR2JocXRj?= =?utf-8?B?eTZIbTdLYlV2bTM0NlN2SUNwcWlDL1p6RmlERWVMV0lZV2U5SnEwTnA1NHNW?= =?utf-8?B?b0hvRjVkMFZHQzBJY3FzYVlXNFp5M3JmbVZMRjJpTXZJdVptdVhxV3JGam8y?= =?utf-8?B?cWFGNDdNN0pZTTFPbGJJUnN4bDdtbVNqYkJMTDROcGlzS09CV05SK2J0bWxi?= =?utf-8?B?VVl6QWJkSlFTVGdZYXJkVjBKRjAzMnM4ck5XR3lKVDN2YlE9PQ==?= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230037)(36860700010)(376011)(7416011)(1800799021)(82310400023);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2024 01:28:15.5600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4eb900a9-a36c-451d-aa63-08dc8cda6e0c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE33.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6423 On 6/14/24 6:24 PM, Boqun Feng wrote: > On Fri, Jun 14, 2024 at 06:03:37PM -0700, John Hubbard wrote: >> On 6/14/24 2:59 AM, Miguel Ojeda wrote: >>> On Thu, Jun 13, 2024 at 9:05 PM Boqun Feng wrote: >>>> >>>> Does this make sense? >>> >>> Implementation-wise, if you think it is simpler or more clear/elegant >>> to have the extra lower level layer, then that sounds fine. >>> >>> However, I was mainly talking about what we would eventually expose to >>> users, i.e. do we want to provide `Atomic` to begin with? If yes, >>> then we could make the lower layer private already. >>> >>> We can defer that extra layer/work if needed even if we go for >>> `Atomic`, but it would be nice to understand if we have consensus >>> for an eventual user-facing API, or if someone has any other opinion >>> or concerns on one vs. the other. >> >> Well, here's one: >> >> The reason that we have things like atomic64_read() in the C code is >> because C doesn't have generics. >> >> In Rust, we should simply move directly to Atomic, as there are, >> after all, associated benefits. And it's very easy to see the connection > > What are the associated benefits you are referring to? Rust std doesn't > use Atomic, that somewhat proves that we don't need it. Just the stock things that a generic provides: less duplicated code, automatic support for future types (although here it's really just integer types we care about of course). thanks, -- John Hubbard NVIDIA