From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id AE8983858D37 for ; Thu, 9 Mar 2023 01:26:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE8983858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.20.4.187]) by gateway (Coremail) with SMTP id _____8Dx3tq2NQlkvCoKAA--.1908S3; Thu, 09 Mar 2023 09:26:15 +0800 (CST) Received: from [10.20.4.187] (unknown [10.20.4.187]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxjb62NQlkHwhQAA--.11767S3; Thu, 09 Mar 2023 09:26:14 +0800 (CST) Subject: Re: [PATCH] x86: Fix bug about glibc.cpu.hwcaps. To: Noah Goldstein Cc: Xi Ruoyao , "H.J. Lu" , libc-alpha@sourceware.org References: <20230302023349.3194099-1-caiyinyu@loongson.cn> <092a02df-58c3-633d-e44f-56d32535f775@loongson.cn> <3398ea16-1e36-8c08-0041-f7a4a2193907@loongson.cn> From: caiyinyu Message-ID: Date: Thu, 9 Mar 2023 09:26:14 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8Bxjb62NQlkHwhQAA--.11767S3 X-CM-SenderInfo: 5fdl5xhq1xqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxJFW5Cr1DurWfKF4ktryxKrg_yoW5AFyDpr yUJa1jkrs8Jry5Gw17Kw1UtF15tryUtr18Zrn8Jw1UZr1qqr13JF42yr1Uuw4UJr1xGr17 ZF18tF17Zr1UXrDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bxkYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26F4j6r4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UM2AI xVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64 kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07AlzVAYIcxG8wCF04 k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18 MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr4 1lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1l IxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4 A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1EksDUUUUU== X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 在 2023/3/9 上午12:56, Noah Goldstein 写道: > On Wed, Mar 8, 2023 at 1:16 AM caiyinyu wrote: >> >> 在 2023/3/8 上午1:23, Noah Goldstein 写道: >>> On Tue, Mar 7, 2023 at 7:18 AM caiyinyu wrote: >>>> 在 2023/3/7 下午9:02, Xi Ruoyao 写道: >>>>> On Tue, 2023-03-07 at 20:45 +0800, caiyinyu wrote: >>>>>> 在 2023/3/2 下午12:22, H.J. Lu 写道: >>>>>>> On Wed, Mar 1, 2023 at 6:36 PM caiyinyu >>>>>>> wrote: >>>>>>>> Recorded in [BZ #30183]: >>>>>>>> >>>>>>>> 1. export GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX512 >>>>>>>> 2. Add _dl_printf("p -- %s\n", p); just before switch(nl) in >>>>>>>> sysdeps/x86/cpu-tunables.c >>>>>>>> 3. compiled and run ./testrun.sh /usr/bin/ls >>>>>>>> you will get: >>>>>>>> >>>>>>>> p -- -AVX512 >>>>>>>> p -- LC_ADDRESS=en_US.UTF-8 >>>>>>>> p -- LC_NUMERIC=C >>>>>>>> ... >>>>>>>> >>>>>>>> The function, TUNABLE_CALLBACK (set_hwcaps) >>>>>>>> (tunable_val_t *valp), checks far more than it should and it >>>>>>>> should stop at end of "-AVX512". >>>>>>>> --- >>>>>>>> sysdeps/x86/cpu-tunables.c | 6 +++--- >>>>>>>> 1 file changed, 3 insertions(+), 3 deletions(-) >>>>>>>> >>>>>>>> diff --git a/sysdeps/x86/cpu-tunables.c b/sysdeps/x86/cpu- >>>>>>>> tunables.c >>>>>>>> index d3e1367bda..772fb0c4c2 100644 >>>>>>>> --- a/sysdeps/x86/cpu-tunables.c >>>>>>>> +++ b/sysdeps/x86/cpu-tunables.c >>>>>>>> @@ -107,13 +107,13 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t >>>>>>>> *valp) >>>>>>>> NOTE: the IFUNC selection may change over time. Please >>>>>>>> check all >>>>>>>> multiarch implementations when experimenting. */ >>>>>>>> >>>>>>>> - const char *p = valp->strval; >>>>>>>> + const char *p = valp->strval, *c; >>>>>>>> struct cpu_features *cpu_features = >>>>>>>> &GLRO(dl_x86_cpu_features); >>>>>>>> size_t len; >>>>>>>> >>>>>>>> do >>>>>>>> { >>>>>>>> - const char *c, *n; >>>>>>>> + const char *n; >>>>>>>> bool disable; >>>>>>>> size_t nl; >>>>>>>> >>>>>>>> @@ -283,7 +283,7 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t >>>>>>>> *valp) >>>>>>>> } >>>>>>>> p += len + 1; >>>>>>>> } >>>>>>>> - while (*p != '\0'); >>>>>>>> + while (*c != '\0'); >>>>>>>> } >>>>>>>> >>>>>>>> # if CET_ENABLED >>>>>>>> -- >>>>>>>> 2.31.1 >>>>>>>> >>>>>>> OK. >>>>>>> >>>>>>> Thanks. >>>>>> Could you help to push this patch? >>>>> I guess you can push it yourself. A port maintainer has write access to >>>>> the entire Git repository, just use it carefully (i. e. always get a >>>>> permission before changing other subsystems). >>>>> >>>> OK, thanks. >>> did you add the tests HJ asked for? >> Not yet. > It also doesn't have the BZ number in the commit message. In the future please > wait for approval before pushing. > Ok. There are "Recorded in [BZ #30183]:" in the commit message and I will append it on the first line next time. I mistakenly thought HJ is ok with >>