public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/25824] New: Abnormal function of strnlen in aarch64
@ 2020-04-15 13:25 zhuyan34 at huawei dot com
  2020-04-15 13:32 ` [Bug libc/25824] " schwab@linux-m68k.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: zhuyan34 at huawei dot com @ 2020-04-15 13:25 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

            Bug ID: 25824
           Summary: Abnormal function of strnlen in aarch64
           Product: glibc
           Version: 2.31
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: zhuyan34 at huawei dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

In aarch64, the strnlen interface has a problem when the string length is more
than 9

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
@ 2020-04-15 13:32 ` schwab@linux-m68k.org
  2020-04-15 14:13 ` zhuyan34 at huawei dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: schwab@linux-m68k.org @ 2020-04-15 13:32 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
*** Bug 25825 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
  2020-04-15 13:32 ` [Bug libc/25824] " schwab@linux-m68k.org
@ 2020-04-15 14:13 ` zhuyan34 at huawei dot com
  2020-04-15 14:13 ` zhuyan34 at huawei dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: zhuyan34 at huawei dot com @ 2020-04-15 14:13 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

--- Comment #2 from Yan Zhu <zhuyan34 at huawei dot com> ---
There is a testcase.

#include <stdio.h>
#include <string.h>

void init_base(char *base, int len)
{
        int i;
        for (i = 0; i < len; i++) {
                base[i] = 'x';
        }
        base[len] = '\0';
}

int main(int argc, char *argv[])
{
        int i;
        char base[1000];
        char buff[1000];
        size_t n;

        for (i = 1; i < 1000; i++) {
                memset(buff, 0, 1000);
                init_base(base, i);             
                n = strnlen(base, 1000);      
                if ( i == n )
                        printf("size=%d is equel\n", i);
                else
                        printf("size=%d is not equel%s\n", i);
        }

    return 0;
}


The execution log is as follows:

arm64be /tmp # ./arm64be-test_strnlen
size=1 is equel
size=2 is equel
size=3 is equel
size=4 is equel
size=5 is equel
size=6 is equel
size=7 is equel
size=8 is equel
size=9 is not equel
size=10 is not equel
size=11 is not equel
size=12 is not equel
size=13 is not equel

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
  2020-04-15 13:32 ` [Bug libc/25824] " schwab@linux-m68k.org
  2020-04-15 14:13 ` zhuyan34 at huawei dot com
@ 2020-04-15 14:13 ` zhuyan34 at huawei dot com
  2020-04-15 14:35 ` schwab@linux-m68k.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: zhuyan34 at huawei dot com @ 2020-04-15 14:13 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

--- Comment #3 from Yan Zhu <zhuyan34 at huawei dot com> ---
There is a testcase.

#include <stdio.h>
#include <string.h>

void init_base(char *base, int len)
{
        int i;
        for (i = 0; i < len; i++) {
                base[i] = 'x';
        }
        base[len] = '\0';
}

int main(int argc, char *argv[])
{
        int i;
        char base[1000];
        char buff[1000];
        size_t n;

        for (i = 1; i < 1000; i++) {
                memset(buff, 0, 1000);
                init_base(base, i);             
                n = strnlen(base, 1000);      
                if ( i == n )
                        printf("size=%d is equel\n", i);
                else
                        printf("size=%d is not equel%s\n", i);
        }

    return 0;
}


The execution log is as follows:

arm64be /tmp # ./arm64be-test_strnlen
size=1 is equel
size=2 is equel
size=3 is equel
size=4 is equel
size=5 is equel
size=6 is equel
size=7 is equel
size=8 is equel
size=9 is not equel
size=10 is not equel
size=11 is not equel
size=12 is not equel
size=13 is not equel

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
                   ` (2 preceding siblings ...)
  2020-04-15 14:13 ` zhuyan34 at huawei dot com
@ 2020-04-15 14:35 ` schwab@linux-m68k.org
  2020-04-15 16:53 ` wdijkstr at arm dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: schwab@linux-m68k.org @ 2020-04-15 14:35 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
               Host|                            |aarch64_be-*-*

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> ---
This does not fail on little-endian aarch64.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
                   ` (3 preceding siblings ...)
  2020-04-15 14:35 ` schwab@linux-m68k.org
@ 2020-04-15 16:53 ` wdijkstr at arm dot com
  2020-05-11 15:33 ` wdijkstr at arm dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: wdijkstr at arm dot com @ 2020-04-15 16:53 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

Wilco <wdijkstr at arm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wdijkstr at arm dot com

