From patchwork Mon Apr 19 19:35:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 43050 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 CA5D1385E02F; Mon, 19 Apr 2021 19:35:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA5D1385E02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1618860949; 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=QmZd32YzFXaR/K1gqF8pN8XN9ImEgTZnx6Ht6Azt74V8ZQ+tBp9ErAPEW678rbHNr kKhX9ADYzRwSpCn1OrwVuNw2x9x+OSHS69f9M1/fJMJI4Vbdjbxl9eUmHFv1ENaXJu R2KhFeb0m4CeNebqDrCW+TKSxMPZu/a9+ntdlI8E= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by sourceware.org (Postfix) with ESMTPS id 19A233968C39 for ; Mon, 19 Apr 2021 19:35:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 19A233968C39 Received: by mail-qk1-x72e.google.com with SMTP id q136so16075566qka.7 for ; Mon, 19 Apr 2021 12:35:42 -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=Z/YDS1H5Nw0tVMIHPhU8RKu050JeIX0u4ofebwNlB+vtjnzsBJ6idcqN/pyqJt83WG Qi7SEVuUwpUiFrezr0v6GBOQ0UG1t3cg3LJupmPkr9qoCX5Iv2N3Wb/aQBxThWno6rm+ iTrmDqbG8e+Y5mgSf1y8MkrdDgmcna4mAbroBbgIknzRA8dnd28noTE3tG8Yes6Qrr6R bxcFMWt5Z1f+CqQSjq4x5mYhMnwIYMIKTWOfeZr5cKs+qn1Z9U4P2NMEMuVbXEmHcuoq C8YEb8o/fjtZ+6t4JK3hBBt1mADC1IkUgUUj/+0FOsRNDX1fu68FW0ztRLg8dKDwOx0B i1zg== X-Gm-Message-State: AOAM533iXydXoDlcUtFsor1E9nWIc6LEi07ObdDDdzNoEtRi7sscjYeC wSMTt5BBFbXxQS6AN1GR8XWR9Y2bmeQ= X-Google-Smtp-Source: ABdhPJyPZKPeQddUY7qM5yfCQID/sIE3adigxQ6ZfRu+dM2g/3N8KuYKESiXpFogqKTz5MGnZk7K1Q== X-Received: by 2002:a05:620a:110f:: with SMTP id o15mr13636484qkk.305.1618860941576; Mon, 19 Apr 2021 12:35:41 -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 b65sm110440qkc.119.2021.04.19.12.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 12:35:41 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v3 2/2] x86: Expand test-memset.c and bench-memset.c Date: Mon, 19 Apr 2021 15:35:02 -0400 Message-Id: <20210419193502.586936-2-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210419193502.586936-1-goldstein.w.n@gmail.com> References: <20210419193502.586936-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); }