DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
Cc: Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
	"Richardson, Bruce" <bruce.richardson@intel.com>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"dmitrym@microsoft.com" <dmitrym@microsoft.com>,
	"khot@microsoft.com" <khot@microsoft.com>,
	"navasile@microsoft.com" <navasile@microsoft.com>,
	"ocardona@microsoft.com" <ocardona@microsoft.com>,
	"Kadam, Pallavi" <pallavi.kadam@intel.com>,
	"roretzla@microsoft.com" <roretzla@microsoft.com>,
	"talshn@nvidia.com" <talshn@nvidia.com>,
	"thomas@monjalon.net" <thomas@monjalon.net>
Subject: Re: [PATCH v18 8/8] eal: implement functions for mutex management
Date: Wed, 9 Mar 2022 00:33:41 +0300	[thread overview]
Message-ID: <20220309003341.29f14f1b@sovereign> (raw)
In-Reply-To: <BY5PR11MB44826A2A40CEC5E8A1943FBD9A3D9@BY5PR11MB4482.namprd11.prod.outlook.com>

Hi Konstantin,

2022-02-24 17:29 (UTC+0000), Ananyev, Konstantin:
[...]
> > However, DmitryM suggested using Slim Reader-Writer lock (SRW):
> > https://docs.microsoft.com/en-us/windows/win32/sync/slim-reader-writer--srw--locks
> > instead of CRITICAL_SECTION.
> > It seems to be a much better option:
> > 
> > * sizeof(SRWLOCK) == 8 (technically "size of a pointer"),
> >   same as sizeof(pthread_mutex_t) on a typical Linux.
> >   Layout of data structures containing rte_thread_mutex_t
> >   can be the same on Windows and Unix,
> >   which simplifies design and promises similar less performance differences.
> > 
> > * Can be taken by multiple readers and one writer,
> >   which is semantically similar to pthread_mutex_t  
> 
> Not sure I understand you here:
> pthread_mutex provides only mutually-exclusive lock semantics.
> For RW lock there exists: pthread_rwlock_t.
> Off-course you can use rwlock fo exclusive locking too -
> if all callers will use only writer locks, but usually that's no point to do that -
> mutexes are simpler and faster.
> That's for posix-like systems, don't know much about Windows environment :)

It is different on Windows.
Multiple sources claim SRW lock is faster than CRITICAL_SECTION
even when used only for exclusive locking.
SRW locks do not support recursive locking,
while CRITICAL_SECTION is always recursive.
I see PTHREAD_MUTEX_RECURSIVE used in net/failsafe and raw/ifpga.
CRITICAL_SECTION also keeps debug information to analyze deadlocks
(can't say much here, never used this feature).

> > Technically it can be a "typedef uintptr_t" or a structure wrapping it.  
> 
> Again can't say much about Windows, but pthread_mutex_t
> can (and is) bigger then then 8 bytes. 

My bad, I measured incorrectly: sizeof(pthread_mutex_t) is 40 on my system.

  parent reply	other threads:[~2022-03-08 21:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 16:02 Ananyev, Konstantin
2022-02-08  2:21 ` Ananyev, Konstantin
2022-02-09  2:47   ` Narcisa Ana Maria Vasile
2022-02-09 13:57     ` Ananyev, Konstantin
2022-02-20 21:56       ` Dmitry Kozlyuk
2022-02-23 17:08         ` Dmitry Kozlyuk
2022-02-24 17:29           ` Ananyev, Konstantin
2022-02-24 17:44             ` Stephen Hemminger
2022-03-08 21:36               ` Dmitry Kozlyuk
2022-03-08 21:33             ` Dmitry Kozlyuk [this message]
2022-02-09  3:08 ` Narcisa Ana Maria Vasile
2022-02-09 12:12   ` Ananyev, Konstantin
  -- strict thread matches above, loose matches on Subject: below --
2021-11-10  3:01 [dpdk-dev] [PATCH v17 00/13] eal: Add EAL API for threading Narcisa Ana Maria Vasile
2021-11-11  1:33 ` [PATCH v18 0/8] " Narcisa Ana Maria Vasile
2021-11-11  1:33   ` [PATCH v18 8/8] eal: implement functions for mutex management Narcisa Ana Maria Vasile
2021-12-13 20:27     ` Narcisa Ana Maria Vasile

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=20220309003341.29f14f1b@sovereign \
    --to=dmitry.kozliuk@gmail.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dmitrym@microsoft.com \
    --cc=khot@microsoft.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=navasile@linux.microsoft.com \
    --cc=navasile@microsoft.com \
    --cc=ocardona@microsoft.com \
    --cc=pallavi.kadam@intel.com \
    --cc=roretzla@microsoft.com \
    --cc=talshn@nvidia.com \
    --cc=thomas@monjalon.net \
    /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).