DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Mattias Rönnblom" <hofors@lysator.liu.se>, dev@dpdk.org
Cc: "Tyler Retzlaff" <roretzla@linux.microsoft.com>
Subject: RE: RTE lock
Date: Wed, 6 Mar 2024 09:46:55 +0100	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F2D4@smartserver.smartshare.dk> (raw)
In-Reply-To: <0024db51-8b39-4aa7-969a-bde86fe1c764@lysator.liu.se>

> From: Mattias Rönnblom [mailto:hofors@lysator.liu.se]
> Sent: Tuesday, 5 March 2024 21.18
> 
> Shouldn't we have a DPDK-native mutex API, rather than using direct
> POSIX mutex lock calls?
> 
> 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.
> 
> 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.

The DPDK does interact with the control plane in ways that require locks, so adding preemption-friendly synchronization APIs seems appropriate.
And although I often rant about EAL bloat, I suppose this would belong into the EAL.

If you add any APIs with a timeout parameter, make sure to use struct timespec, like pthread_mutex_timedlock(). If a synchronization function is exclusively used for the control plane, millisecond resolution would probably suffice, but if it might be used by the data plane, millisecond level delays are intolerable. This was overlooked when adding rte_epoll_wait(), which was implemented using epoll_wait() instead of epoll_pwait2(), so you have to use the O/S specific timerfd_create/settime() functions for high-res timeout - and then the whole point of this EAL function goes out the window.

For reference, DPDK offers many types of locks [1]:
atomic, mcslock, pflock, rwlock, seqcount, seqlock, spinlock, ticketlock, RCU

[1] https://doc.dpdk.org/api/


      parent reply	other threads:[~2024-03-06  8:47 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
2024-03-08  9:44       ` Mattias Rönnblom
2024-03-06  8:46 ` Morten Brørup [this message]

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=98CBD80474FA8B44BF855DF32C47DC35E9F2D4@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=dev@dpdk.org \
    --cc=hofors@lysator.liu.se \
    --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).