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 libc/29537] [2.34 regression]: Alignment issue on m68k when using futexes on qemu-user
Date: Tue, 30 Aug 2022 14:16:28 +0000	[thread overview]
Message-ID: <bug-29537-131-5DLdmXoFzy@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29537-131@http.sourceware.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com

--- Comment #3 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Adhemerval Zanella from comment #2)
> It seems a real issue, but I am puzzled why we have not see any issue so
> far. I take mostly runs were done in single-core, where hardware did not
> enforce 32-bit alignment with atomic operations.
> 
> A better change would be to use:
> 
> diff --git a/sysdeps/nptl/libc-lockP.h b/sysdeps/nptl/libc-lockP.h
> index d3a6837fd2..9efe962588 100644
> --- a/sysdeps/nptl/libc-lockP.h
> +++ b/sysdeps/nptl/libc-lockP.h
> @@ -34,7 +34,7 @@
>  #include <tls.h>
> 
>  /* Mutex type.  */
> -typedef int __libc_lock_t;
> +typedef int __libc_lock_t __LOCK_ALIGNMENT;
>  typedef struct { pthread_mutex_t mutex; } __rtld_lock_recursive_t;
>  typedef pthread_rwlock_t __libc_rwlock_t;

Does this impact any externally visible ABIs?

> Since __LOCK_ALIGNMENT is defined per architecture if required.  The HPPA
> also requires a 16-byte alignment for locks, although it is just a
> historical artifact to keep compatibility with old implementation.

If an architecture needs higher alignment for locks then I strongly suggest
out-of-line locking in the kernel as we did for parisc. We have an array of
locks that we use to scale the futex locking operations. We pick a lock based
on the low-bit hash of the futex address, and we use that consistently in our
kernel helper (kernel aided emulation of compare-and-swap) and inside the
kernel. This yields a consistent behaviour on SMP where the userspace CAS uses
the same set of lock words for the address as the kernel-side futex CAS. Those
lock words are 16-byte aligned because only load-and-clear-word (ldcw) exists
on parisc and requires the extra alignment for the hardware atomicity to hold.

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

  parent reply	other threads:[~2022-08-30 14:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30  7:30 [Bug libc/29537] New: " glaubitz at physik dot fu-berlin.de
2022-08-30  7:44 ` [Bug libc/29537] " glaubitz at physik dot fu-berlin.de
2022-08-30  7:49 ` dilfridge at gentoo dot org
2022-08-30  7:55 ` chewi at gentoo dot org
2022-08-30  9:15 ` glaubitz at physik dot fu-berlin.de
2022-08-30 13:18 ` adhemerval.zanella at linaro dot org
2022-08-30 14:16 ` carlos at redhat dot com [this message]
2022-08-30 14:33 ` schwab@linux-m68k.org
2022-08-30 14:35 ` adhemerval.zanella at linaro dot org
2022-08-30 15:01 ` carlos at redhat dot com
2022-08-30 15:58 ` sam at gentoo dot org
2022-09-02 10:31 ` dilfridge at gentoo dot org
2022-09-16 15:39 ` danglin at gcc dot gnu.org
2022-09-20 16:48 ` adhemerval.zanella at linaro dot org
2022-09-21  9:43 ` glaubitz at physik dot fu-berlin.de
2022-09-21 13:47 ` adhemerval.zanella at linaro dot org

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-29537-131-5DLdmXoFzy@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).