From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 411913857C4E for ; Mon, 5 Oct 2020 19:15:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 411913857C4E Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 095J1DHT043316 for ; Mon, 5 Oct 2020 15:15:03 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3408my1gkg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 05 Oct 2020 15:15:03 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 095JAKgl085767 for ; Mon, 5 Oct 2020 15:15:03 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0b-001b2d01.pphosted.com with ESMTP id 3408my1gk7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Oct 2020 15:15:03 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 095J7EME015963; Mon, 5 Oct 2020 19:15:02 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma02wdc.us.ibm.com with ESMTP id 33xgx99ufp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Oct 2020 19:15:02 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 095JF2oX16580878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Oct 2020 19:15:02 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D7EEAC060; Mon, 5 Oct 2020 19:15:02 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2ABA3AC064; Mon, 5 Oct 2020 19:15:02 +0000 (GMT) Received: from li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com (unknown [9.85.135.246]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTPS; Mon, 5 Oct 2020 19:15:02 +0000 (GMT) Date: Mon, 5 Oct 2020 14:15:00 -0500 From: "Paul A. Clarke" To: Florian Weimer Cc: libc-alpha@sourceware.org Message-ID: <20201005191500.GA69013@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com> References: <01faff4932d02c7e3224b50a1cdb5956354b1fc2.1601569371.git.fweimer@redhat.com> <20201001185639.GA132840@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com> <87ft6txavf.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ft6txavf.fsf@oldenburg2.str.redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-TM-AS-GCONF: 00 Subject: RE: [PATCH 18/28] powerpc64le: Add glibc-hwcaps support X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-10-05_14:2020-10-05, 2020-10-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 clxscore=1015 mlxscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2010050135 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Oct 2020 19:15:05 -0000 On Mon, Oct 05, 2020 at 11:47:32AM +0200, Florian Weimer wrote: > * Paul A. Clarke: > >> diff --git a/sysdeps/powerpc/powerpc64/le/dl-hwcaps-subdirs.c b/sysdeps/powerpc/powerpc64/le/dl-hwcaps-subdirs.c > >> new file mode 100644 > >> index 0000000000..496daf0fa0 > >> --- /dev/null > >> +++ b/sysdeps/powerpc/powerpc64/le/dl-hwcaps-subdirs.c [...snip...] > >> +_dl_hwcaps_subdirs_active (void) > >> +{ > >> + if (GLRO (dl_hwcap2) & PPC_FEATURE2_ARCH_3_1) > >> + return 3; > >> + > >> + if (GLRO (dl_hwcap2) & PPC_FEATURE2_ARCH_3_00) > >> + return 1; > > > > Is there some way to tie these magic numbers closer to their meaning? > > Would you please have a look at the the x86-64 implementation and check > if it is closer to your liking? A bit. I am concerned about the opaqueness of the interface. The x86 code basically does: > int32_t result = 0; > int32_t bit = 1 << 2; > if (...) > return result; > result |= bit; > bit >>= 1; > if (...) > return result; > result |= bit; > bit >>= 1; > if (...) > return result; > result |= bit; > bit >>= 1; > return result; ...which still creates magic numbers and really doesn't explain what the result represents. The entire API is documented in a 2-line comment before count_hwcaps(). For someone to update the implementation for a new hwcap, which will need to be done fairly often, seems to me to be a bit challenging for the uninitiated (like me ;-). > > Perhaps something like (not tested): > > -- > > const char * const _dl_hwcaps_subdirs[] = { > > #define _DL_HWCAPS_SUBDIR_POWER10_BIT 0x2 /* or 1 to preserve same order. */ > > "power10", > > #define _DL_HWCAPS_SUBDIR_POWER9_BIT 0x1 /* or 2. */ > > "power9" > > }; > > > > int32_t > > _dl_hwcaps_subdirs_active (void) > > { > > int32_t result = 0; > > > > if (GLRO (dl_hwcap2) & PPC_FEATURE2_ARCH_3_1) > > result |= _DL_HWCAPS_SUBDIR_POWER10_BIT; > > > > if (GLRO (dl_hwcap2) & PPC_FEATURE2_ARCH_3_00) > > result |= _DL_HWCAPS_SUBDIR_POWER9_BIT; > > > > return result; > > } > > -- > > > > Of course, that would require changes to the code that parses > > _dl_hwcaps_subdirs. > > I chose the current approach to avoid relocations and memory allocations > for processing hwcaps settings (e.g. from the ld.so command line). Does the "array of strings" approach introduce new/additional relocations and memory allocations? It would seem to avoid the need for the splitting code, at least. PC