Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8858849rwl; Sat, 31 Dec 2022 13:34:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXtzjclQk3GBdXgReh2VcexzN5i3ka9LvjgekHqcMJR2K1W0rpz+sYb99ZpG1XIg0bamavY3 X-Received: by 2002:a17:907:1710:b0:7c0:c36d:f5df with SMTP id le16-20020a170907171000b007c0c36df5dfmr38814762ejc.70.1672522449073; Sat, 31 Dec 2022 13:34:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672522449; cv=pass; d=google.com; s=arc-20160816; b=IBGsSYU1Rh0bRyF6trmkv93aPYjl9/2xVH47JWNhPLyctdTOat+V95UxDyJ4KUpR9t ARYBcJ7OnefUSLlUJ7dTjS8VdhHxOZm4Snn+XUdJoV3DjaJD56z/hHThKlHHtOCDcWoE zUpgPRc2ePFQPrpfcH9oJFbQ+E0iM9GU1sN0RPjxi7nsckUDmMgdHY8fkkwYYe+7ghCP hfDj07cUrFGm6SN/HOdRoe24RKyOkasic1i5uVllF3CePXlqwP6FTrq+KY1zokabvxXi K7IlpEBsPns2ZgJBf24EF0Ke/j6r4Cpj/4XuHN7pfVBXhWYiFjcA5MItsWu5GTXH2HOT KDjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=c8YGLgYdqnGY0K0WsQj9r7RhrnVjZRcRSJczOSS7Eq4=; b=bBszDnUJbRl1jq8vVOexpsJCRBxrexZTTBvB8rYwbYnUtPSAVJUYXdAPP8WugTuXRk mqrNxAD0bgw/zrI3yKVgB/sPh2niyxnpnu2HnqJSh2bFN4TTBOYbTxcAlsHkT9meGBCv LmMSpmh+63aCbtj4hDT2PkqzVPR5dpZ28yk6pnm1tf7SuGNO3XvCxzelQYDB2/SXSq2o DXp04iuS/J1ZkAJCF29TJ90+dFtoPtzcoodgCyNbajoOvsMCR4pWGlXWhhXmpza+wlHh FS7PXNm4MeWRbS+Jz51l3ma/WhadgAYZSWYYTHMYiz913T+N64Z2rHcETNZuN0ulgwCn L/uw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b="iiiY/Dif"; arc=pass (i=1 spf=pass spfdomain=garyguo.net dkim=pass dkdomain=garyguo.net dmarc=pass fromdomain=garyguo.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs6-20020a1709072d0600b007cebad0e757si22478328ejc.194.2022.12.31.13.33.54; Sat, 31 Dec 2022 13:34:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b="iiiY/Dif"; arc=pass (i=1 spf=pass spfdomain=garyguo.net dkim=pass dkdomain=garyguo.net dmarc=pass fromdomain=garyguo.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232131AbiLaTzO (ORCPT + 61 others); Sat, 31 Dec 2022 14:55:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbiLaTzM (ORCPT ); Sat, 31 Dec 2022 14:55:12 -0500 Received: from GBR01-CWL-obe.outbound.protection.outlook.com (mail-cwlgbr01on2106.outbound.protection.outlook.com [40.107.11.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A41165DF; Sat, 31 Dec 2022 11:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=djCXOl5skfXuyHVEuI70sjTwSfLqo33R87d381Ir6swO/eO9Iwe+HVlTKhN7cLl6iFCwa0tYpNXZlTo++IynWYoCHWiqLzJSaYIfWqOEoGvXaE/T7R96sLpwpJCixqSGfHkXupeAc6D9iSKyBnaxYplZH5lS+IjmG664mh9PzUaV3yLj00KqJsNEgmPr3vVJuJ9xsIjmQHeLkc+Cn80Hk82L8IwUI8Za1xwEf7AnKpAF55o/nDDaWgwHYcr9bWxyJj9t4jtISRiDa+udBXSmXJJfsoiD6uUcYyyzcok5FJHF7LW2/vNYoEDcToCtwAQxLn8ryHtsiwnEM/l/RdwUfA== 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=c8YGLgYdqnGY0K0WsQj9r7RhrnVjZRcRSJczOSS7Eq4=; b=XoneJ3mj4kWvh672foIvqyA4fJERXheQwRkAf3Ytr7r9kaM3ocPnZyIAXuXTI0GSikd0grkgB6KyZIqgTE4Wk6PzP2cLLFjO5bYxPHrDx4H4BMbw7jkZ6nP6ChBAgmy3ns/azYFGcC0vpFREc//CuszxjKun+xEllp1odbXOf1RFgqgZi2SAtV76643TH+5TVESD7TGNBwh+aV+sxglzwzz4+pp00oPUjbX0Wzb/SX+/fAre2j/2Pgwoo3AgNppXTasXL/N/S27kSlpXue2PwWRSzh8XrUQ4SzkaNSfkyeeWaihQb/nu7HxkA4WuQ8b77sVAqbSJkLpY+6A12OpFHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c8YGLgYdqnGY0K0WsQj9r7RhrnVjZRcRSJczOSS7Eq4=; b=iiiY/DifjGqZG8PtFWTITfk9dL0LyJnmVzuXkh+OA7Hub9hPlWoWJzvMBWbhdNyMNiUJhKWtw4dQVATJc7m4uGoVq1OTvh/6lJ85wbG/SdHLINj5lzOfYlhhlAzmYYx4+3z4aP0+ucvdcjr5oDRFw1CsUtD9rIHOUm1pcBMc1aA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) by LOYP265MB2096.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:117::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.18; Sat, 31 Dec 2022 19:55:09 +0000 Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::2f24:8099:5588:8ba8]) by LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::2f24:8099:5588:8ba8%8]) with mapi id 15.20.5944.018; Sat, 31 Dec 2022 19:55:09 +0000 Date: Sat, 31 Dec 2022 19:55:08 +0000 From: Gary Guo To: Wedson Almeida Filho Cc: rust-for-linux@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Boqun Feng , =?UTF-8?B?QmrDtnJu?= Roy Baron , linux-kernel@vger.kernel.org, Will Deacon , Peter Zijlstra , Mark Rutland Subject: Re: [PATCH 1/7] rust: sync: add `Arc` for ref-counted allocations Message-ID: <20221231195508.7783a774.gary@garyguo.net> In-Reply-To: <20221228060346.352362-1-wedsonaf@gmail.com> References: <20221228060346.352362-1-wedsonaf@gmail.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0343.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18d::6) To LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LO2P265MB5183:EE_|LOYP265MB2096:EE_ X-MS-Office365-Filtering-Correlation-Id: e4ea7cba-8f15-4346-3a4e-08daeb68ebd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: unsr72jI2kgUvmocqMKkSgqADT2d5rMmdBdoZ1uasOi64Zb+Md5SVspiFc+zlll71Yya58hG9KDu0fnDtwbT857MnKY3F/UHDhZ/V9KlrVU55VGxPvAf8m2EdJAxOnytySVZ4Pu6rEWtzS8upBbHsy2m6RYvkPduOwq5+7Zi3h/soU4ej5+3uISIrqEBAMgi4Yx7uRWnPAzlkaevphyVug0/tdxsX0jmUs+d0BBytOkfqqTIU78v14A13YayDUowEoLB8b87RJeDmTbTd2+hv4w/7hB4xV/I4l1XbsEOHWJADOV5zm7CG7kJYiYcLvruNDK4HNYXDYILmtYI73Ka3Y7iwC1DWYxmMs6XnzsT2JdR2BxmiMrNRZhMLL8jM2blSnTEEOK4WEB+x4oV8tJuW15qAWA/Muh6iaxo0+3ThGVFYyz7LxA9bbJxNPLpTuC6q1u+PUsbCNI37nZFsOti77tbylVvF22BnRk4NoaNX2m1gq6e6pA/5Lt0voQa5/7CgLuf3rwhZeI/4AP5mfNKwLq3mKxTKq7kPNZgjl2o2vWMHGsFMs75DpkoTIe+27XhE8qmChYRqjSNPp4X48OZQJ5XTzU6eDNMUrGEawtvZB2B4yx+JJNPnMPe09AHBbACcKHsD6tZbPya32t9uVOtF463032YBgiKlzip+lYBmCXxEkL/OFTsVMeAh2VS3tIe X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(136003)(396003)(366004)(39830400003)(346002)(376002)(451199015)(2616005)(54906003)(6916009)(478600001)(316002)(36756003)(86362001)(38100700002)(26005)(1076003)(186003)(6512007)(6506007)(55236004)(4744005)(7416002)(2906002)(5660300002)(6486002)(41300700001)(66476007)(66556008)(8676002)(4326008)(8936002)(66946007)(81973001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Vxa4fWq2cZumHsa7oRR0p3eB4F+I0naGx2NI4keIQ3aI7ckkHexSTtPVWnwe?= =?us-ascii?Q?QlmADWe62M7WfvN6SLYYhjlK+wSyuo7ipPMPhXyI9dxxfe3TlXa1GDq90u9G?= =?us-ascii?Q?gEhyOcgLD2NZL+bDzNBvZpJuAxW2Wc3JtOhs7ju+KXblRT5t4k8o4wil8qxs?= =?us-ascii?Q?VPPwdT3lVNwl8uyiRvXzkXpP1/XsupPu/VWA5klOmnfR4M2H+9C+sdGNknit?= =?us-ascii?Q?pI4ti8KEfBBb9s6Dh7x0xhAfP9hugJLYquxj5iec7xn2cHRUQ9Eq3Hmwe0Mu?= =?us-ascii?Q?zI3HYzGe86ht1pMs5WNiKYHAihkOpyAo3/iaJYHIdBU+dTBVshO9lmWTglN7?= =?us-ascii?Q?+cFdl1a3aQctKFpw+uuBBMUTDYxvTmpKk6HzAU8hNCebKocIlIlQodoPdNjG?= =?us-ascii?Q?mZd8sdHPzJYOKz8pir5+jPjg10tXoJJprfG8F0xirb2lvLkYpffGYp7ybqr7?= =?us-ascii?Q?YthleJuuyzaHr40fjfbAPmPJRpOQa3g2BhU9Y9Ud49AkezPLxs6ccTNLVB5X?= =?us-ascii?Q?wPtqfYdNDxX0KhVeJi9Tyn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= =?us-ascii?Q?31MPP/GuX5fCTxvuoXR4wrTuSkiuVy28CNBoRHXlE/ODqOuN79XdOGApaZUL?= =?us-ascii?Q?CTJg8viNRJekOStn+WuCxCRpV5uFuRDD6w7Ing7eXIb1rlHs9JEC9uyshL8z?= =?us-ascii?Q?YdSW0YxcQHVqkbOy9tI=3D?= X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: e4ea7cba-8f15-4346-3a4e-08daeb68ebd7 X-MS-Exchange-CrossTenant-AuthSource: LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Dec 2022 19:55:09.3473 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jHuURqk9XXeS2NJYgq8kbbeekx62SR8NMKcbyzyBuKC5e9HVmdc79i1+0dDu4f4M4O1iKoJjdt6Ck36Rnz2SKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LOYP265MB2096 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Dec 2022 06:03:40 +0000 Wedson Almeida Filho wrote: > This is a basic implementation of `Arc` backed by C's `refcount_t`. It > allows Rust code to idiomatically allocate memory that is ref-counted. > > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Mark Rutland > Signed-off-by: Wedson Almeida Filho Reviewed-by: Gary Guo > --- > rust/bindings/bindings_helper.h | 1 + > rust/bindings/lib.rs | 1 + > rust/helpers.c | 19 ++++ > rust/kernel/lib.rs | 1 + > rust/kernel/sync.rs | 10 ++ > rust/kernel/sync/arc.rs | 157 ++++++++++++++++++++++++++++++++ > 6 files changed, 189 insertions(+) > create mode 100644 rust/kernel/sync.rs > create mode 100644 rust/kernel/sync/arc.rs