public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "carlos at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug linuxthreads/25774] Suggestion: count number of retries in __lll_lock_wait
Date: Sat, 04 Apr 2020 16:17:16 +0000	[thread overview]
Message-ID: <bug-25774-131-sgoSf0wfOp@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-25774-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=25774

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |carlos at redhat dot com
   Last reconfirmed|                            |2020-04-04
     Ever confirmed|0                           |1

--- Comment #1 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to François Rigault from comment #0)
> ```
> --- glibc-2.30/nptl/lowlevellock.c      2019-08-01 06:29:31.000000000 +0200
> +++ ../glibc/glibc-2.30/nptl/lowlevellock.c     2020-04-04
> 11:24:50.367896172 +0200
> @@ -42,13 +42,16 @@
>  void
>  __lll_lock_wait (int *futex, int private)
>  {
> +  int count = 0;
> +
>    if (atomic_load_relaxed (futex) == 2)
>      goto futex;
> 
>    while (atomic_exchange_acquire (futex, 2) != 0)
>      {
> +      ++count;
>      futex:
> -      LIBC_PROBE (lll_lock_wait, 1, futex);
> +      LIBC_PROBE (lll_lock_wait, 2, futex, count);
>        lll_futex_wait (futex, 2, private); /* Wait if *futex == 2.  */
>      }
>  }
> ```

It adds a small amount of code in the slow path before the wait, which seems
fine to me, we're about to enter the kernel and sleep.

The value is local, and should be 'unsigned' to allow wrapping.

I think your suggestion is a good one.

Would you like to put a patch together for this?

I'd expect:
- The change to the probe.
- Add the probe to manual/probes.texi under a new node "POSIX Thread Probes"
and document the behaviour (previously undocumented) of just this probe.

Have a look at our contribution checklist:
https://sourceware.org/glibc/wiki/Contribution%20checklist

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2020-04-04 16:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-04  9:52 [Bug linuxthreads/25774] New: " rigault.francois+glib at gmail dot com
2020-04-04 16:10 ` [Bug linuxthreads/25774] " romain.geissler at amadeus dot com
2020-04-04 16:17 ` carlos at redhat dot com [this message]
2020-04-04 20:51 ` rigault.francois+glib at gmail dot com
2020-04-04 20:52 ` rigault.francois+glib at gmail dot com
2020-04-06 12:00 ` [Bug nptl/25774] " fweimer at redhat dot com
2020-04-06 14:28 ` carlos at redhat dot com
2020-04-11 10:35 ` rigault.francois+glib at gmail dot com

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=bug-25774-131-sgoSf0wfOp@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.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).