[0/5] Architecture code cleanup

Message ID 20211216194222.186992-1-adhemerval.zanella@linaro.org
Headers
Series Architecture code cleanup |

Message

Adhemerval Zanella Netto Dec. 16, 2021, 7:42 p.m. UTC
  These cleanups come from reviewing the OpenRISC submission.  The
tcb-offset.h is used mostly on setjmp/longjmp implementation to
provide pointer mangle/demangle, but most ports do not use its
definition (it should speed up a bit the build process).

The libmemusage requires duplicate definition and adds a lot of
boilerplate code: its internal atomics can be replaces by
C11 atomics, which allows remove a lof of atomic-machine.h
internal types; the internal time can be replaced with hp-timing.h,
and for stack pointer information we can use either the
__thread_stack_pointer (hurd) or CURRENT_STACK_FRAME (Linux).

Adhemerval Zanella (5):
  Remove ununsed tcb-offset
  malloc: Use C11 atomics on libmemusage
  Remove atomic-machine.h boilerplates definition
  malloc: Use hp-timing on libmemusage
  malloc: Remove memusage.h

 malloc/memusage.c                             | 65 +++++++++++--------
 sysdeps/aarch64/atomic-machine.h              | 17 -----
 sysdeps/aarch64/memusage.h                    | 21 ------
 sysdeps/aarch64/nptl/Makefile                 | 21 ------
 sysdeps/aarch64/nptl/tcb-offsets.sym          |  6 --
 sysdeps/aarch64/nptl/tls.h                    |  3 -
 sysdeps/alpha/atomic-machine.h                | 27 +-------
 sysdeps/alpha/memusage.h                      | 20 ------
 sysdeps/alpha/nptl/Makefile                   | 20 ------
 sysdeps/alpha/nptl/tcb-offsets.sym            | 13 ----
 sysdeps/alpha/nptl/tls.h                      |  2 -
 sysdeps/arc/atomic-machine.h                  | 12 ----
 sysdeps/arc/memusage.h                        | 23 -------
 sysdeps/arc/nptl/Makefile                     | 22 -------
 sysdeps/arc/nptl/tcb-offsets.sym              | 11 ----
 sysdeps/arm/atomic-machine.h                  | 17 -----
 sysdeps/arm/memusage.h                        | 20 ------
 sysdeps/arm/nptl/Makefile                     |  4 --
 sysdeps/arm/nptl/tcb-offsets.sym              | 10 ---
 sysdeps/arm/nptl/tls.h                        |  3 -
 sysdeps/csky/Makefile                         |  4 --
 sysdeps/csky/atomic-machine.h                 | 10 ---
 sysdeps/csky/memusage.h                       | 21 ------
 sysdeps/csky/nptl/Makefile                    | 20 ------
 sysdeps/csky/nptl/tcb-offsets.sym             | 10 ---
 sysdeps/csky/nptl/tls.h                       |  1 -
 sysdeps/generic/memusage.h                    | 51 ---------------
 sysdeps/hppa/memusage.h                       | 21 ------
 sysdeps/hppa/nptl/Makefile                    | 20 ------
 sysdeps/hppa/nptl/tcb-offsets.sym             | 17 -----
 sysdeps/hppa/nptl/tls.h                       |  3 -
 sysdeps/i386/htl/machine-sp.h                 |  2 +-
 sysdeps/i386/i586/memusage.h                  |  1 -
 sysdeps/i386/memusage.h                       | 20 ------
 sysdeps/ia64/atomic-machine.h                 | 26 --------
 sysdeps/ia64/memusage.h                       | 29 ---------
 sysdeps/m68k/coldfire/atomic-machine.h        | 31 ---------
 sysdeps/m68k/m680x0/m68020/atomic-machine.h   | 28 --------
 sysdeps/m68k/memusage.h                       | 21 ------
 sysdeps/m68k/nptl/Makefile                    | 20 ------
 sysdeps/m68k/nptl/tcb-offsets.sym             | 10 ---
 sysdeps/m68k/nptl/tls.h                       |  3 -
 sysdeps/mach/hurd/i386/tls.h                  |  1 -
 sysdeps/mach/i386/machine-sp.h                |  2 +-
 sysdeps/microblaze/atomic-machine.h           | 17 -----
 sysdeps/microblaze/memusage.h                 | 21 ------
 sysdeps/microblaze/nptl/Makefile              | 21 ------
 sysdeps/microblaze/nptl/tcb-offsets.sym       | 10 ---
 sysdeps/microblaze/nptl/tls.h                 |  3 -
 sysdeps/mips/atomic-machine.h                 | 17 -----
 sysdeps/mips/memusage.h                       | 20 ------
 sysdeps/mips/nptl/Makefile                    | 20 ------
 sysdeps/mips/nptl/tcb-offsets.sym             | 10 ---
 sysdeps/mips/nptl/tls.h                       |  2 -
 sysdeps/nios2/Makefile                        |  4 --
 sysdeps/nios2/memusage.h                      | 23 -------
 sysdeps/powerpc/atomic-machine.h              | 17 -----
 sysdeps/powerpc/memusage.h                    | 20 ------
 sysdeps/riscv/memusage.h                      | 21 ------
 sysdeps/riscv/nptl/Makefile                   | 21 ------
 sysdeps/riscv/nptl/tcb-offsets.sym            |  6 --
 sysdeps/s390/atomic-machine.h                 | 27 --------
 sysdeps/s390/memusage.h                       | 20 ------
 sysdeps/sh/memusage.h                         | 20 ------
 sysdeps/sparc/atomic-machine.h                | 27 --------
 sysdeps/sparc/memusage.h                      | 20 ------
 sysdeps/unix/sysv/linux/hppa/atomic-machine.h | 17 -----
 .../sysv/linux/m68k/coldfire/atomic-machine.h | 11 ----
 .../sysv/linux/machine-sp.h}                  | 16 +++--
 .../unix/sysv/linux/nios2/atomic-machine.h    | 12 ----
 .../unix/sysv/linux/riscv/atomic-machine.h    | 13 ----
 sysdeps/unix/sysv/linux/sh/atomic-machine.h   | 28 --------
 sysdeps/x86/atomic-machine.h                  | 40 ++----------
 sysdeps/x86_64/memusage.h                     | 21 ------
 74 files changed, 60 insertions(+), 1174 deletions(-)
 delete mode 100644 sysdeps/aarch64/memusage.h
 delete mode 100644 sysdeps/aarch64/nptl/Makefile
 delete mode 100644 sysdeps/aarch64/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/alpha/memusage.h
 delete mode 100644 sysdeps/alpha/nptl/Makefile
 delete mode 100644 sysdeps/alpha/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/arc/memusage.h
 delete mode 100644 sysdeps/arc/nptl/Makefile
 delete mode 100644 sysdeps/arc/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/arm/memusage.h
 delete mode 100644 sysdeps/arm/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/csky/memusage.h
 delete mode 100644 sysdeps/csky/nptl/Makefile
 delete mode 100644 sysdeps/csky/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/generic/memusage.h
 delete mode 100644 sysdeps/hppa/memusage.h
 delete mode 100644 sysdeps/hppa/nptl/Makefile
 delete mode 100644 sysdeps/hppa/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/i386/i586/memusage.h
 delete mode 100644 sysdeps/i386/memusage.h
 delete mode 100644 sysdeps/ia64/memusage.h
 delete mode 100644 sysdeps/m68k/memusage.h
 delete mode 100644 sysdeps/m68k/nptl/Makefile
 delete mode 100644 sysdeps/m68k/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/microblaze/memusage.h
 delete mode 100644 sysdeps/microblaze/nptl/Makefile
 delete mode 100644 sysdeps/microblaze/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/mips/memusage.h
 delete mode 100644 sysdeps/mips/nptl/Makefile
 delete mode 100644 sysdeps/mips/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/nios2/memusage.h
 delete mode 100644 sysdeps/powerpc/memusage.h
 delete mode 100644 sysdeps/riscv/memusage.h
 delete mode 100644 sysdeps/riscv/nptl/Makefile
 delete mode 100644 sysdeps/riscv/nptl/tcb-offsets.sym
 delete mode 100644 sysdeps/s390/memusage.h
 delete mode 100644 sysdeps/sh/memusage.h
 delete mode 100644 sysdeps/sparc/memusage.h
 rename sysdeps/{i386/i686/memusage.h => unix/sysv/linux/machine-sp.h} (68%)
 delete mode 100644 sysdeps/x86_64/memusage.h
  

