mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Leonid Shamis <leonid.shamis@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] robust list not issuing FUTEX_WAKE
Date: Wed, 20 Apr 2022 19:56:17 -0400	[thread overview]
Message-ID: <20220420235617.GE7074@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAHSMefh+=VrbWHp_OXyfZKJ-Tz1rP_+SCFDgbKsj000ZZjpBYA@mail.gmail.com>

On Wed, Apr 20, 2022 at 04:46:23PM -0700, Leonid Shamis wrote:
> Hey Musl Folks,
> 
> I'm trying to understand the futex robust list and it's not quite working
> how I would expect it to from a reading of the man pages.
> 
> In a minimal example, I'm getting the futex changed to FUTEX_OWNER_DIED
> instead of FUTEX_OWNER_DIED|tid and I'm not getting a FUTEX_WAKE event.
> Any idea why this might be?
> 
> Happy to share the minimal example.

Can you clarify if you're trying to use robust mutexes under musl or
roll your own thing using the kernel robust list directly? I don't
think I'm understanding what you're confused about. If the owner of a
robust mutex dies, its tid can no longer be in the futex word because
that tid is immediately available to be assigned to a new task, and
the next thread trying to lock the mutex would not be able to
distinguish whether it's owned by a new thread with that tid, or
available.

So as far as the kernel is concerned, FUTEX_OWNER_DIED is more of a
value than a flag. It's what the futex word gets set to when the owner
dies with it held. In musl, we use FUTEX_OWNER_DIED as a flag as well
for a robust mutex whose old owner died and who has a new owner but
hasn't yet called pthread_mutex_consistent (in which case it would
become unrecoverable on unlock).

Rich

  reply	other threads:[~2022-04-20 23:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 23:46 Leonid Shamis
2022-04-20 23:56 ` Rich Felker [this message]
2022-04-21 12:25   ` Rich Felker
2022-04-21 19:09     ` Leonid Shamis

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=20220420235617.GE7074@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=leonid.shamis@gmail.com \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).