DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: "Zhou, Xiangyun" <xiangyun.zhou@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "Xu, Bowen" <bowen.xu@intel.com>
Subject: Re: C++20 report error at file rte_spinlock.h
Date: Mon, 19 Dec 2022 08:30:11 -0800	[thread overview]
Message-ID: <20221219163011.GA18921@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <PH0PR11MB4776AB842314CFB45A6BD049F2E39@PH0PR11MB4776.namprd11.prod.outlook.com>

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=c++20", the compiler report below errors. After checking file rte_spinlock.h, I think the error report by compiler is valid, there should be a potential issue when using functions rte_spinlock_recursive_lock, rte_spinlock_recursive_unlock and rte_spinlock_recursive_trylock in multi-thread, we could either remove "volatile" definition to ask users to handle the multi-thread issue, or using atomic operatings instead of self-increment and self-decrement.
> 
> 
> /home/dpdk/lib/eal/include/generic/rte_spinlock.h:221:12: error: increment 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: decrement of object of volatile-qualified type 'volatile int' is deprecated [-Werror,-Wdeprecated-volatile]
>         if (--(slr->count) == 0) {
>             ^
> /home/dpdk/lib/eal/include/generic/rte_spinlock.h:255:12: error: increment of object of volatile-qualified type 'volatile int' is deprecated [-Werror,-Wdeprecated-volatile]
>         slr->count++;
> 

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.

the code should be converted to use __atomic_fetch_{add,sub} or
__atomic_{add,sub}_fetch as appropriate.

ty.

  reply	other threads:[~2022-12-19 16:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13  6:11 Zhou, Xiangyun
2022-12-19 16:30 ` Tyler Retzlaff [this message]
2022-12-19 16:51   ` Konstantin Ananyev
2022-12-20  2:11     ` Zhou, Xiangyun
2022-12-21 16:37       ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221219163011.GA18921@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
    --to=roretzla@linux.microsoft.com \
    --cc=bowen.xu@intel.com \
    --cc=dev@dpdk.org \
    --cc=xiangyun.zhou@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).