Comments

Joseph Myers Dec. 16, 2021, 9:41 p.m. UTC | #1
On Thu, 16 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:

> The libmemusage requires duplicate definition and adds a lot of
> boilerplate code: its internal atomics can be replaces by
> C11 atomics, which allows remove a lof of atomic-machine.h
> internal types; the internal time can be replaced with hp-timing.h,
> and for stack pointer information we can use either the
> __thread_stack_pointer (hurd) or CURRENT_STACK_FRAME (Linux).

Has this patch series been tested with build-many-glibcs.py?  (I'm 
concerned with making sure the atomics aren't introducing any circular 
dependencies on libatomic - that they're expanded entirely inline or to 
use libgcc operations.)
  
Adhemerval Zanella Netto Dec. 16, 2021, 11:08 p.m. UTC | #2
On 16/12/2021 18:41, Joseph Myers wrote:
> On Thu, 16 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:
> 
>> The libmemusage requires duplicate definition and adds a lot of
>> boilerplate code: its internal atomics can be replaces by
>> C11 atomics, which allows remove a lof of atomic-machine.h
>> internal types; the internal time can be replaced with hp-timing.h,
>> and for stack pointer information we can use either the
>> __thread_stack_pointer (hurd) or CURRENT_STACK_FRAME (Linux).
> 
> Has this patch series been tested with build-many-glibcs.py?  (I'm 
> concerned with making sure the atomics aren't introducing any circular 
> dependencies on libatomic - that they're expanded entirely inline or to 
> use libgcc operations.)
> 

