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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3183C64EC4 for ; Tue, 7 Feb 2023 19:04:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232641AbjBGTEa (ORCPT ); Tue, 7 Feb 2023 14:04:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231691AbjBGTEZ (ORCPT ); Tue, 7 Feb 2023 14:04:25 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2088.outbound.protection.outlook.com [40.107.96.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A48140BD9; Tue, 7 Feb 2023 11:03:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HvqdQ41IfvE6nnHAkpl1NrCl+sdeDWxDuwdOq/xGlhgxKfQPJs46rk0klFfpE5kUNg1UWo7dsTrG5G7LdBzskOqdhZ4NPyOeiaZTqhpKh/1Lj327p+NyjSSnvHe0HJlXAugZ2lSYVlitG7BdKRBDJ+0qjxTi7+pZfIJucq20+ZCxAwrq/bjyl0TsloJvdBiCeqS0O/VLcmqI4Hygbm4lOrXdTUjDUo9nDfk4mfpwCBvaOYiLuk8311k77qt91Wfw7OzzYHJ29Y8usNDcPIjlzjPVO87yxYza3R0zBF1N2w8AuggyDnECRVtUJgXOg8pMsLNL9B8nEuVbkj8+hhSevw== 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=wOjNC2VMFH/sKiBmdQAjNiih5ZU2+vwg9Ght1+ALMjk=; b=IWNTosYPQf3dL9l5kiBv+UBxismYJEb5rUmeD0K0P0PsGR+qAbsuD465X4DNTyTI5OIUszMYzKbflCFSCeIEr2ArXm2BlDYknqhu1YvBIIg/dV4TbroDrZWnkBoNGZ+20s7uR7NdiTmf/8vNJdamw3a17mKLwp8y9qBnQejWHhc+KcvOjDaPBI3Tsdk9fJ6EuoQvKxEgjo5UcArgHkxfcjAPMUUYkQY4rb6zNcP487UyAdJhCu8JqX1M47nJ/HNaRF2NYJBo3TuQNGPnBnrS7V5dEAkEO8D0a2xacftCTgoOFEKrJOfFN/MLCwYFITUabo4h0rQhktpakz9IevBTKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wOjNC2VMFH/sKiBmdQAjNiih5ZU2+vwg9Ght1+ALMjk=; b=tdlyhMl/yvTxFErEY8WDAqX4nWbj2JqR/+aQm1M/foRXaMgnHI6fRum2+EYRMFyFqfMlu2y8bk61WQNfo2szbyvbzHfP3/vv8TR32/pIb5nqr2JBohvZAaWwqFWCzki40f+PYTsAqWoWdF8oQGor1o+hq/E/3+61fZyGGoMOIEc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BL1PR12MB5874.namprd12.prod.outlook.com (2603:10b6:208:396::17) by IA0PR12MB8325.namprd12.prod.outlook.com (2603:10b6:208:407::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Tue, 7 Feb 2023 19:03:55 +0000 Received: from BL1PR12MB5874.namprd12.prod.outlook.com ([fe80::f29:b74e:c400:b24]) by BL1PR12MB5874.namprd12.prod.outlook.com ([fe80::f29:b74e:c400:b24%5]) with mapi id 15.20.6064.032; Tue, 7 Feb 2023 19:03:55 +0000 Message-ID: <718cd090-1a0b-d485-c595-f14ea1d41d9d@amd.com> Date: Tue, 7 Feb 2023 13:03:52 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc Content-Language: en-US To: Boqun Feng , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?UTF-8?Q?Bj=c3=b6rn_Roy_Baron?= , Vincenzo Palazzo , Will Deacon , Peter Zijlstra , Mark Rutland , Greg Kroah-Hartman , =?UTF-8?Q?Sergio_Gonz=c3=a1lez_Collado?= , Finn Behrens References: <20230207185216.1314638-1-boqun.feng@gmail.com> <20230207185216.1314638-2-boqun.feng@gmail.com> From: Carlos Bilbao In-Reply-To: <20230207185216.1314638-2-boqun.feng@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH2PR20CA0017.namprd20.prod.outlook.com (2603:10b6:610:58::27) To BL1PR12MB5874.namprd12.prod.outlook.com (2603:10b6:208:396::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL1PR12MB5874:EE_|IA0PR12MB8325:EE_ X-MS-Office365-Filtering-Correlation-Id: 347054fc-a8fc-4e97-14a3-08db093e0f78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JxR1epuz/KDZCrSWujPMGl/5uo9QIMwu0QfzCzR0O866RF+GmUGkY5unNxlss96TdrsuIg3scNjY/syK1R63bEKDuQNIzT2AchrSd2D6BadKggMwAAfOuxVB77dGUY3KsY9TQqkZliv1TH+ATwMagQWGR0sXmBl6odP8KMJkxYxUhZ1QKGvF/SXn4vgo4J01uqbeS8aGe2CYMHQdcEdbEVgsZ67w/S6GcKhs5pHLDl6lV8PEi9Wj3VQjOgINOkX+oi5b2tjWfk0rYJxPbJHVDi3qcUiN7boh9j4AtffRgy9hXSsKMh3GHxSYf3U71X3J7BF4Ai2/oSJ9LDtOOZS0urbKuT9j/b/JeWpcau+R+hqnbhp1+CZdgix7IhWwby2hG/ep8k7eRizXnd3XwkwNPNrOw+VdGra05bHjWBHQujHwtQPJx0BKeSjirPM3CXyxCxxy10+wnq+pPvwhAN29nyGZ01nseqZ2FCNPhBWPbPGUzwV895KqcD7BmjPsmlj2pxr+SdU8rWWQh8IIylPHbSPae1dqscnUeYgq8o+7LIw8sSj4F8PMwZWJiDcv/wUUCL5gp2vZAkfXyc08kEbC7oL8ORpZ6kz/n6fC8qHFPa/7kMSz4WaRAKcdlbn/RWO4SujiY1KACg6zRRsfqLcBbJTyW2Hvecsqqem35AqQgc+AZPYmbJwMlPdxfJeWutL6qxstm5ZSAjZvzWX6UIcCi9SKg6xBqVesBtTNwNZEBhLKCgzTKbRBGkaJV0OTUbODOHgVEQN2BdQ6vhTcHumNZQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR12MB5874.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(31686004)(54906003)(66556008)(4326008)(7416002)(5660300002)(316002)(66476007)(8936002)(41300700001)(66946007)(8676002)(86362001)(31696002)(36756003)(38100700002)(186003)(6512007)(53546011)(6666004)(6506007)(26005)(44832011)(6486002)(2906002)(478600001)(2616005)(222643001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange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TBwblEwRXNQcjRKSThyQVlFUUhMS2tkUU5KSnNqYldaR0dUdW1vV2o3?= =?utf-8?B?djJKOUJodUViMnhlcUpVTXI0b0pLRTZTYnZyVG5Na3lPdU1aeWljS2RtSStR?= =?utf-8?B?MGpRY0pCZC9wNDY4YUFNdVRkSS9zS0ZYNmdCMTczNi9Lay84RHR4amNwa3hK?= =?utf-8?B?Tm1tMjVpQjRYRzBzWTlUZnRFOCtsWVRhVDJMcGtiTUh6Yi9PRzJZK3JFR1py?= =?utf-8?B?WGJRQXBlSDMrL1ZhY09aWlNBbW5Sbmtla1VRY0h1Z2dhcVoyTlJxcGVoTlNs?= =?utf-8?B?c3dLRUVGR3RVbFI0SUU4SDJ2emFvNWZpaHNBcG1lODhUOHp3c01JWVRVWE1B?= =?utf-8?Q?5+488pRJhfD1k+dGKLptbeKpf?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 347054fc-a8fc-4e97-14a3-08db093e0f78 X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5874.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 19:03:55.6769 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /oVlevjuuZNoWym4OHXio7qnmdz37b2Hfpfu3d75NmlPkSv6yWTbmm9dpcQSeqiFn2sVAiwVnr6QrVbh/GYXJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8325 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/7/23 12:52, Boqun Feng wrote: > This allows printing the inner data of `Arc` and its friends if the > inner data implements `Display` or `Debug`. It's useful for logging and > debugging purpose. > > Signed-off-by: Boqun Feng > Reviwed-by: Vincenzo Palazzo s/Reviwed/Reviewed > --- > rust/kernel/sync/arc.rs | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs > index 519a6ec43644..e6176d9b5b29 100644 > --- a/rust/kernel/sync/arc.rs > +++ b/rust/kernel/sync/arc.rs > @@ -22,6 +22,7 @@ use crate::{ > }; > use alloc::boxed::Box; > use core::{ > + fmt, > marker::{PhantomData, Unsize}, > mem::{ManuallyDrop, MaybeUninit}, > ops::{Deref, DerefMut}, > @@ -522,3 +523,27 @@ impl DerefMut for UniqueArc { > unsafe { &mut self.inner.ptr.as_mut().data } > } > } > + > +impl fmt::Display for UniqueArc { > + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { > + fmt::Display::fmt(self.deref(), f) > + } > +} > + > +impl fmt::Display for Arc { > + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { > + fmt::Display::fmt(self.deref(), f) > + } > +} > + > +impl fmt::Debug for UniqueArc { > + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { > + fmt::Debug::fmt(self.deref(), f) > + } > +} > + > +impl fmt::Debug for Arc { > + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { > + fmt::Debug::fmt(self.deref(), f) > + } > +} Just a thought, perhaps it's worth creating a macro to implement this trait, since all do the same with fmt and others might join later on. Thanks, Carlos