public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/15215] New: Unify pthread_once implementations.
@ 2013-02-28 19:59 carlos at redhat dot com
  2013-05-24 21:48 ` [Bug nptl/15215] " carlos at redhat dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: carlos at redhat dot com @ 2013-02-28 19:59 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15215

             Bug #: 15215
           Summary: Unify pthread_once implementations.
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: unassigned@sourceware.org
        ReportedBy: carlos@redhat.com
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


At present we have several different algorithms for implementing the core of
pthread_once.

The following machines share one implementation, call this I1:

ports/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/ia64/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/tile/nptl/pthread_once.c
nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c

The following machines share another implementation, call this I2:

ports/sysdeps/unix/sysv/linux/m68k/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/aarch64/nptl/pthread_once.c

The following machines have custom implementations:

nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S
nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c
nptl/sysdeps/unix/sysv/linux/s390/pthread_once.c
ports/sysdeps/unix/sysv/linux/alpha/nptl/pthread_once.c

(a) Verify I1 is functionally equivalent to I2.
- Someone should verify that the algorithm used in I1 is equivalent to I2.
- If I1 is not equivalent to I2 then the algorithm should be fixed one way or
the other to produce a functioning single implementation called IC. Do not
cleanup any of the magic numbers yet since that's (c).
- Post analysis and patch (if you changed a representative implementation) to
libc-alpha@sourceware.org and libc-ports@sourceware.org and suggest (b).

Notes:
- It would appear that in I2 the setting of once_control via:
"*once_control = __fork_generation | 2;" may not have the release semantics
required by the earlier "atomic_compare_and_exchange_val_acq (once_control,
newval, oldval)". This means I2 is not actually safe for systems that have
weakly ordered memory writes.

(b) Use IC for all machines that do not have custom implementations.
- Place IC in nptl/sysdeps/unix/sysv/linux/pthread_once.c
- Remove:
ports/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/ia64/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/tile/nptl/pthread_once.c
nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c
ports/sysdeps/unix/sysv/linux/m68k/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c
ports/sysdeps/unix/sysv/linux/aarch64/nptl/pthread_once.c
The builds will fall back to using the newly installed IC.
- Post patch to libc-alpha@sourceware.org and libc-ports@sourceware.org, garner
consensus, and checkin changes.

(c) Cleanup IC.
- We magically add +4 in nptl/sysdeps/unix/sysv/linux/fork.c to the fork
generation counter, that's simply to avoid the low-two bits which we use in
control object to indicate done running init_routine (bit 2 set) or running
init_routine (bit 1 set). We should use a macro here like
__PTHREAD_ONCE_FORK_GEN and define it in nptl/pthreadP.h.
- Similarly the IC should use:
/* Used by pthread_once and fork coordination.  */
#define __PTHREAD_ONCE_RUN      1       /* Running the initializer.  */
#define __PTHREAD_ONCE_DONE     2       /* Initializer done running.  */
#define __PTHREAD_ONCE_MASK     3       /* Status bit mask.  */
instead of the magic & 2, or | 1, etc, that appear in the implementation.
- Get rid of the `& -4' magic, we all know this is actually
`~(__PTHREAD_ONCE_FORK_GEN - 1)' which makes a lot more sense to most people
and generates the same code.
- Make sure that the atomic update to the control object has the correct
semantics e.g. release.

(d) Review i386 and x86_64 implementations.
- Review:
nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
- How do those compare to IC?
- Try compiling IC for i386 and x86_64 by simply removing the assembly
implementation and examine the generated assembly to see if it's any better or
the same as the custom assembly versions.
- Post any interesting findings to libc-alpha@sourceware.org.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/15215] Unify pthread_once implementations.
  2013-02-28 19:59 [Bug nptl/15215] New: Unify pthread_once implementations carlos at redhat dot com
  2013-05-24 21:48 ` [Bug nptl/15215] " carlos at redhat dot com
