Message ID | 1504294850.3182.66.camel@cavium.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 88333 invoked by alias); 1 Sep 2017 19:41:04 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <libc-alpha.sourceware.org> List-Unsubscribe: <mailto:libc-alpha-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:libc-alpha-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 88252 invoked by uid 89); 1 Sep 2017 19:41:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: NAM03-CO1-obe.outbound.protection.outlook.com Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Steve.Ellcey@cavium.com; Message-ID: <1504294850.3182.66.camel@cavium.com> Subject: [PATCH][aarch64] Fix glibc.tune.cpu tunable handling From: Steve Ellcey <sellcey@cavium.com> Reply-To: sellcey@cavium.com To: libc-alpha <libc-alpha@sourceware.org> Date: Fri, 01 Sep 2017 12:40:50 -0700 Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MWHPR1601CA0015.namprd16.prod.outlook.com (10.172.93.25) To DM5PR07MB3547.namprd07.prod.outlook.com (10.164.153.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b1815d10-6b06-4ca5-a0b1-08d4f1715f02 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR07MB3547; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3547; 3:eq1zONaOC0RzSuTr8iN5fzjWcKeqlxj6z0Kelk82V26i3+cLV2oi8sotiZCEjWcPEGD1cXMleIbwd732q2f7u99YqktAY2eKK5hWOKHDHE06JyFx8oD0vaF7DJh3ppa/B5eKGfPde5O61f55dq+Ets+pdplYU0bGBWZd89sRsdidUI8tF4X1DZw7ifFj07JpfF1JH5YRGhe6x7AkIdJ1lseRhTCVZu15mKLDZ5XWqXxayeg3l9qPXh7630cP53Oq; 25:06OgmhHtm6DZH7W6pyBRPTfOUzJ2Sbslz6LAru5YArO239GQDvSNCZVyjd8qEDcWid9BTrUo8ahocB780vAhv20f/Msjfym5NJgLBkSB8Mfr/zTGDfhS62MR/c+HQ1jceGT4qzAjOEW7/lTqUl270LCtSEQZqC3e8nl6BJqWn377GRFRR1WVQt0YUOEhQdgTyFXGZLO5/0Xl1Ib9ikzipssFvEO4T9pj2KZU31fNA4reTRkGVvxwvvQU/4lnLZco0UA2oCBnFslv3BQOCCn3No+vwffS+bWrm2Hn/3HTg8h998W7qav8+t+7zZWWmHlxkUMOBfKts0zua+GYroB8Ww==; 31:MZSRybrPonetmhK3cMy9vgEAhtPQhsmZvkJY8qsanOPMjbRj3YdwQ3L3rgVSfpN6HdiOFFT5lFFcTH9T5dQQXQsJthD9seh+jH1KJJTi5cgzsoJ+gFkl31j5UajvL/D+PP8aN50tyH58984YwxAynw8kXDsRvxECdyqAoqhzZFELQu61GqG1gISffWN1OnpLCFEbW2VF1v+Dr7CsDLsU/lTEcFA4XxlEjJ3VVXZSZoQ= X-MS-TrafficTypeDiagnostic: DM5PR07MB3547: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3547; 20:KrLjSqPfHIkDRzMjiCfyYRKEdPVl9Xk9QTGABOAKFJT3MnhD3syK/L3i5Klyc9FMuhJZNNlIZ6G45g2A9LZnE1Ve2aBiuPOBHiNEh2BVMZjrpHR3+oW8b9cG2iXgceKMJiuso2R+UjYeuqaolP5Ib5OO+Wo51ukOqXd+5h0lAqOdqYp6bvUFaa62y+Jc5IGdt1bFfdgGnYNplkOy149TPtOatgf4c2S6LvzIPX8ppmZ1AQCz7z5zfTSWbvuOM2RrDg1auyXMFGhHVcfT1fYQ7ozw1rImqqn5khXl7VCw7Gqj3tsSmileEzR+31VhbQcYSsv3bfUrUMIMxvHupoJPjAN2Ihp6lK375Hn1OynxOzf6aA+Y1/2pDnu2bSLJ3LbF6BDyGTE4PaIptTsPH13/i9MQabQ2cTwk6eEFPGrnTYimHEvZw10B6zELMyAZSGrwbHdYJZSr613FEpUT4OJwo9DSeeO8k2Ru4yhzCfjmh4qmjlzxZiK1oANNvaDWtOPG; 4:59vE6h7Hoo4OuBJ5rzYYtXtdX6anPE6O0C93Zd9vizccUohJkKsKLq8yKKHWxgF0n93uTke0IVFy+sgurIUJvm2ezasqqoYgLQMid4SeqoB+hOcihwJRL1nvepn7HqZicrkUAVF1roniGwqxHteNZVcBaTAqerYUcdn8YdrVLnwYLooDKW4N0iMtwXQSISESZOsH0DtZpzu7iiKLKALf7t75ORiFwNWoZXjSxhkpLVXnmE4ZM0vPxBRdiW2GtIHe X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: <DM5PR07MB354774852576216D2D1A3327F5920@DM5PR07MB3547.namprd07.prod.outlook.com> X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3547; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3547; X-Forefront-PRVS: 0417A3FFD2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(377424004)(189002)(199003)(103116003)(72206003)(8936002)(25786009)(3450700001)(36756003)(66066001)(69596002)(43066003)(189998001)(23676002)(5820100001)(110136004)(478600001)(6512007)(97736004)(101416001)(50986999)(53936002)(3846002)(2906002)(6116002)(42186005)(50226002)(6916009)(53416004)(106356001)(81156014)(81166006)(105586002)(33646002)(68736007)(50466002)(6506006)(5660300001)(6666003)(47776003)(305945005)(6486002)(2870700001)(7736002)(8676002)(99106002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3547; H:sellcey-dt.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjA3TUIzNTQ3OzIzOjJPT3NHS1p3MG4xWklEK1pYQTNuVUlBNGJt?= =?utf-8?B?ZFZxaHEzVEVmTkwyR3hjOXZuVnZzQ1g0eGFxeTA0U1VXWnZLNXRpVmY0UUQx?= =?utf-8?B?cTkvZGdTSW5vUU5yOEFSdW5LeXEzdUlxQzFERXZtbWdvTEsyUm5qOWpiR2Nu?= =?utf-8?B?SGFmVC8wZ1g5VG52OVYrT3lCMitaYndpQXUzMDhGRHZSSWtrZmVNR1lmU3NI?= =?utf-8?B?NGRNbTVTYWd6aDJBODFNcTZnakxaR3dmcyt2VGR6WS9oZFlla3BWWTg1T2ZP?= =?utf-8?B?b2JZaDl2UHFjeExVeU1UdGU5ejF5eVNOeTBHRmNNRm96dEFjSUR1Rml6Slpo?= =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8EB7Kk9NsD67Chi+dz0Xzx2qD+S1J15QOupdvN3ELWS8IJl0vuCeaZLRfrGx1odQc01B+iMeI/Y2hFxe5jN6wmjKVT87qXzbC1r9yUvFItGXVN+ObU4sJRJwnq1t43GK0D5prcLetH2elKDjuUYCOe2PxuGmmRTLT8CGXUisPKlBg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2017 19:40:58.3844 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3547 |
Commit Message
Steve Ellcey
Sept. 1, 2017, 7:40 p.m. UTC
While working on a gcc patch I realized that the glibc tunable 'glibc.tune.cpu' was not working on aarch64. I tracked it down to get_midr_from_mcpu and at first I thought I should remove the '== 0' from the if statement because tunable_is_name returns true/false, not -1/0/1 like strcmp. But then I realized we shouldn't be using tunable_is_name at all because we are comparing two null terminated strings and tunable_is_name is trying to compare a null terminated string with a '=' terminated string which is not what we have. I tested this by running a program that calls memcpy and checking what memcpy gets run after setting glibc.tune.cpu to generic, thunderx, and falkor. OK to checkin? Steve Ellcey sellcey@cavium.com 2017-09-01 Steve Ellcey <sellcey@cavium.com> * sysdeps/unix/sysv/linux/aarch64/cpu-features.c (get_midr_from_mcpu): Use strcmp instead of tunable_is_name.
Comments
On Saturday 02 September 2017 01:10 AM, Steve Ellcey wrote: > While working on a gcc patch I realized that the glibc tunable > 'glibc.tune.cpu' was not working on aarch64. I tracked it down to > get_midr_from_mcpu and at first I thought I should remove the '== 0' > from the if statement because tunable_is_name returns true/false, not > -1/0/1 like strcmp. But then I realized we shouldn't be using > tunable_is_name at all because we are comparing two null terminated > strings and tunable_is_name is trying to compare a null terminated > string with a '=' terminated string which is not what we have. > > I tested this by running a program that calls memcpy and checking what > memcpy gets run after setting glibc.tune.cpu to generic, thunderx, > and falkor. Right, tunable_is_name is the wrong function to call but using strcmp there may not be safe. Please verify that it does not go through a PLT, i.e. it calls the ld.so version at all times. Siddhesh
On Mon, 2017-09-04 at 11:07 +0530, Siddhesh Poyarekar wrote: > > Right, tunable_is_name is the wrong function to call but using strcmp > there may not be safe. Please verify that it does not go through a PLT, > i.e. it calls the ld.so version at all times. > > Siddhesh I am not sure I know how to do this. If I look at csu/libc-start.o, where, after inlining, this code shows up I see a reference to "strcmp" and not to "__GI_strcmp" that I see in some other places. Does that mean I am going through the PLT? If so, what do I do about it? I also see a new undefined reference to strcmp from elf/dl-sysdep.os, but that file was already referencing "strlen", so maybe it doesn't matter there. Steve Ellcey sellcey@cavium.com
On Tuesday 05 September 2017 09:23 PM, Steve Ellcey wrote: > I am not sure I know how to do this. If I look at csu/libc-start.o, > where, after inlining, this code shows up I see a reference to "strcmp" > and not to "__GI_strcmp" that I see in some other places. Does that > mean I am going through the PLT? If so, what do I do about it? I also > see a new undefined reference to strcmp from elf/dl-sysdep.os, but that > file was already referencing "strlen", so maybe it doesn't matter > there. When you disassemble ld.so you should see (1) a definition of strcmp and (2) the call site should have a call to strcmp and not to strcmp@plt. Siddhesh
On Wed, 2017-09-06 at 11:53 +0530, Siddhesh Poyarekar wrote: > On Tuesday 05 September 2017 09:23 PM, Steve Ellcey wrote: > > > > I am not sure I know how to do this. If I look at csu/libc-start.o, > > where, after inlining, this code shows up I see a reference to "strcmp" > > and not to "__GI_strcmp" that I see in some other places. Does that > > mean I am going through the PLT? If so, what do I do about it? I also > > see a new undefined reference to strcmp from elf/dl-sysdep.os, but that > > file was already referencing "strlen", so maybe it doesn't matter > > there. > When you disassemble ld.so you should see (1) a definition of strcmp and > (2) the call site should have a call to strcmp and not to strcmp@plt. > > Siddhesh OK, I disassembled ld.so with 'objdump -d' and the calls are to 'strcmp' and not to 'strcmp@plt'. I see quite a few of them so it looks like we were already using strcmp in other places. I also see the definition of strcmp in ld.so. Steve Ellcey sellcey@cavium.com
On Wednesday 06 September 2017 08:58 PM, Steve Ellcey wrote: > OK, I disassembled ld.so with 'objdump -d' and the calls are to > 'strcmp' and not to 'strcmp@plt'. I see quite a few of them so > it looks like we were already using strcmp in other places. > > I also see the definition of strcmp in ld.so. Looks good then. Thanks, Siddhesh
diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c b/sysdeps/unix/sysv/ linux/aarch64/cpu-features.c index 18f5e60..0c7e13f 100644 --- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c +++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c @@ -37,7 +37,7 @@ static uint64_t  get_midr_from_mcpu (const char *mcpu)  {    for (int i = 0; i < sizeof (cpu_list) / sizeof (struct cpu_list); i++) -    if (tunable_is_name (mcpu, cpu_list[i].name) == 0) +    if (strcmp (mcpu, cpu_list[i].name) == 0)        return cpu_list[i].midr;     return UINT64_MAX;