From patchwork Fri Apr 2 21:35:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1461895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=qcWLP9o7; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FBtdm6Glgz9sSC for ; Sat, 3 Apr 2021 08:35:56 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C84F5388A40E; Fri, 2 Apr 2021 21:35:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C84F5388A40E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617399349; bh=AZeXMFsrrAvhjQiljcwyqWTY80wTH+qwz0/POfp3DTk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=qcWLP9o7ykbTy0weMVxVGhcYXAFByrweH1cakQ9vIl2ZRktg9CUPuRBKcciAzXklT 4yBA+PUz6QxlOnqlqgo5535MLRi4NZ33Vho6L5zgV+QrGuLiPasWGMTP1fnKzjYHOv G2Fm3twoegVKpGBD4uAz1a93ll2vEV4joycRhHDk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by sourceware.org (Postfix) with ESMTPS id C974A3857832 for ; Fri, 2 Apr 2021 21:35:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C974A3857832 Received: by mail-qk1-x735.google.com with SMTP id v70so6351396qkb.8 for ; Fri, 02 Apr 2021 14:35:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AZeXMFsrrAvhjQiljcwyqWTY80wTH+qwz0/POfp3DTk=; b=C4v7wMqMgNDH9oviS4kvN8Bhupa4byBr6924sqsp8ux+zLaxAvEEAg6ng4LCN8MXQL JAwIFS/OfPeqB3b6/fQzIwnyvgbZGLYkOIbkeNG7uBLwP+p+n56DkhNXQH12nrPvIUi5 dwz3XHWrbfVQqu716BJ2DudS90uw1iRDzsD8n5JqJSkOA06uxZcV5C5Fu9FuJB94GmhR NrpMNU85STwm39Z4XtOCsDZ2zMrjsSsM6FfS9eEvJ4DvP4xxXUc/ztx63K+Xa8ZNgxHR zcA3VygKBg3aNjDteFxV4DcOOOO8oktioH6154ZXy3HXQ7Kh7DD1oR+Ht2sSyPqD8LiR sh3Q== X-Gm-Message-State: AOAM53256C1n7BM7ZgfWa60RBqzNZE4dZOg76AcbPV25xA7bDW4828As ZaXZOZyOGlzDZ1BgPZfhEheptqWPpD4= X-Google-Smtp-Source: ABdhPJwy+SAfoETXGFZMCS7kfjiUQKSoHFBHNGBlah8FDeB3kligp7j36sQYkMxiQ1NQqI0EI39nNg== X-Received: by 2002:a37:a913:: with SMTP id s19mr15416127qke.158.1617399346266; Fri, 02 Apr 2021 14:35:46 -0700 (PDT) Received: from localhost.localdomain (pool-71-245-178-39.pitbpa.fios.verizon.net. [71.245.178.39]) by smtp.googlemail.com with ESMTPSA id l9sm7450267qtv.65.2021.04.02.14.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 14:35:46 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v7 2/2] x86: Expanding test-memmove.c, test-memcpy.c, bench-memcpy-large.c Date: Fri, 2 Apr 2021 17:35:36 -0400 Message-Id: <20210402213536.1380514-2-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210402213536.1380514-1-goldstein.w.n@gmail.com> References: <20210402213536.1380514-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.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.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-Patchwork-Original-From: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: noah No Bug. This commit expanding the range of tests / benchmarks for memmove and memcpy. The test expansion is mostly in the vein of increasing the maximum size, increasing the number of unique alignments tested, and testing both source < destination and vice versa. The benchmark expansaion is just to increase the number of unique alignments. test-memcpy, test-memccpy, test-mempcpy, test-memmove, and tst-memmove-overflow all pass. Signed-off-by: Noah Goldstein --- benchtests/bench-memcpy-large.c | 8 +++- string/test-memcpy.c | 61 ++++++++++++++++------------- string/test-memmove.c | 68 ++++++++++++++++++++------------- 3 files changed, 82 insertions(+), 55 deletions(-) diff --git a/benchtests/bench-memcpy-large.c b/benchtests/bench-memcpy-large.c index 3df1575514..efb9627b1e 100644 --- a/benchtests/bench-memcpy-large.c +++ b/benchtests/bench-memcpy-large.c @@ -57,11 +57,11 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len) size_t i, j; char *s1, *s2; - align1 &= 63; + align1 &= 4095; if (align1 + len >= page_size) return; - align2 &= 63; + align2 &= 4095; if (align2 + len >= page_size) return; @@ -113,6 +113,10 @@ test_main (void) do_test (&json_ctx, 0, 3, i + 15); do_test (&json_ctx, 3, 0, i + 31); do_test (&json_ctx, 3, 5, i + 63); + do_test (&json_ctx, 0, 127, i); + do_test (&json_ctx, 0, 255, i); + do_test (&json_ctx, 0, 256, i); + do_test (&json_ctx, 0, 4064, i); } json_array_end (&json_ctx); diff --git a/string/test-memcpy.c b/string/test-memcpy.c index 2e9c6bd099..c9dfc88fed 100644 --- a/string/test-memcpy.c +++ b/string/test-memcpy.c @@ -82,11 +82,11 @@ do_test (size_t align1, size_t align2, size_t len) size_t i, j; char *s1, *s2; - align1 &= 63; + align1 &= 4095; if (align1 + len >= page_size) return; - align2 &= 63; + align2 &= 4095; if (align2 + len >= page_size) return; @@ -213,11 +213,9 @@ do_random_tests (void) } static void -do_test1 (void) +do_test1 (size_t size) { - size_t size = 0x100000; void *large_buf; - large_buf = mmap (NULL, size * 2 + page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); if (large_buf == MAP_FAILED) @@ -233,27 +231,32 @@ do_test1 (void) uint32_t *dest = large_buf; uint32_t *src = large_buf + size + page_size; size_t i; - - for (i = 0; i < arrary_size; i++) - src[i] = (uint32_t) i; - - FOR_EACH_IMPL (impl, 0) + size_t repeats; + for(repeats = 0; repeats < 2; repeats++) { - memset (dest, -1, size); - CALL (impl, (char *) dest, (char *) src, size); for (i = 0; i < arrary_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; - break; - } + src[i] = (uint32_t) i; + + 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++) + 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); + return; + } + } + dest = src; + src = large_buf; } - - munmap ((void *) dest, size); - munmap ((void *) src, size); + munmap ((void *) large_buf, size * 2 + page_size); } int @@ -275,7 +278,6 @@ test_main (void) do_test (0, i, 1 << i); do_test (i, i, 1 << i); } - for (i = 0; i < 32; ++i) { do_test (0, 0, i); @@ -294,12 +296,19 @@ test_main (void) do_test (i, i, 16 * i); } + for (i = 19; i <= 25; ++i) + { + do_test (255, 0, 1 << i); + do_test (0, 255, i); + do_test (0, 4000, i); + } + do_test (0, 0, getpagesize ()); do_random_tests (); - do_test1 (); - + do_test1 (0x100000); + do_test1 (0x2000000); return ret; } diff --git a/string/test-memmove.c b/string/test-memmove.c index 2e3ce75b9b..2e665fa3a5 100644 --- a/string/test-memmove.c +++ b/string/test-memmove.c @@ -247,7 +247,7 @@ do_random_tests (void) } static void -do_test2 (void) +do_test2 (size_t offset) { size_t size = 0x20000000; uint32_t * large_buf; @@ -268,33 +268,45 @@ do_test2 (void) } size_t bytes_move = 0x80000000 - (uintptr_t) large_buf; + if (bytes_move + offset * sizeof (uint32_t) > size) + { + munmap ((void *) large_buf, size); + return; + } size_t arr_size = bytes_move / sizeof (uint32_t); size_t i; - - FOR_EACH_IMPL (impl, 0) + size_t repeats; + uint32_t * src = large_buf; + uint32_t * dst = &large_buf[offset]; + for (repeats = 0; repeats < 2; ++repeats) { - for (i = 0; i < arr_size; i++) - large_buf[i] = (uint32_t) i; - - uint32_t * dst = &large_buf[33]; - -#ifdef TEST_BCOPY - CALL (impl, (char *) large_buf, (char *) dst, bytes_move); -#else - CALL (impl, (char *) dst, (char *) large_buf, bytes_move); -#endif - - for (i = 0; i < arr_size; i++) - { - if (dst[i] != (uint32_t) i) - { - error (0, 0, - "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"", - impl->name, dst, large_buf, i); - ret = 1; - break; - } - } + FOR_EACH_IMPL (impl, 0) + { + for (i = 0; i < arr_size; i++) + src[i] = (uint32_t) i; + + + #ifdef TEST_BCOPY + CALL (impl, (char *) src, (char *) dst, bytes_move); + #else + CALL (impl, (char *) dst, (char *) src, bytes_move); + #endif + + for (i = 0; i < arr_size; i++) + { + if (dst[i] != (uint32_t) i) + { + error (0, 0, + "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"", + impl->name, dst, large_buf, i); + ret = 1; + munmap ((void *) large_buf, size); + return; + } + } + } + src = dst; + dst = large_buf; } munmap ((void *) large_buf, size); @@ -340,8 +352,10 @@ test_main (void) do_random_tests (); - do_test2 (); - + do_test2 (33); + do_test2 (0x200000); + do_test2 (0x4000000 - 1); + do_test2 (0x4000000); return ret; }