@ 2013-05-24 21:48 ` carlos at redhat dot com
  2014-04-11 14:04 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: carlos at redhat dot com @ 2013-05-24 21:48 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15215

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |triegel at redhat dot com

--- Comment #1 from Carlos O'Donell <carlos at redhat dot com> ---
Torvald is looking at this.

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/15215] Unify pthread_once implementations.
  2013-02-28 19:59 [Bug nptl/15215] New: Unify pthread_once implementations carlos at redhat dot com
@ 2013-05-24 21:48 ` carlos at redhat dot com
  2013-05-24 21:48 ` carlos at redhat dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: carlos at redhat dot com @ 2013-05-24 21:48 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15215

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/15215] Unify pthread_once implementations.
  2013-02-28 19:59 [Bug nptl/15215] New: Unify pthread_once implementations carlos at redhat dot com
  2013-05-24 21:48 ` [Bug nptl/15215] " carlos at redhat dot com
  2013-05-24 21:48 ` carlos at redhat dot com
@ 2014-04-11 14:04 ` cvs-commit at gcc dot gnu.org
  2014-06-13 18:46 ` fweimer at redhat dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-04-11 14:04 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  36875b06e0ed7f137190b9228bef553adfc338ba (commit)
      from  579db35a068e70a4f3112000778138ede6994ac0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=36875b06e0ed7f137190b9228bef553adfc338ba

commit 36875b06e0ed7f137190b9228bef553adfc338ba
Author: Torvald Riegel <triegel@redhat.com>
Date:   Wed May 8 16:35:10 2013 +0200

    Fixed and unified pthread_once.

    [BZ #15215] This unifies various pthread_once architecture-specific
    implementations which were using the same algorithm with slightly different
    implementations.  It also adds missing memory barriers that are required
for
    correctness.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |   13 ++
 nptl/sysdeps/unix/sysv/linux/pthread_once.c        |  131 ++++++++++++++++++++
 nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c  |   93 --------------
 ports/ChangeLog.hppa                               |    5 +
 .../unix/sysv/linux/hppa/nptl/pthread_once.c       |   93 --------------
 .../unix/sysv/linux/aarch64/nptl/pthread_once.c    |   90 --------------
 sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c    |   89 -------------
 sysdeps/unix/sysv/linux/ia64/nptl/pthread_once.c   |   93 --------------
 sysdeps/unix/sysv/linux/m68k/nptl/pthread_once.c   |   90 --------------
 sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c   |   93 --------------
 sysdeps/unix/sysv/linux/tile/nptl/pthread_once.c   |   94 --------------
 11 files changed, 149 insertions(+), 735 deletions(-)
 create mode 100644 nptl/sysdeps/unix/sysv/linux/pthread_once.c
 delete mode 100644 nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c
 delete mode 100644 ports/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/nptl/pthread_once.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c
 delete mode 100644 sysdeps/unix/sysv/linux/ia64/nptl/pthread_once.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/nptl/pthread_once.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c
 delete mode 100644 sysdeps/unix/sysv/linux/tile/nptl/pthread_once.c

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/15215] Unify pthread_once implementations.
  2013-02-28 19:59 [Bug nptl/15215] New: Unify pthread_once implementations carlos at redhat dot com
                   ` (2 preceding siblings ...)
  2014-04-11 14:04 ` cvs-commit at gcc dot gnu.org
@ 2014-06-13 18:46 ` fweimer at redhat dot com
  2014-10-20 16:26 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 18:46 UTC (permalink / raw)
  To: glibc-bugs

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/15215] Unify pthread_once implementations.
  2013-02-28 19:59 [Bug nptl/15215] New: Unify pthread_once implementations carlos at redhat dot com
                   ` (3 preceding siblings ...)
  2014-06-13 18:46 ` fweimer at redhat dot com
@ 2014-10-20 16:26 ` cvs-commit at gcc dot gnu.org
  2014-10-20 19:37 ` triegel at redhat dot com
  2014-10-31 21:22 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-10-20 16:26 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  63668b7084ac26865136e59fdf17781f9f49bd99 (commit)
      from  42b7f5d48549b85386a9b28a1a90e66fd81ba273 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=63668b7084ac26865136e59fdf17781f9f49bd99

commit 63668b7084ac26865136e59fdf17781f9f49bd99
Author: Torvald Riegel <triegel@redhat.com>
Date:   Fri Oct 11 18:58:04 2013 +0300

    pthread_once: Clean up constants.

    [BZ #15215] This just gives a name to the integer constants being used.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog           |    9 +++++++++
 nptl/pthreadP.h     |    6 ++++++
 nptl/pthread_once.c |   21 ++++++++++++---------
 sysdeps/nptl/fork.c |    3 ++-
 4 files changed, 29 insertions(+), 10 deletions(-)

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/15215] Unify pthread_once implementations.
  2013-02-28 19:59 [Bug nptl/15215] New: Unify pthread_once implementations carlos at redhat dot com
                   ` (4 preceding siblings ...)
  2014-10-20 16:26 ` cvs-commit at gcc dot gnu.org
@ 2014-10-20 19:37 ` triegel at redhat dot com
  2014-10-31 21:22 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: triegel at redhat dot com @ 2014-10-20 19:37 UTC (permalink / raw)
  To: glibc-bugs

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

Torvald Riegel <triegel at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Torvald Riegel <triegel at redhat dot com> ---
Fixed with f50277c19df0937ea9691ab7e7c642ecd3ed3d94.

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/15215] Unify pthread_once implementations.
  2013-02-28 19:59 [Bug nptl/15215] New: Unify pthread_once implementations carlos at redhat dot com
                   ` (5 preceding siblings ...)
  2014-10-20 19:37 ` triegel at redhat dot com
@ 2014-10-31 21:22 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-10-31 21:22 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  b09adb5b46327e4a2ea354d5524280146d9c6015 (commit)
      from  94a42455257226361fedf37a0ad7fc1d9d131645 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b09adb5b46327e4a2ea354d5524280146d9c6015

commit b09adb5b46327e4a2ea354d5524280146d9c6015
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Fri Oct 31 21:21:15 2014 +0000

    Add bug 15215 to NEWS; move bug 17344 to correct version's list in NEWS.

-----------------------------------------------------------------------

Summary of changes:
 NEWS |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-10-31 21:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-28 19:59 [Bug nptl/15215] New: Unify pthread_once implementations carlos at redhat dot com
2013-05-24 21:48 ` [Bug nptl/15215] " carlos at redhat dot com
2013-05-24 21:48 ` carlos at redhat dot com
2014-04-11 14:04 ` cvs-commit at gcc dot gnu.org
2014-06-13 18:46 ` fweimer at redhat dot com
2014-10-20 16:26 ` cvs-commit at gcc dot gnu.org
2014-10-20 19:37 ` triegel at redhat dot com
2014-10-31 21:22 ` cvs-commit at gcc dot gnu.org

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