From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59BDEA0528; Thu, 9 Jul 2020 11:52:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C316B1E54F; Thu, 9 Jul 2020 11:52:57 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60076.outbound.protection.outlook.com [40.107.6.76]) by dpdk.org (Postfix) with ESMTP id 57EC01E54B for ; Thu, 9 Jul 2020 11:52:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UjTDMK/uYxND/iqSeC1kZxGEfe+hSYhRm2hR5pEwqZo=; b=fiwROk+xe31PijPqLMe8extanyJDd6T1jjE2PrCi8XqkkTbSiufv9ShUwF5kGbMRzGrF2PTz1jAtCU7k+0F9NRgmjysLjkGbJuMzk4jCSASjDhmwJOMXe7CZHkPxj3L8w5nbnlM18vrTXmUxFs8J4zqGrfIQ9j8nKJEJ676l2nQ= Received: from AM5PR0202CA0003.eurprd02.prod.outlook.com (2603:10a6:203:69::13) by DB7PR08MB2970.eurprd08.prod.outlook.com (2603:10a6:5:17::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Thu, 9 Jul 2020 09:52:55 +0000 Received: from AM5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::ba) by AM5PR0202CA0003.outlook.office365.com (2603:10a6:203:69::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22 via Frontend Transport; Thu, 9 Jul 2020 09:52:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT020.mail.protection.outlook.com (10.152.16.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Thu, 9 Jul 2020 09:52:55 +0000 Received: ("Tessian outbound c4059ed8d7bf:v62"); Thu, 09 Jul 2020 09:52:54 +0000 X-CR-MTA-TID: 64aa7808 Received: from 2022ab143824.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F0D3FBC2-3012-4230-80E1-FEE3991E63A3.1; Thu, 09 Jul 2020 09:52:49 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2022ab143824.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 09 Jul 2020 09:52:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ri3PGuONtVik6HKFuHyvDHAfk0Cm8+0xFvBU0F7o8ZztSibAA9J7NyqPAranSVJw6o4sumhR7sZO2rjGq5K2wIGF8dSfyRJ2EW21fe9d49wrmdfVm8M5xUYiL7G8x6D0I8t3TJBLSTnEREeBvB0Nfzhnt1tQxSCvV5kQQzF63h4dcf+2j/5qVY3kBVAANVOZ57OUAyAkxmKUcHv1zRmGBjfdj1o02PducL233u7eSbK9xlzgo500Y5orPSpiQCbDuFkgBeYX03KOcofzMEJD0LY5X3zklR1Sgc1ScftoEST4HNnrKllsF1bGlLyzojeBnMu+QwTUV3bVjlrohhZYog== 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=UjTDMK/uYxND/iqSeC1kZxGEfe+hSYhRm2hR5pEwqZo=; b=i1jmOS5RP5/riPM2rG0BAdp6hcNABBLXwKYL3+TjWerBYu1Tpb8GQSOMKbtOUPIcplWXCXRmka+MMyMFOHsOU0alsEfI1+9CUNxt0RYRyytASkqr9dtePFogNMs1me9ruk6EH0eXMGZM0jqnrxOEFewlExBp7wZ1JATFQW2gv4P3OMsOhODZHU9tsQJHUUmhX0beeXKlC/ZJHwtM+HoOowZr480kVK+NxbUqsnxMnqnCoIb+tOzp2PW3mme18O6gJzASZyP1t5s9UJomMP0e9zHAM7DYGjAZXiR25MKjpGnmL8qhf0MWPBUReAosSvxpJEytZfRRjzQNM7/Rw5unEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UjTDMK/uYxND/iqSeC1kZxGEfe+hSYhRm2hR5pEwqZo=; b=fiwROk+xe31PijPqLMe8extanyJDd6T1jjE2PrCi8XqkkTbSiufv9ShUwF5kGbMRzGrF2PTz1jAtCU7k+0F9NRgmjysLjkGbJuMzk4jCSASjDhmwJOMXe7CZHkPxj3L8w5nbnlM18vrTXmUxFs8J4zqGrfIQ9j8nKJEJ676l2nQ= Received: from VE1PR08MB4640.eurprd08.prod.outlook.com (2603:10a6:802:b2::11) by VE1PR08MB4910.eurprd08.prod.outlook.com (2603:10a6:802:ac::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.24; Thu, 9 Jul 2020 09:52:45 +0000 Received: from VE1PR08MB4640.eurprd08.prod.outlook.com ([fe80::c2e:9ccb:a690:6863]) by VE1PR08MB4640.eurprd08.prod.outlook.com ([fe80::c2e:9ccb:a690:6863%6]) with mapi id 15.20.3174.022; Thu, 9 Jul 2020 09:52:45 +0000 From: Phil Yang To: Olivier Matz CC: Stephen Hemminger , "david.marchand@redhat.com" , "dev@dpdk.org" , "drc@linux.vnet.ibm.com" , Honnappa Nagarahalli , Ruifeng Wang , nd Thread-Topic: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations Thread-Index: AQHWVEbwX0ZZhWoutEejPVv4HOUHjKj8Wz4AgAC86dCAAHkqAIABURdw Date: Thu, 9 Jul 2020 09:52:45 +0000 Message-ID: References: <1591871178-12542-1-git-send-email-phil.yang@arm.com> <1594116633-14554-1-git-send-email-phil.yang@arm.com> <20200707101314.42df824c@hermes.lan> <20200708114301.GN5869@platinum> In-Reply-To: <20200708114301.GN5869@platinum> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 0b6c2bd2-886c-4853-b44c-83cdd0841a85.0 x-checkrecipientchecked: true Authentication-Results-Original: 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [203.126.0.112] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a1f84de2-7fd5-47a4-c50f-08d823edda65 x-ms-traffictypediagnostic: VE1PR08MB4910:|DB7PR08MB2970: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:8273;OLM:8273; x-forefront-prvs: 04599F3534 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: oek2PNvSaRnpMpDTR4lUIfiZMsgR8nwSOdvnLpLmGx6DIn9yUhCDdbjNRJs82xbyuu/ReuKSnmPjQCnnJAnFutzSiL1zVK5/NwsGCqmwKkbqu8MMH1xoV/uLlFI4HkPKCieW+YHq7YMsR0a3nk3/3bMzFlGBOJ78nNnlgr3qi02GA+h35rgVdwG80wBu/W47NFq0goArkK6l+97ix669jueVLVVkzTp76cXtEb8gRTOXYayv6RzNwo+SX7V88LKaNqY6TMb4LVmQLqxmhDDm5CdsYHxkbSvLpICaSN5s6zgZHYnFLPKKB13++LSlMsvrdAA8SkGDz/VN7Fyfenen2Q== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB4640.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(366004)(376002)(346002)(55016002)(4326008)(186003)(6916009)(2906002)(7696005)(54906003)(316002)(9686003)(33656002)(478600001)(71200400001)(6506007)(53546011)(76116006)(26005)(66946007)(64756008)(66446008)(66556008)(66476007)(52536014)(5660300002)(83380400001)(86362001)(8936002)(8676002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: dTZLD/GPzx4DxYqEzI0Yr4VQtv4Xon49pUGkTvX2LXmrlyynEuUhvJZm1GWKAsMD0V0VfVL1N9nPE6m9fa7jcpoFzGZULDAXkrrSNc9ktX1Y93bkmYZSIPlB8BzBz1rsv0lIFt4IDGapUlawJnwT5i6yez3DmIVbUiSbe7LfkvDyzqjm5dnoUVAcym2OjpbBZmknRlWRy46RxYuBxknVxNvVsN7vAIaDoXnJrXhDn30VTyDMh1UAiFTc4wWXZKHNBEeZNC/S9bw483PFTPFlpLqawvZHCdGd8i1vJ5V+MpNn6CG1n/v8deyd4rDNGn4a72VdE4xuw3RRUePXhDJVKMPLLDRr7Hb12+7wjpKj09U5j/7dPWa3WLhiXX6dO3HbKie0Ip+Gh73gTaDk5UHQT9qNU8Zn4nnSqgfYWr8KTzV5ooOtSV6rmQsI0b1sZIFRYc4OsSY4KvomKIv3DAxzoAVz5b92NTQfAs2jm5sxZtQ= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4910 Original-Authentication-Results: 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(346002)(376002)(396003)(39860400002)(136003)(46966005)(83380400001)(86362001)(52536014)(54906003)(478600001)(53546011)(81166007)(70586007)(4326008)(9686003)(7696005)(336012)(55016002)(5660300002)(8676002)(2906002)(33656002)(36906005)(6506007)(26005)(47076004)(6862004)(8936002)(186003)(82310400002)(82740400003)(316002)(356005)(70206006); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: e46e6d56-8fa6-40a5-cb35-08d823edd4cb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UjdJea9MQuIJcl6Hhhyx3b7zhpNNB+KTuFY4SFGGC6/fH+34fwQzT+L/X+XxyyfRkb3eDdWJ1TEsBU+iV9zeYrvOJ1aT1FF8nJROMZz/3wNoJR4rHQy7bt4ZXvTtp8aa33xijW07vKh8l4OFn57tDQdjO0DvrU1CL2VHCSkkIOpSsvwElrbRtEkBXNdXsfPPQpsTQFOqRCGtKx6okNhChNAkSeybb8RN8wa2uuMYULixopSvfVbSz56Sf5NR02mD+g48PESQ+q2NFeXxT0P/PdM0oEh19zKYaN4c99FsQrUcrqJf5Nj0GGyZ9n3Sk1EQg/k024SSMPR2UbO0DvcE2n1SPEH78/yXv3G1HIZ8K2PwvfnJf18NAnNBPJ15QVkQZTto3L680DdK5RRBuqwwkQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2020 09:52:55.0695 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1f84de2-7fd5-47a4-c50f-08d823edda65 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB2970 Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Olivier Matz > Sent: Wednesday, July 8, 2020 7:43 PM > To: Phil Yang > Cc: Stephen Hemminger ; > david.marchand@redhat.com; dev@dpdk.org; drc@linux.vnet.ibm.com; > Honnappa Nagarahalli ; Ruifeng Wang > ; nd > Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt > operations >=20 > On Wed, Jul 08, 2020 at 04:48:33AM +0000, Phil Yang wrote: > > > -----Original Message----- > > > From: Stephen Hemminger > > > Sent: Wednesday, July 8, 2020 1:13 AM > > > To: Phil Yang > > > Cc: david.marchand@redhat.com; dev@dpdk.org; > drc@linux.vnet.ibm.com; > > > Honnappa Nagarahalli ; > > > olivier.matz@6wind.com; Ruifeng Wang ; nd > > > > > > Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt > > > operations > > > > > > On Tue, 7 Jul 2020 18:10:33 +0800 > > > Phil Yang wrote: > > > > > > > + return (uint16_t)(__atomic_add_fetch((int16_t *)&shinfo- > > > >refcnt_atomic, > > > > + > > > > > > Why do you need so many casts here? > > > The type of refcnt_atomic is now uint16 after your patch. > > > > In the existing code, the input parameter type for this API is signed i= nteger. > For example: > > drivers/net/netvsc/hn_rxtx.c:531 > > lib/librte_mbuf/rte_mbuf.h:1194 > > > > However, the output type of rte_mbuf_ext_refcnt related APIs is not > uniform. We use these typecast to consistent with the current API definit= ion. >=20 > Would it make sense to cast the increment instead? Yes. It is better. Thanks. >=20 > I mean: >=20 > return __atomic_add_fetch(&m->refcnt, (uint16_t)value, > __ATOMIC_ACQ_REL); >=20 > instead of: >=20 > return (uint16_t)(__atomic_add_fetch((int16_t *)&m->refcnt, value, > __ATOMIC_ACQ_REL)); >=20 >=20 > The same could apply to __rte_pktmbuf_pinned_extbuf_decref() I think: >=20 > > - if (likely(rte_atomic16_add_return > > - (&shinfo->refcnt_atomic, -1))) > > + if (likely(__atomic_add_fetch((int *)&shinfo->refcnt_atomic, -1, > > + __ATOMIC_ACQ_REL))) >=20 > By the way, why was the cast was to (int *) in this case? I think > it can overwrite fields beside refcnt. Fixed in the next version. Thanks, Phil