public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Torvald Riegel <triegel@redhat.com>
To: Andreas Larsson <andreas@gaisler.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	"Carlos O'Donell" <carlos@redhat.com>,
	David Miller <davem@davemloft.net>,
	software@gaisler.com
Subject: Re: [RFC][PATCH 0/2] Make sparcv8 work again on cas enabled hardware
Date: Tue, 01 Nov 2016 16:00:00 -0000	[thread overview]
Message-ID: <1478015984.7146.645.camel@localhost.localdomain> (raw)
In-Reply-To: <1478012867-6031-1-git-send-email-andreas@gaisler.com>

On Tue, 2016-11-01 at 16:07 +0100, Andreas Larsson wrote:
> This patch series:
> 
> 1) Fixes a sparcv8 bug introduced since the #error was added to
> sysdeps/sparc/sparc32/pthread_barrier_wait.c in 2.23. This fix stops
> incorrect usage of sendmsg and recvmsg Linux system calls for sparcv8.

I don't know whether the changes this patch applies make sense, but
otherwise the patch looks okay to me.  This could also be a separate
patch I think.

Do you have a copyright assignment in place for glibc?

> 2) Makes use of the CASA compare and swap instruction for atomic_*
> functions sparcv8, that is available for most LEON3 and LEON4 designs
> and implied by -mcpu=leon3, but not part of the sparcv8 standard. To
> allow for easy kernel emulation on systems that lack the instruction,
> the CASA instruction is used for all writing atomic_* functions. This
> approach is discussed in thread [1].

Before I can review the patch in detail, I think there are a few
high-level things that need to be taken care of.

We need to document what sparc32 systems we actually support.  Your
patch looks like for now, CAS is required.  If this is true, this should
be documented (e.g., I guess this would need a NEWS item too).

Is there a way to test this new requirement at build time, or is this
just a runtime requirement?  If this is a build-time requirement, is the
assembler actually already aware that it can use a CAS (which would
remove the need to hand-code the instruction).

If we require CAS, the 24b exchanges should just be removed altogether;
it seems the only remaining user is the low-level lock.

I don't think you need to make all modifying atomic accesses use a CAS
underneath, at least if we require CAS.  If we will also allow for
kernel emulation in the future, it would also be possible to check
whether emulation is required and only then route all modifying accesses
through the kernel.

In the future, we will most likely require 8b atomic loads and stores
(perhaps we can do without an 8b CAS, though doing that with a 32b cas
is possible).

I suggest to also look at whether you can use the new __atomic builtins
(ie, as noted by the USE_ATOMIC_COMPILER_BUILTINS define).  On the sparc
systems that we want to support, will GCC do the right thing for CAS
etc. (eg, if the requirement is to build with -mcpu=leon3)?  In
particular, will it either always emit a CAS instruction or will
libatomic use a CAS instruction?
If so, you could also just rely on the new atomic builtins and define
the legacy atomic operations (ie, those not in C11 style) on top of
those. 

> Any comments are most welcome. The spin lock based sparcv8 semaphore
> implementation is currently unchanged by this patchset, but I would say
> that that should go as well.

Agreed.

  parent reply	other threads:[~2016-11-01 16:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-01 15:08 Andreas Larsson
2016-11-01 15:08 ` [RFC][PATCH 1/2] sparc32: Mark sendmsg and recvmsg system calls as unsupported Andreas Larsson
2016-11-01 17:28   ` Adhemerval Zanella
2016-11-02 11:38     ` Andreas Larsson
2016-11-02 12:49       ` Adhemerval Zanella
2016-11-04 18:36   ` David Miller
2016-11-01 15:08 ` [RFC][PATCH 2/2] sparc32: Use cas for atomic_* operations and use general pthread_barrier_wait Andreas Larsson
2016-11-04 18:37   ` David Miller
2016-11-04 18:44     ` David Miller
2016-11-01 16:00 ` Torvald Riegel [this message]
2016-11-01 16:09   ` [RFC][PATCH 0/2] Make sparcv8 work again on cas enabled hardware David Miller
2016-11-01 16:46     ` Torvald Riegel
2016-11-01 16:51       ` David Miller
2016-11-02 10:05         ` Torvald Riegel
2016-11-02 11:29           ` Andreas Larsson
2016-11-02 15:32           ` David Miller
2016-11-02 22:33             ` Torvald Riegel
2016-11-03  2:52               ` David Miller
2016-11-03 15:39                 ` Torvald Riegel
2016-11-03 17:22                   ` David Miller
2016-11-03 18:41                     ` Adhemerval Zanella
2016-11-03 20:33                       ` David Miller
2016-11-03 21:29                         ` Adhemerval Zanella
2016-11-03 22:25                         ` Torvald Riegel
2016-11-04 10:28                     ` Andreas Larsson
2016-11-04 15:23                       ` David Miller
2016-11-04 13:55                     ` Richard Henderson
2016-11-04 15:31                       ` David Miller
2016-11-04 16:10                         ` Richard Henderson
2016-11-04 14:04                     ` Richard Henderson

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=1478015984.7146.645.camel@localhost.localdomain \
    --to=triegel@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=andreas@gaisler.com \
    --cc=carlos@redhat.com \
    --cc=davem@davemloft.net \
    --cc=libc-alpha@sourceware.org \
    --cc=software@gaisler.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.
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).