DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Mattias Rönnblom" <hofors@lysator.liu.se>
Cc: "Tyler Retzlaff" <roretzla@linux.microsoft.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: Re: RTE lock
Date: Thu, 7 Mar 2024 12:27:30 -0800	[thread overview]
Message-ID: <20240307122730.35a07d8b@hermes.local> (raw)
In-Reply-To: <ca5d6c66-1ee7-4a47-a086-e82627780bb7@lysator.liu.se>

On Thu, 7 Mar 2024 20:50:26 +0100
Mattias Rönnblom <hofors@lysator.liu.se> wrote:

> On 2024-03-05 22:02, Tyler Retzlaff wrote:
> > On Tue, Mar 05, 2024 at 09:18:20PM +0100, Mattias Rönnblom wrote:  
> >> Shouldn't we have a DPDK-native mutex API, rather than using direct
> >> POSIX mutex lock calls?  
> > 
> > David raised this a while back and the consensus is yes. I admit it's
> > been on my radar for a long time for the obvious reasons you list below
> > but with other work hasn't been a priority (yet).
> >   
> >>
> >> There are two reasons for this, as I see it
> >> 1) more cleanly support non-POSIX operating system (i.e., Microsoft
> >> Windows).
> >> 2) to discourage mechanical use of spinlocks in places where a
> >> regular mutex lock is more appropriate.
> >>
> >> I think (and hope) DPDK developers will tend to pick DPDK-native
> >> rather than other APIs as their first choice.  
> > 
> > I spent some time evaluating C11 mutex but it really didn't strike me as
> > being fit for purpose so I think DPDK-native is probably the only way to
> > go. If behind the scenes particular locks relied on something standard
> > for Windows perhaps it could be hidden as an implementation detail.
> >   
> 
> What was it you were missing?
> 
> I'm not familiar with C11 mtx_*()
> 
> >>
> >> For locks, they go for spinlocks, even in control (non-fast
> >> path/non-packet processing) code paths (e.g., calls made by the
> >> typical non-EAL thread).
> >>
> >> Using spinlocks to synchronize threads that may be preempted aren't
> >> great idea.  
> > 
> > If you're thinking of looking into this i'd be happy to see it solved.
> >   
> 
> I have no immediate plans, but this might be something I'll do in the 
> future.
> 
> > ty  

For Linux, what would be good is a simplified version of what pthread_mutex
does. The current code for pthread_mutex in glibc has a lot of indirection
and complexity which definately slows down the fast uncontended path.
Ideally, an inline version using futex.

Glibc has so much indirection because it supports so many mutex variants
and operating systems like mach and hurd...

  reply	other threads:[~2024-03-07 20:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 20:18 Mattias Rönnblom
2024-03-05 20:50 ` Stephen Hemminger
2024-03-05 21:02 ` Tyler Retzlaff
2024-03-07 19:50   ` Mattias Rönnblom
2024-03-07 20:27     ` Stephen Hemminger [this message]
2024-03-08  9:44       ` Mattias Rönnblom
2024-03-06  8:46 ` Morten Brørup

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=20240307122730.35a07d8b@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=hofors@lysator.liu.se \
    --cc=mattias.ronnblom@ericsson.com \
    --cc=roretzla@linux.microsoft.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).