From patchwork Thu Mar 9 15:57:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul A. Clarke" X-Patchwork-Id: 19500 X-Patchwork-Delegate: vapier@gentoo.org Received: (qmail 64571 invoked by alias); 9 Mar 2017 15:57:20 -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 64549 invoked by uid 89); 9 Mar 2017 15:57:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=le X-HELO: mx0a-001b2d01.pphosted.com Reply-To: pc@us.ibm.com To: libc-alpha@sourceware.org From: Paul Clarke Subject: [PATCH] powerpc: Support auxilliary vector components for cache geometries Date: Thu, 9 Mar 2017 09:57:06 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17030915-0036-0000-0000-0000019C3A77 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006751; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00832232; UDB=6.00408400; IPR=6.00609820; BA=6.00005202; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014578; XFM=3.00000013; UTC=2017-03-09 15:57:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030915-0037-0000-0000-00003EB9F09D Message-Id: <09eaab05-8cfe-a800-a033-750a02e417a5@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-09_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703090118 Use getauxval() to get L1, L2, L3 cache sizes, cache line sizes, and cache associativities. The new types for getauxval() were added in the stream for Linux kernel v4.11 in commit 98a5f361b8625c6f4841d6ba013bbf0e80d08147. Add test case which retrieves above values using getauxval(). * elf/elf.h: Add auxvec identifiers from kernel arch/powerpc/include/uapi/asm/auxvec.h. * glibc/sysdeps/powerpc/tst-getauxval.c: New test to retrieve new auxvec values. * glibc/sysdeps/powerpc/Makefile (tests): Add tst-getauxval. --- elf/elf.h | 12 ++++++ sysdeps/powerpc/Makefile | 1 + sysdeps/powerpc/tst-getauxval.c | 86 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 sysdeps/powerpc/tst-getauxval.c diff --git a/elf/elf.h b/elf/elf.h index 6d3b356..fff893d 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -1170,6 +1170,18 @@ typedef struct #define AT_L2_CACHESHAPE 36 #define AT_L3_CACHESHAPE 37 +/* Shapes of the caches, with more room to describe them. + *GEOMETRY are comprised of cache line size in bytes in the bottom 16 bits + and the cache associativity in the next 16 bits. */ +#define AT_L1I_CACHESIZE 40 +#define AT_L1I_CACHEGEOMETRY 41 +#define AT_L1D_CACHESIZE 42 +#define AT_L1D_CACHEGEOMETRY 43 +#define AT_L2_CACHESIZE 44 +#define AT_L2_CACHEGEOMETRY 45 +#define AT_L3_CACHESIZE 46 +#define AT_L3_CACHEGEOMETRY 47 + /* Note section contents. Each entry in the note section begins with a header of a fixed form. */ diff --git a/sysdeps/powerpc/Makefile b/sysdeps/powerpc/Makefile index 933810f..5f10f68 100644 --- a/sysdeps/powerpc/Makefile +++ b/sysdeps/powerpc/Makefile @@ -35,6 +35,7 @@ ifeq ($(subdir),misc) sysdep_headers += sys/platform/ppc.h tests += test-gettimebase tests += tst-set_ppr +tests += tst-getauxval endif ifneq (,$(filter %le,$(config-machine))) diff --git a/sysdeps/powerpc/tst-getauxval.c b/sysdeps/powerpc/tst-getauxval.c new file mode 100644 index 0000000..1f5e9f0 --- /dev/null +++ b/sysdeps/powerpc/tst-getauxval.c @@ -0,0 +1,86 @@ +/* Test the implementation of getauxval functions for + cache size, cache line size, and associativity for L1, L2, L3 caches. + + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +#include + +static int +do_test (void) +{ + int rc = 0; + unsigned long val; + val = getauxval (AT_L1I_CACHESIZE); + if (val) + printf("AT_L1I_CACHESIZE: %ld (0x%lx)\n",val,val); + else + rc = EXIT_UNSUPPORTED; + + val = getauxval (AT_L1I_CACHEGEOMETRY); + if (val) + printf("AT_L1I_CACHEGEOMETRY: associativity %ld; line size %ld\n", + (val & 0xffff0000) >> 16, val & 0x0000ffff); + else + rc = EXIT_UNSUPPORTED; + + val = getauxval (AT_L1D_CACHESIZE); + if (val) + printf("AT_L1D_CACHESIZE: %ld (0x%lx)\n",val,val); + else + rc = EXIT_UNSUPPORTED; + + val = getauxval (AT_L1D_CACHEGEOMETRY); + if (val) + printf("AT_L1D_CACHEGEOMETRY: associativity %ld; line size %ld\n", + (val & 0xffff0000) >> 16, val & 0x0000ffff); + else + rc = EXIT_UNSUPPORTED; + + val = getauxval (AT_L2_CACHESIZE); + if (val) + printf("AT_L2_CACHESIZE: %ld (0x%lx)\n",val,val); + else + rc = EXIT_UNSUPPORTED; + + val = getauxval (AT_L2_CACHEGEOMETRY); + if (val) + printf("AT_L2_CACHEGEOMETRY: associativity %ld; line size %ld\n", + (val & 0xffff0000) >> 16, val & 0x0000ffff); + else + rc = EXIT_UNSUPPORTED; + + val = getauxval (AT_L3_CACHESIZE); + if (val) + printf("AT_L3_CACHESIZE: %ld (0x%lx)\n",val,val); + else + rc = EXIT_UNSUPPORTED; + + val = getauxval (AT_L3_CACHEGEOMETRY); + if (val) + printf("AT_L3_CACHEGEOMETRY: associativity %ld; line size %ld\n", + (val & 0xffff0000) >> 16, val & 0x0000ffff); + else + rc = EXIT_UNSUPPORTED; + + return rc; +} + +#include