--- Comment #5 from Wilco <wdijkstr at arm dot com> ---
(In reply to Yan Zhu from comment #0)
> In aarch64, the strnlen interface has a problem when the string length is
> more than 9

In big-endian? Yes that rev64 only swaps bytes in each 64-bit word, so you
still need to swap the index in mov data1, datav2.d[0].

This sequence comes from strlen_asimd.S originally. And now strcpy.S has it
too.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
                   ` (4 preceding siblings ...)
  2020-04-15 16:53 ` wdijkstr at arm dot com
@ 2020-05-11 15:33 ` wdijkstr at arm dot com
  2020-05-15 13:22 ` nsz at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: wdijkstr at arm dot com @ 2020-05-11 15:33 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

--- Comment #6 from Wilco <wdijkstr at arm dot com> ---
(In reply to Wilco from comment #5)
> (In reply to Yan Zhu from comment #0)
> > In aarch64, the strnlen interface has a problem when the string length is
> > more than 9
> 
> In big-endian? Yes that rev64 only swaps bytes in each 64-bit word, so you
> still need to swap the index in mov data1, datav2.d[0].
> 
> This sequence comes from strlen_asimd.S originally. And now strcpy.S has it
> too.

Btw I have a faster strnlen I'll post soon that will fix one of the 3 cases.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
                   ` (5 preceding siblings ...)
  2020-05-11 15:33 ` wdijkstr at arm dot com
@ 2020-05-15 13:22 ` nsz at gcc dot gnu.org
  2020-07-17 14:07 ` cvs-commit at gcc dot gnu.org
  2020-07-17 14:56 ` nsz at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: nsz at gcc dot gnu.org @ 2020-05-15 13:22 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

Szabolcs Nagy <nsz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |nsz at gcc dot gnu.org
   Target Milestone|---                         |2.32
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-05-15

--- Comment #7 from Szabolcs Nagy <nsz at gcc dot gnu.org> ---
bigendian strnlen, strcpy (and stpcpy) are fixed for glibc 2.32 in

commit 59b64f9cbbf1e98c6d187873de6c363994aee19d
Author:     Lexi Shao <shaolexi@huawei.com>
AuthorDate: 2020-05-15 18:48:59 +0800

    aarch64: fix strcpy and strnlen for big-endian [BZ #25824]

falkor and kunpeng920 specific strlen_asimd still needs to be fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
                   ` (6 preceding siblings ...)
  2020-05-15 13:22 ` nsz at gcc dot gnu.org
@ 2020-07-17 14:07 ` cvs-commit at gcc dot gnu.org
  2020-07-17 14:56 ` nsz at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-17 14:07 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

--- Comment #8 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Wilco Dijkstra <wilco@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f46ef33ad134bec7ac992f28ee4b8b0614590e3e

commit f46ef33ad134bec7ac992f28ee4b8b0614590e3e
Author: Wilco Dijkstra <wdijkstr@arm.com>
Date:   Fri Jul 17 14:09:36 2020 +0100

    AArch64: Improve strlen_asimd performance (bug 25824)

    Optimize strlen using a mix of scalar and SIMD code.  On modern micro
    architectures large strings are 2.6 times faster than existing
    strlen_asimd and 35% faster than the new MTE version of strlen.

    On a random strlen benchmark using small sizes the speedup is 7% vs
    strlen_asimd and 40% vs the MTE strlen.  This fixes the main strlen
    regressions on Cortex-A53 and other cores with a simple Neon unit.

    Rename __strlen_generic to __strlen_mte, and select strlen_asimd when
    MTE is not enabled (this is waiting on support for a HWCAP_MTE bit).

    This fixes big-endian bug 25824. Passes GLIBC regression tests.

    Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/25824] Abnormal function of strnlen in aarch64
  2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
                   ` (7 preceding siblings ...)
  2020-07-17 14:07 ` cvs-commit at gcc dot gnu.org
@ 2020-07-17 14:56 ` nsz at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: nsz at gcc dot gnu.org @ 2020-07-17 14:56 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=25824

Szabolcs Nagy <nsz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #9 from Szabolcs Nagy <nsz at gcc dot gnu.org> ---
fixed for 2.32

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-07-17 14:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15 13:25 [Bug libc/25824] New: Abnormal function of strnlen in aarch64 zhuyan34 at huawei dot com
2020-04-15 13:32 ` [Bug libc/25824] " schwab@linux-m68k.org
2020-04-15 14:13 ` zhuyan34 at huawei dot com
2020-04-15 14:13 ` zhuyan34 at huawei dot com
2020-04-15 14:35 ` schwab@linux-m68k.org
2020-04-15 16:53 ` wdijkstr at arm dot com
2020-05-11 15:33 ` wdijkstr at arm dot com
2020-05-15 13:22 ` nsz at gcc dot gnu.org
2020-07-17 14:07 ` cvs-commit at gcc dot gnu.org
2020-07-17 14:56 ` nsz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).