public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: <katsuki.uwatoko@toshiba.co.jp>
Cc: <libc-ports@sourceware.org>, Carlos O'Donell <carlos@systemhalted.org>
Subject: Re: [PATCH] Avoid unnecessary busy loop in __lll_timedlock_wait on ARM.
Date: Thu, 07 Feb 2013 23:33:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.1302072328580.17419@digraph.polyomino.org.uk> (raw)
In-Reply-To: <F3B6523425E7914AA6214ED358D820AF25D90F5D@TGXML316.toshiba.local>

On Thu, 31 Jan 2013, katsuki.uwatoko@toshiba.co.jp wrote:

> Hi,
> 
> I have found an issue in __lll_timedlock_wait on ARM.

I think the busy loop should have a bug filed in Bugzilla, as a 
user-visible bug - could you file that bug?

> The following sequence causes unnecessary busy loop. 
> 
> "A thread" gets the lock. (futex = 1)
> "B thread" tries to get the lock, and has not called futex syscall yet. (futex = 2)
> "A thread" releases the lock (futex = 0)
> "C thread" gets the lock, and does not call futex syscall because of futex=0 (futex = 1)
> "B thread" calls futex syscall, and returns with an error.
>            Because futex syscall in Linux Kernel checks if the val is changed 
>            from 2, which is the 3rd arg of the syscall at futex_wait_setup(),
>            but in this case futex is 1.
> "B thread" tries to get the lock in userspace but cannot get it 
>            because futex is not 0.
>            After all the thread keeps calling futex syscall 
>            until "C thread" will release it (futex = 0) or timeout.
> 
> Therefore I think that the value should be set 2 in every loop 
> the same as __lll_lock_wait_private, and attached a patch for this issue.

Carlos, any comments on this patch 
<http://sourceware.org/ml/libc-ports/2013-01/msg00084.html>?  It makes the 
ARM version of __lll_timedlock_wait closer to the HPPA version, but I 
don't know if many of the differences between different architecture 
versions of this code are really deliberate....

Would you agree that the generic Linux version 
(nptl/sysdeps/unix/sysv/linux/lowlevellock.c) doesn't need such a change 
because the loop is using atomic_exchange_acq rather than 
atomic_compare_and_exchange_bool_acq, so is already setting the futex to 2 
in every loop iteration?

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2013-02-07 23:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31  8:42 katsuki.uwatoko
2013-02-07 23:33 ` Joseph S. Myers [this message]
2013-02-08  0:13   ` katsuki.uwatoko
2013-02-09  4:18   ` Carlos O'Donell
2013-02-09  6:49     ` David Miller
2013-02-09 14:56       ` Carlos O'Donell
2013-02-10  4:56         ` David Miller
2013-02-10 17:55           ` Carlos O'Donell
2013-02-12 21:41             ` Daniel Jacobowitz
2013-02-12 21:41               ` Daniel Jacobowitz
2013-02-12 21:57               ` Carlos O'Donell

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=Pine.LNX.4.64.1302072328580.17419@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=carlos@systemhalted.org \
    --cc=katsuki.uwatoko@toshiba.co.jp \
    --cc=libc-ports@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).