From patchwork Mon Apr 19 16:30:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 43044 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E158F3959C2F; Mon, 19 Apr 2021 16:30:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E158F3959C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1618849850; bh=l8KD1Dg/i15zQMa9KC/JlAIgnqMBAQMlbAeTENg6zUg=; 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=YRDjSwR3TF8sFRHrM59aKfASUV0ck8bBRN3SSjZOJj61WXGgFZSrNshDFQ1hNThkh VQT/eUsk0a5IfBEtc/A/XSvjbpa+0nVqs8Hyg17DiB5+2RkVjo7TnzirnjRqwP48DB FWiXal3h4NMuwPCHMVRG9mJha+96ptcCiSFHjvDE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by sourceware.org (Postfix) with ESMTPS id 408453959CB9 for ; Mon, 19 Apr 2021 16:30:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 408453959CB9 Received: by mail-qk1-x732.google.com with SMTP id y136so4288824qkb.1 for ; Mon, 19 Apr 2021 09:30: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=l8KD1Dg/i15zQMa9KC/JlAIgnqMBAQMlbAeTENg6zUg=; b=rXL7IGn6JwS/9AFmd77hy1mIShf3riSmcMhfxXFnSBLmksEkFYwPUelmYGFER83oK6 K3hAtBzxRSbp9NViKOi+vufLf8a7M9n9jo4ilQkDuCwATD2HPLHxmVC+p+IzFo4kdusa kVrr90ahVUUdkIwlY0KF+2DZ0kcSARORz8AchxHTMIcWT6yjMA9AZPcr3p8OSBePkod/ dagx444s3pFW0Lc/frF6pyEmICBLkjfMWfOZfv8ltzDDzAlLW6P2Mh8kVPJ2kmN5TcwS 6GT3F6stBlrmDpV3r+85XdL8zDG/D76kanvvL7BQkn/A/I24u22KHdc3IYKN52AethRe Faqw== X-Gm-Message-State: AOAM5309dsdgCdcrWQe/x4aA6dPdCgKYg+MH2qzS2t7v0JeUkIrm3KJ3 Trl4EBCzIRli5G2Rxx5m6Y1k+s8+kbE= X-Google-Smtp-Source: ABdhPJy96oKz9mepozEGXnDreC5AUDATqW/HUDvylOMP+myiQ1te7K6WZPe1JAEqx2FFyHqIFQb31g== X-Received: by 2002:a05:620a:7d1:: with SMTP id 17mr12872341qkb.403.1618849845691; Mon, 19 Apr 2021 09:30:45 -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 m2sm10115505qkc.14.2021.04.19.09.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 09:30:45 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 2/2] x86: Expand test-memset.c and bench-memset.c Date: Mon, 19 Apr 2021 12:30:25 -0400 Message-Id: <20210419163025.2285675-2-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210419163025.2285675-1-goldstein.w.n@gmail.com> References: <20210419163025.2285675-1-goldstein.w.n@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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" No bug. This commit adds tests cases and benchmarks for page cross and for memset to the end of the page without crossing. As well in test-memset.c this commit adds sentinel on start/end of tstbuf to test for overwrites Signed-off-by: Noah Goldstein --- benchtests/bench-memset.c | 6 ++++-- string/test-memset.c | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c index 1174900e88..d6619b4836 100644 --- a/benchtests/bench-memset.c +++ b/benchtests/bench-memset.c @@ -61,7 +61,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, static void do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len) { - align &= 63; + align &= 4095; if ((align + len) * sizeof (CHAR) > page_size) return; @@ -110,9 +110,11 @@ test_main (void) { for (i = 0; i < 18; ++i) do_test (&json_ctx, 0, c, 1 << i); - for (i = 1; i < 32; ++i) + for (i = 1; i < 64; ++i) { do_test (&json_ctx, i, c, i); + do_test (&json_ctx, 4096 - i, c, i); + do_test (&json_ctx, 4095, c, i); if (i & (i - 1)) do_test (&json_ctx, 0, c, i); } diff --git a/string/test-memset.c b/string/test-memset.c index eb71517390..82bfcd6ad4 100644 --- a/string/test-memset.c +++ b/string/test-memset.c @@ -109,16 +109,24 @@ SIMPLE_MEMSET (CHAR *s, int c, size_t n) static void do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n) { - CHAR tstbuf[n]; + CHAR buf[n + 2]; + CHAR *tstbuf = buf + 1; + CHAR sentinel = c - 1; + buf[0] = sentinel; + buf[n + 1] = sentinel; #ifdef TEST_BZERO simple_bzero (tstbuf, n); CALL (impl, s, n); - if (memcmp (s, tstbuf, n) != 0) + if (memcmp (s, tstbuf, n) != 0 + || buf[0] != sentinel + || buf[n + 1] != sentinel) #else CHAR *res = CALL (impl, s, c, n); if (res != s || SIMPLE_MEMSET (tstbuf, c, n) != tstbuf - || MEMCMP (s, tstbuf, n) != 0) + || MEMCMP (s, tstbuf, n) != 0 + || buf[0] != sentinel + || buf[n + 1] != sentinel) #endif /* !TEST_BZERO */ { error (0, 0, "Wrong result in function %s", impl->name); @@ -130,7 +138,7 @@ do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n) static void do_test (size_t align, int c, size_t len) { - align &= 7; + align &= 4095; if ((align + len) * sizeof (CHAR) > page_size) return; @@ -245,9 +253,11 @@ test_main (void) { for (i = 0; i < 18; ++i) do_test (0, c, 1 << i); - for (i = 1; i < 32; ++i) + for (i = 1; i < 64; ++i) { do_test (i, c, i); + do_test (4096 - i, c, i); + do_test (4095, c, i); if (i & (i - 1)) do_test (0, c, i); }