perfbook.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: nick black <dankamongmen@gmail.com>
To: perfbook@vger.kernel.org
Subject: 3.2.2: "lock requires two atomic ops"
Date: Tue, 13 Jun 2023 20:15:28 -0400	[thread overview]
Message-ID: <20230614001528.GA3365842@schwarzgerat.orthanc> (raw)

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

enjoying the updated edition!

"The lock operation is more expensive than CAS because it
 requires two atomic operations on the lock data structure, one
 for acquisition and the other for release."

this might be worth expanding upon. it's not immediately obvious
to me why the unlock would need to be atomic. the rough 2x
certainly jives with this explanation, and i intend to go look
at some source, but i'd think it would be more:

  atomic update
  fence
  non-atomic update

you've presumably got threads attempting to lock with a CAS
looking for a sentinel representing unlocked, right? so if i
update back to that sentinel in multiple steps, they're going to
miss in media res, no?

feel no obligation to respond, of course.

--nick

-- 
nick black -=- https://www.nick-black.com
to make an apple pie from scratch,
you need first invent a universe.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2023-06-14  0:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14  0:15 nick black [this message]
2023-06-15 20:31 ` 3.2.2: "lock requires two atomic ops" Paul E. McKenney

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=20230614001528.GA3365842@schwarzgerat.orthanc \
    --to=dankamongmen@gmail.com \
    --cc=perfbook@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).