From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 152F8A00C5; Mon, 19 Dec 2022 17:51:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7BE840A7A; Mon, 19 Dec 2022 17:51:24 +0100 (CET) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id AB84040685 for ; Mon, 19 Dec 2022 17:51:23 +0100 (CET) Received: from frapeml500007.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4NbQcn6rtzz67N6g; Tue, 20 Dec 2022 00:48:09 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 19 Dec 2022 17:51:22 +0100 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2375.034; Mon, 19 Dec 2022 17:51:22 +0100 From: Konstantin Ananyev To: Tyler Retzlaff , "Zhou, Xiangyun" CC: "dev@dpdk.org" , "Xu, Bowen" Subject: RE: C++20 report error at file rte_spinlock.h Thread-Topic: C++20 report error at file rte_spinlock.h Thread-Index: AdkOua1eIFFRnwEuTUqVdev5WXYqUQFBRr6AAAKUvdA= Date: Mon, 19 Dec 2022 16:51:22 +0000 Message-ID: References: <20221219163011.GA18921@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> In-Reply-To: <20221219163011.GA18921@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.206.138.42] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > On Tue, Dec 13, 2022 at 06:11:06AM +0000, Zhou, Xiangyun wrote: > > Dear dpdk dev, > > > > I'm using dpdk 21.11 LTS, when compile my program with CPP flag "-std= =3Dc++20", the compiler report below errors. After checking file > rte_spinlock.h, I think the error report by compiler is valid, there shou= ld be a potential issue when using functions > rte_spinlock_recursive_lock, rte_spinlock_recursive_unlock and rte_spinlo= ck_recursive_trylock in multi-thread, we could either > remove "volatile" definition to ask users to handle the multi-thread issu= e, or using atomic operatings instead of self-increment and > self-decrement. > > > > > > /home/dpdk/lib/eal/include/generic/rte_spinlock.h:221:12: error: increm= ent of object of volatile-qualified type 'volatile int' is > deprecated [-Werror,-Wdeprecated-volatile] > > slr->count++; > > ^ > > /home/dpdk/lib/eal/include/generic/rte_spinlock.h:231:6: error: decreme= nt of object of volatile-qualified type 'volatile int' is > deprecated [-Werror,-Wdeprecated-volatile] > > if (--(slr->count) =3D=3D 0) { > > ^ > > /home/dpdk/lib/eal/include/generic/rte_spinlock.h:255:12: error: increm= ent of object of volatile-qualified type 'volatile int' is > deprecated [-Werror,-Wdeprecated-volatile] > > slr->count++; > > >=20 > i have work in progress to optionally use standard atomics but in the > meantime the correct thing to do here is to use the gcc builtins that > match the requirements of the c++11 memory model. >=20 > the code should be converted to use __atomic_fetch_{add,sub} or > __atomic_{add,sub}_fetch as appropriate. >=20 > ty. >From looking at the code, I don't think it is necessary: both 'user' and 'count' supposed to be protected by 'sl'. In fact, it looks safe just to remove 'volatile' qualifier here. =20