From patchwork Fri Nov 30 19:29:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tulio Magno Quites Machado Filho X-Patchwork-Id: 30481 X-Patchwork-Delegate: fweimer@redhat.com Received: (qmail 20682 invoked by alias); 30 Nov 2018 19:31:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 20292 invoked by uid 89); 30 Nov 2018 19:30:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=unavailable version=3.3.2 spammy=geometry, lub, gid X-HELO: mx0a-001b2d01.pphosted.com From: Tulio Magno Quites Machado Filho To: libc-alpha@sourceware.org Subject: [PATCH] Print cache size and geometry auxv types on LD_SHOW_AUXV=1 Date: Fri, 30 Nov 2018 17:29:46 -0200 x-cbid: 18113019-0036-0000-0000-00000A63AA2E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010148; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01125066; UDB=6.00584181; IPR=6.00905194; MB=3.00024399; MTD=3.00000008; XFM=3.00000015; UTC=2018-11-30 19:30:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18113019-0037-0000-0000-000049D0FE85 Message-Id: <20181130192946.17918-1-tuliom@linux.ibm.com> Add support for AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY, AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE, AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE and AT_L3_CACHEGEOMETRY when LD_SHOW_AUXV=1. AT_L*_CACHESIZE is printed as decimal and represent the number of bytes of the cache. AT_L*_CACHEGEOMETRY is treated in order to specify the cache line size and its associativity. Example output from a POWER8: AT_L1I_CACHESIZE: 32768 AT_L1I_CACHEGEOMETRY: 128B line size, 8-way set associative AT_L1D_CACHESIZE: 65536 AT_L1D_CACHEGEOMETRY: 128B line size, 8-way set associative AT_L2_CACHESIZE: 524288 AT_L2_CACHEGEOMETRY: 128B line size, 8-way set associative AT_L3_CACHESIZE: 8388608 AT_L3_CACHEGEOMETRY: 128B line size, 8-way set associative Some of the new types are longer than the previous ones, requiring to increase the indentation in order to keep the values aligned. 2018-11-30 Tulio Magno Quites Machado Filho * elf/dl-sysdep.c (auxvars): Add AT_L1I_CACHESIZE, AT_L1I_CACHEGEOMETRY, AT_L1D_CACHESIZE, AT_L1D_CACHEGEOMETRY, AT_L2_CACHESIZE, AT_L2_CACHEGEOMETRY, AT_L3_CACHESIZE and AT_L3_CACHEGEOMETRY. Fix indentation when printing the other fields. (_dl_show_auxv): Give a special treatment to AT_L1I_CACHEGEOMETRY, AT_L1D_CACHEGEOMETRY, AT_L2_CACHEGEOMETRY and AT_L3_CACHEGEOMETRY. * sysdeps/powerpc/dl-procinfo.h (cache_geometry): New function. (_dl_procinfo): Fix indentation when printing AT_HWCAP and AT_HWCAP2. Add support for AT_L1I_CACHEGEOMETRY, AT_L1D_CACHEGEOMETRY, AT_L2_CACHEGEOMETRY and AT_L3_CACHEGEOMETRY. Signed-off-by: Tulio Magno Quites Machado Filho --- elf/dl-sysdep.c | 68 +++++++++++++++++++++++++------------------ sysdeps/powerpc/dl-procinfo.h | 55 ++++++++++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 31 deletions(-) diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c index 998c5d52bc..939832517e 100644 --- a/elf/dl-sysdep.c +++ b/elf/dl-sysdep.c @@ -277,38 +277,46 @@ _dl_show_auxv (void) { static const struct { - const char label[17]; + const char label[22]; enum { unknown = 0, dec, hex, str, ignore } form : 8; } auxvars[] = { - [AT_EXECFD - 2] = { "EXECFD: ", dec }, - [AT_EXECFN - 2] = { "EXECFN: ", str }, - [AT_PHDR - 2] = { "PHDR: 0x", hex }, - [AT_PHENT - 2] = { "PHENT: ", dec }, - [AT_PHNUM - 2] = { "PHNUM: ", dec }, - [AT_PAGESZ - 2] = { "PAGESZ: ", dec }, - [AT_BASE - 2] = { "BASE: 0x", hex }, - [AT_FLAGS - 2] = { "FLAGS: 0x", hex }, - [AT_ENTRY - 2] = { "ENTRY: 0x", hex }, - [AT_NOTELF - 2] = { "NOTELF: ", hex }, - [AT_UID - 2] = { "UID: ", dec }, - [AT_EUID - 2] = { "EUID: ", dec }, - [AT_GID - 2] = { "GID: ", dec }, - [AT_EGID - 2] = { "EGID: ", dec }, - [AT_PLATFORM - 2] = { "PLATFORM: ", str }, - [AT_HWCAP - 2] = { "HWCAP: ", hex }, - [AT_CLKTCK - 2] = { "CLKTCK: ", dec }, - [AT_FPUCW - 2] = { "FPUCW: ", hex }, - [AT_DCACHEBSIZE - 2] = { "DCACHEBSIZE: 0x", hex }, - [AT_ICACHEBSIZE - 2] = { "ICACHEBSIZE: 0x", hex }, - [AT_UCACHEBSIZE - 2] = { "UCACHEBSIZE: 0x", hex }, + [AT_EXECFD - 2] = { "EXECFD: ", dec }, + [AT_EXECFN - 2] = { "EXECFN: ", str }, + [AT_PHDR - 2] = { "PHDR: 0x", hex }, + [AT_PHENT - 2] = { "PHENT: ", dec }, + [AT_PHNUM - 2] = { "PHNUM: ", dec }, + [AT_PAGESZ - 2] = { "PAGESZ: ", dec }, + [AT_BASE - 2] = { "BASE: 0x", hex }, + [AT_FLAGS - 2] = { "FLAGS: 0x", hex }, + [AT_ENTRY - 2] = { "ENTRY: 0x", hex }, + [AT_NOTELF - 2] = { "NOTELF: ", hex }, + [AT_UID - 2] = { "UID: ", dec }, + [AT_EUID - 2] = { "EUID: ", dec }, + [AT_GID - 2] = { "GID: ", dec }, + [AT_EGID - 2] = { "EGID: ", dec }, + [AT_PLATFORM - 2] = { "PLATFORM: ", str }, + [AT_HWCAP - 2] = { "HWCAP: ", hex }, + [AT_CLKTCK - 2] = { "CLKTCK: ", dec }, + [AT_FPUCW - 2] = { "FPUCW: ", hex }, + [AT_DCACHEBSIZE - 2] = { "DCACHEBSIZE: 0x", hex }, + [AT_ICACHEBSIZE - 2] = { "ICACHEBSIZE: 0x", hex }, + [AT_UCACHEBSIZE - 2] = { "UCACHEBSIZE: 0x", hex }, [AT_IGNOREPPC - 2] = { "IGNOREPPC", ignore }, - [AT_SECURE - 2] = { "SECURE: ", dec }, - [AT_BASE_PLATFORM - 2] = { "BASE_PLATFORM:", str }, - [AT_SYSINFO - 2] = { "SYSINFO: 0x", hex }, - [AT_SYSINFO_EHDR - 2] = { "SYSINFO_EHDR: 0x", hex }, - [AT_RANDOM - 2] = { "RANDOM: 0x", hex }, - [AT_HWCAP2 - 2] = { "HWCAP2: 0x", hex }, + [AT_SECURE - 2] = { "SECURE: ", dec }, + [AT_BASE_PLATFORM - 2] = { "BASE_PLATFORM: ", str }, + [AT_SYSINFO - 2] = { "SYSINFO: 0x", hex }, + [AT_SYSINFO_EHDR - 2] = { "SYSINFO_EHDR: 0x", hex }, + [AT_RANDOM - 2] = { "RANDOM: 0x", hex }, + [AT_HWCAP2 - 2] = { "HWCAP2: 0x", hex }, + [AT_L1I_CACHESIZE - 2] = { "L1I_CACHESIZE: ", dec }, + [AT_L1I_CACHEGEOMETRY - 2] = { "L1I_CACHEGEOMETRY: 0x", hex }, + [AT_L1D_CACHESIZE - 2] = { "L1D_CACHESIZE: ", dec }, + [AT_L1D_CACHEGEOMETRY - 2] = { "L1D_CACHEGEOMETRY: 0x", hex }, + [AT_L2_CACHESIZE - 2] = { "L2_CACHESIZE: ", dec }, + [AT_L2_CACHEGEOMETRY - 2] = { "L2_CACHEGEOMETRY: 0x", hex }, + [AT_L3_CACHESIZE - 2] = { "L3_CACHESIZE: ", dec }, + [AT_L3_CACHEGEOMETRY - 2] = { "L3_CACHEGEOMETRY: 0x", hex }, }; unsigned int idx = (unsigned int) (av->a_type - 2); @@ -320,7 +328,9 @@ _dl_show_auxv (void) assert (AT_NULL == 0); assert (AT_IGNORE == 1); - if (av->a_type == AT_HWCAP || av->a_type == AT_HWCAP2) + if (av->a_type == AT_HWCAP || av->a_type == AT_HWCAP2 + || AT_L1I_CACHEGEOMETRY || AT_L1D_CACHEGEOMETRY + || AT_L2_CACHEGEOMETRY || AT_L3_CACHEGEOMETRY) { /* These are handled in a special way per platform. */ if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0) diff --git a/sysdeps/powerpc/dl-procinfo.h b/sysdeps/powerpc/dl-procinfo.h index 3803379ab2..34bf80de9f 100644 --- a/sysdeps/powerpc/dl-procinfo.h +++ b/sysdeps/powerpc/dl-procinfo.h @@ -147,6 +147,37 @@ _dl_string_platform (const char *str) } #if IS_IN (rtld) +static inline void +cache_geometry (const char * name, unsigned long int geometry) +{ + unsigned long int assocty, line; + + _dl_printf ("%s", name); + + line = geometry & 0xffff; + assocty = (geometry >> 16) & 0xffff; + + if (line == 0) + _dl_printf ("Unknown line size, "); + else + _dl_printf ("%luB line size, ", line); + + switch (assocty) + { + case 0: + _dl_printf ("Unknown associativity"); + break; + case 1: + _dl_printf ("Directly mapped"); + break; + case 0xffff: + _dl_printf ("Fully associative"); + break; + default: + _dl_printf ("%lu-way set associative", assocty); + } +} + static inline int __attribute__ ((unused)) _dl_procinfo (unsigned int type, unsigned long int word) @@ -154,7 +185,7 @@ _dl_procinfo (unsigned int type, unsigned long int word) switch(type) { case AT_HWCAP: - _dl_printf ("AT_HWCAP: "); + _dl_printf ("AT_HWCAP: "); for (int i = 0; i <= _DL_HWCAP_LAST; ++i) if (word & (1 << i)) @@ -164,7 +195,7 @@ _dl_procinfo (unsigned int type, unsigned long int word) { unsigned int offset = _DL_HWCAP_LAST + 1; - _dl_printf ("AT_HWCAP2: "); + _dl_printf ("AT_HWCAP2: "); /* We have to go through them all because the kernel added the AT_HWCAP2 features starting with the high bits. */ @@ -173,6 +204,26 @@ _dl_procinfo (unsigned int type, unsigned long int word) _dl_printf (" %s", _dl_hwcap_string (offset + i)); break; } + case AT_L1I_CACHEGEOMETRY: + { + cache_geometry ("AT_L1I_CACHEGEOMETRY: ", word); + break; + } + case AT_L1D_CACHEGEOMETRY: + { + cache_geometry ("AT_L1D_CACHEGEOMETRY: ", word); + break; + } + case AT_L2_CACHEGEOMETRY: + { + cache_geometry ("AT_L2_CACHEGEOMETRY: ", word); + break; + } + case AT_L3_CACHEGEOMETRY: + { + cache_geometry ("AT_L3_CACHEGEOMETRY: ", word); + break; + } default: /* This should not happen. */ return -1;