From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 65B313858014 for ; Tue, 7 Dec 2021 22:07:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 65B313858014 Received: by mail-pl1-x62a.google.com with SMTP id u17so188398plg.9 for ; Tue, 07 Dec 2021 14:07:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=j3YMbGJo1JLpfRvWLVFAI81dokoXHC5nJhjJB0cCAr0=; b=RtBvS6SK1OcoVpLCQo9IP9bY6KlGlNvH8p2sCHsNE2WFpMc030Ctmeiaxgk6xCXXvK QysrVYXmOoWgTFRcGkKPW1EtGyQ8jqmDU+fptdcP5rZxC7YKEdSPVD/AuqdZlda/wEww jEuFBOdtkfhfwDQ61gRhkooHipSg5bLff1vMEVuGxRP88To6YbrerYJncVy9pinKqVLY KwjwtX4bIF06aBQtiChiKlAnTYLHaphdG2Z78huf3gLgc4RFdHlDeMhctf8kmB09kShY EYHqL9BTWHUfKXzjQPRNBLW6ZXGJjdFlUsV+kIwTPzH3bnN+9tnZpd3l25Aw7qeQi0Pv QVcQ== X-Gm-Message-State: AOAM530cV7ckMh9NNXy8MC/eYw3diQeY8wnwHLSXMp2+e5hbhqlGkPcp qxxQOdPHQQhjusv8Hmpi1CNCiz1FQHA= X-Google-Smtp-Source: ABdhPJzgIUWmieDQpaPAsanU2YkZE2h0tgAkV+P7D0usWu5vQto/YIDIQfkw9Doa2OaVXgCY9SJp1g== X-Received: by 2002:a17:90b:1241:: with SMTP id gx1mr2216486pjb.164.1638914864388; Tue, 07 Dec 2021 14:07:44 -0800 (PST) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id c81sm719974pfb.166.2021.12.07.14.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 14:07:43 -0800 (PST) Date: Wed, 8 Dec 2021 07:07:41 +0900 From: Stafford Horne To: Noah Goldstein Cc: GNU C Library Subject: Re: [PATCH v4 1/5] string: Make tests birdirectional test-memcpy.c Message-ID: References: <20211101054952.2349590-1-goldstein.w.n@gmail.com> <20211106183322.3129442-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Tue, 07 Dec 2021 22:07:47 -0000 On Tue, Dec 07, 2021 at 03:36:48PM -0600, Noah Goldstein wrote: > On Tue, Dec 7, 2021 at 3:10 PM Stafford Horne wrote: > > > > On Sat, Nov 06, 2021 at 01:33:18PM -0500, Noah Goldstein via Libc-alpha wrote: > > > This commit updates the memcpy tests to test both dst > src and dst < > > > src. This is because there is logic in the code based on the > > > Reviewed-by: H.J. Lu > > > --- > > > string/test-memcpy.c | 167 +++++++++++++++++++++++++++++++++++------- > > > string/test-memmove.c | 75 ++++++++++++++++++- > > > 2 files changed, 214 insertions(+), 28 deletions(-) > > > > > > diff --git a/string/test-memcpy.c b/string/test-memcpy.c > > [..] > > > static void > > > -do_test1 (size_t size) > > > +do_test1 (size_t align1, size_t align2, size_t size) > > > { > > > void *large_buf; > > > - large_buf = mmap (NULL, size * 2 + page_size, PROT_READ | PROT_WRITE, > > > - MAP_PRIVATE | MAP_ANON, -1, 0); > > > + size_t mmap_size, region_size; > > > + > > > + align1 &= (page_size - 1); > > > + if (align1 == 0) > > > + align1 = page_size; > > > + > > > + align2 &= (page_size - 1); > > > + if (align2 == 0) > > > + align2 = page_size; > > > + > > > + region_size = (size + page_size - 1) & (~(page_size - 1)); > > > + > > > + mmap_size = region_size * 2 + 3 * page_size; > > > + large_buf = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, > > > + MAP_PRIVATE | MAP_ANON, -1, 0); > > > if (large_buf == MAP_FAILED) > > > { > > > - puts ("Failed to allocat large_buf, skipping do_test1"); > > > + puts ("Failed to allocate large_buf, skipping do_test1"); > > > return; > > > } > > > - > > > - if (mprotect (large_buf + size, page_size, PROT_NONE)) > > > + if (mprotect (large_buf + region_size + page_size, page_size, PROT_NONE)) > > > error (EXIT_FAILURE, errno, "mprotect failed"); > > > > > > - size_t arrary_size = size / sizeof (uint32_t); > > > - uint32_t *dest = large_buf; > > > - uint32_t *src = large_buf + size + page_size; > > > + size_t array_size = size / sizeof (uint32_t); > > > + uint32_t *dest = large_buf + align1; > > > + uint32_t *src = large_buf + region_size + 2 * page_size + align2; > > > > Hello, this causes Bus errors on the new OpenRISC port I am working on. > > Bugzilla for this issue is here: > https://sourceware.org/bugzilla/show_bug.cgi?id=28572 > > There is a patch attached to the bugzilla and a patch proposed > by Adhemerval Zanella that both fix the issue. Thanks, That patch should work. -Stafford > > > > > size_t i; > > > size_t repeats; > > > for(repeats = 0; repeats < 2; repeats++) > > > { > > > - for (i = 0; i < arrary_size; i++) > > > + for (i = 0; i < array_size; i++) > > > src[i] = (uint32_t) i; > > > > The bus errors happen here caused when align2 is 1 or 2. OpenRISC (and maybe > > other architectures?) do not support unaligned copies of words. > > > > I fixed this by limiting the align1/align2 to 4 but I am not sure if that is > > what you are trying to copy here. > > > > Maybe we need to change how we setup the src array. > > > > > - > > > FOR_EACH_IMPL (impl, 0) > > > { > > > - printf ("\t\tRunning: %s\n", impl->name); > > > memset (dest, -1, size); > > > CALL (impl, (char *) dest, (char *) src, size); > > > - for (i = 0; i < arrary_size; i++) > > > + for (i = 0; i < array_size; i++) > > > if (dest[i] != src[i]) > > > { > > > error (0, 0, > > > "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"", > > > impl->name, dest, src, i); > > > ret = 1; > > > - munmap ((void *) large_buf, size * 2 + page_size); > > > + munmap ((void *) large_buf, mmap_size); > > > return; > > > } > > > } > > > - dest = src; > > > - src = large_buf; > > > + dest = large_buf + region_size + 2 * page_size + align1; > > > + src = large_buf + align2; > > > + } > > > + munmap ((void *) large_buf, mmap_size); > > > +} > > > + > > [..] > > > @@ -306,8 +341,88 @@ test_main (void) > > > > > > do_random_tests (); > > > > > > - do_test1 (0x100000); > > > - do_test1 (0x2000000); > > > + do_test1 (0, 0, 0x100000); > > > + do_test1 (0, 0, 0x2000000); > > > + > > > + for (i = 4096; i < 32768; i += 4096) > > > + { > > > + for (j = 1; j <= 1024; j <<= 1) > > > + { > > > + do_test1 (0, j, i); > > > + do_test1 (4095, j, i); > > > + do_test1 (4096 - j, 0, i); > > > + > > > + do_test1 (0, j - 1, i); > > > + do_test1 (4095, j - 1, i); > > > + do_test1 (4096 - j - 1, 0, i); > > > + > > > + do_test1 (0, j + 1, i); > > > + do_test1 (4095, j + 1, i); > > > + do_test1 (4096 - j, 1, i); > > > > These +1, -1's cause non-aligned word access. > > > > > + } > > > + } > > > + > > > > -Stafford