nptl: Decorate thread stack on pthread_create
commit6afce56c197ee83520994a2c94a82c2ca2bce9fa
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 1 Nov 2023 12:56:07 +0000 (1 09:56 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 7 Nov 2023 13:27:20 +0000 (7 10:27 -0300)
tree973adf10b4992c1440fc3c4352165f599747474b
parented318beab986c6f6ccf2507d4753dfea6a7b1f8d
nptl: Decorate thread stack on pthread_create

Linux 4.5 removed thread stack annotations due to the complexity of
computing them [1], and Linux added PR_SET_VMA_ANON_NAME on 5.17
as a way to name anonymous virtual memory areas.

This patch adds decoration on the stack created and used by
pthread_create, for glibc crated thread stack the /proc/self/maps will
now show:

  [anon: glibc: pthread stack: <tid>]

And for user-provided stacks:

  [anon: glibc: pthread user stack: <tid>]

The guard page is not decorated, and the mapping name is cleared when
the thread finishes its execution (so the cached stack does not have any
name associated).

Checked on x86_64-linux-gnu aarch64 aarch64-linux-gnu.

[1] https://github.com/torvalds/linux/commit/65376df582174ffcec9e6471bf5b0dd79ba05e4a

Co-authored-by: Ian Rogers <irogers@google.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
elf/Makefile
elf/tst-decorate-maps.c [new file with mode: 0644]
nptl/allocatestack.c
nptl/pthread_create.c