The C11 usage is for the types, memusage.c still uses catomic_* functions
(which it is not optimal).  My plan is to clean this up later patch.
  
Adhemerval Zanella Netto Dec. 16, 2021, 11:35 p.m. UTC | #3
On 16/12/2021 20:08, Adhemerval Zanella wrote:
> 
> 
> On 16/12/2021 18:41, Joseph Myers wrote:
>> On Thu, 16 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:
>>
>>> The libmemusage requires duplicate definition and adds a lot of
>>> boilerplate code: its internal atomics can be replaces by
>>> C11 atomics, which allows remove a lof of atomic-machine.h
>>> internal types; the internal time can be replaced with hp-timing.h,
>>> and for stack pointer information we can use either the
>>> __thread_stack_pointer (hurd) or CURRENT_STACK_FRAME (Linux).
>>
>> Has this patch series been tested with build-many-glibcs.py?  (I'm 
>> concerned with making sure the atomics aren't introducing any circular 
>> dependencies on libatomic - that they're expanded entirely inline or to 
>> use libgcc operations.)
>>
> 
> The C11 usage is for the types, memusage.c still uses catomic_* functions
> (which it is not optimal).  My plan is to clean this up later patch.

Scratch that, I just realized that did use _Atomic. I will check with
build-many-glibcs.py.
  
Adhemerval Zanella Netto Dec. 17, 2021, 11:10 a.m. UTC | #4
On 16/12/2021 20:35, Adhemerval Zanella wrote:
> 
> 
> On 16/12/2021 20:08, Adhemerval Zanella wrote:
>>
>>
>> On 16/12/2021 18:41, Joseph Myers wrote:
>>> On Thu, 16 Dec 2021, Adhemerval Zanella via Libc-alpha wrote:
>>>
>>>> The libmemusage requires duplicate definition and adds a lot of
>>>> boilerplate code: its internal atomics can be replaces by
>>>> C11 atomics, which allows remove a lof of atomic-machine.h
>>>> internal types; the internal time can be replaced with hp-timing.h,
>>>> and for stack pointer information we can use either the
>>>> __thread_stack_pointer (hurd) or CURRENT_STACK_FRAME (Linux).
>>>
>>> Has this patch series been tested with build-many-glibcs.py?  (I'm 
>>> concerned with making sure the atomics aren't introducing any circular 
>>> dependencies on libatomic - that they're expanded entirely inline or to 
>>> use libgcc operations.)
>>>
>>
>> The C11 usage is for the types, memusage.c still uses catomic_* functions
>> (which it is not optimal).  My plan is to clean this up later patch.
> 
> Scratch that, I just realized that did use _Atomic. I will check with
> build-many-glibcs.py.

It does pass on handful of architecture that might use libatomic, but thinking
again it does seems the best strategy to use C11 atomics while issuing glibc
handcrafted atomic functions/macros.  I will just replace with plain [u]intXX_t
types, since it is what we usually do in other places.