[dpdk-dev] [RFC] ethdev: make rte flow API thread safe

Suanming Mou suanmingm at nvidia.com
Wed Sep 9 03:26:47 CEST 2020



> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org>
> Sent: Tuesday, September 8, 2020 10:52 PM
> To: Suanming Mou <suanmingm at nvidia.com>
> Cc: Ori Kam <orika at mellanox.com>; John McNamara
> <john.mcnamara at intel.com>; Marko Kovacevic <marko.kovacevic at intel.com>;
> Matan Azrad <matan at mellanox.com>; Shahaf Shuler <shahafs at mellanox.com>;
> Viacheslav Ovsiienko <viacheslavo at mellanox.com>; NBU-Contact-Thomas
> Monjalon <thomas at monjalon.net>; Ferruh Yigit <ferruh.yigit at intel.com>;
> Andrew Rybchenko <arybchenko at solarflare.com>; dev at dpdk.org
> Subject: Re: [dpdk-dev] [RFC] ethdev: make rte flow API thread safe
> 
> On Mon, 7 Sep 2020 02:36:48 +0000
> Suanming Mou <suanmingm at nvidia.com> wrote:
> 
> > Hi,
> >
> > Sorry for my late reply due to the vacation.
> >
> > > What is the performance impact of this for currently working
> > > applications that use a single thread to program flow rules.  You
> > > are adding a couple of system calls to what was formerly a totally usermode
> operation.
> >
> 
> Read the source for glibc and see what pthread_mutex does

Yes, the pthread mutex lock will try CAS(Compare And Swap) with the atomic value first, if not success, have the futex syscall.
So it means in single thread case, no syscall will be introduced. And the testing code also shows pthread mutex have similar cycles with spin_lock.

> 
> > If I understand correctly, in the non-contended single thread case, pthread
> mutex lock should not go to the kernel space.
> > I also wrote a small application with pthread mutex, and strace shows no
> system call was introduced.
> >
> > Another simple testing code below is to check the cycles cost difference in
> every round between pthread mutex and spin_lock.
> >
> 
> Micro benchmarks of locking is hard to see.



More information about the dev mailing list