Message ID | 20200612201056.228614-2-hjl.tools@gmail.com |
---|---|
State | Committed |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> 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 1DC0D395B801; Fri, 12 Jun 2020 20:11:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DC0D395B801 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1591992662; bh=bLI+A2N7zfWLZEvWReVHOVzPVg78x1EZzujvS6NJltA=; 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=KDMtuTNCSTEZN3Xoj8kpQb6g+k7m5mCsPe4i3cFHIRqZ1B5a2jfMqvhox/0PiueGp QgskkNTSqUsVK3FWxDF/o6d2xsIAyEqB8JNwmIgFKwAkorgVfDF19GS1IOyLM8oHIo 0aM8RQ9HyLHXeT6bFVjqqRfgqDl5YQcnVXmUyzzg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by sourceware.org (Postfix) with ESMTPS id 1ADF0394800A for <libc-alpha@sourceware.org>; Fri, 12 Jun 2020 20:10:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1ADF0394800A Received: by mail-pj1-x1043.google.com with SMTP id k2so4080570pjs.2 for <libc-alpha@sourceware.org>; Fri, 12 Jun 2020 13:10:59 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bLI+A2N7zfWLZEvWReVHOVzPVg78x1EZzujvS6NJltA=; b=Chue4FR272cHCURnEx3XvNIjKz4pZy4s4NXSY1hPD/AktYxEnzyDjzcg3ecUs6EwmU bXyE2b/xlMk5eKL/JQfhwRd9EXf4YhJhLePerDPPThyRPkA4cQVkj9AO1y+/MR+AMbXC h/mf93jM70+62OYnyv/hXQj9LWVtmnfeq7XrLfmtXu8WVQtDr0snAgKqe6AFzLXS+8hZ 3TDUVg10Y1MeZWQgFKYGlTscT0+qxzPZo8VpbOk4Eme5Ij2JFU+ItOkDFI2rzZxXHpf1 FmvXboh3f9KJQFo9blgxK7YnGuU+CAQ6o1wsx/K0w1qD8LxGlJ9eojvUbx2fkbHBayMx +dhw== X-Gm-Message-State: AOAM5321ZBBGXlcAZZNNowrZqjjRJ6eZ4yLsWrtLDcFC1jWBkr0ZMb8S CCzHKAg0cjNFw+XHP36jXAmBFAKH X-Google-Smtp-Source: ABdhPJzdXLZ0dP4EbNYstFaHYVSaYZdxoTEwAqRFmRtu21yHac96whhFJGqkWCfhkMYSC7FEnbF9Pg== X-Received: by 2002:a17:902:8544:: with SMTP id d4mr7322922plo.234.1591992658054; Fri, 12 Jun 2020 13:10:58 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id p19sm6889352pff.116.2020.06.12.13.10.57 for <libc-alpha@sourceware.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 13:10:57 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 4C3B11A0140 for <libc-alpha@sourceware.org>; Fri, 12 Jun 2020 13:10:56 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 2/4] strcmp: Add a testcase for page boundary Date: Fri, 12 Jun 2020 13:10:54 -0700 Message-Id: <20200612201056.228614-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612201056.228614-1-hjl.tools@gmail.com> References: <20200612201056.228614-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.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 <libc-alpha.sourceware.org> List-Unsubscribe: <http://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <http://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org> Reply-To: "H.J. Lu" <hjl.tools@gmail.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
[1/4] strncmp: Add a testcase for page boundary [BZ #25933]
|
|
Commit Message
H.J. Lu
June 12, 2020, 8:10 p.m. UTC
Add a strncmp testcase to cover cases where both strings end on the page boundary. --- string/test-strcmp.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
Comments
On 6/12/20 4:10 PM, H.J. Lu via Libc-alpha wrote: > Add a strncmp testcase to cover cases where both strings end on the > page boundary. > --- > string/test-strcmp.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > OK to commit if you: - Add all the comments. - s1a iterates over [30,32). Reviewed-by: Carlos O'Donell <carlos@redhat.com> > diff --git a/string/test-strcmp.c b/string/test-strcmp.c > index 8d4784de80..41d95567c7 100644 > --- a/string/test-strcmp.c > +++ b/string/test-strcmp.c > @@ -359,6 +359,30 @@ check (void) > } > } > Add a comment: /* To trigger bug 25933 we need a size that is equal to the vector length times 4. In the case of AVX2 for Intel we need 32 * 4. We make this test generic and run it for all architectures as additional boundary testing for such related algorithms. */ > +static void > +check2 (void) > +{ > + size_t size = 32 * 4; > + CHAR *s1 = (CHAR *) (buf1 + (BUF1PAGES - 1) * page_size); > + CHAR *s2 = (CHAR *) (buf2 + (BUF1PAGES - 1) * page_size); > + int exp_result; > + > + memset (s1, 'a', page_size); > + memset (s2, 'a', page_size); > + s1[(page_size / CHARBYTES) - 1] = (CHAR) 0; > + s2[(page_size / CHARBYTES) - 1] = (CHAR) 0; > + Add comment: /* Iterate over a size that is just below where we expect the bug to trigger up to the size we expect will trigger the bug e.g. [99-128]. Likewise iterate the start of two strings between 30 and 31 bytes away from the boundary to simulate alignment changes. */ > + for (size_t s = 99; s <= size; s++) > + for (size_t s1a = 31; s1a < 32; s1a++) Please make s1a iterate over [30,32) like s2a. > + for (size_t s2a = 30; s2a < 32; s2a++) > + { > + CHAR *s1p = s1 + (page_size / CHARBYTES - s) - s1a; > + CHAR *s2p = s2 + (page_size / CHARBYTES - s) - s2a; > + exp_result = SIMPLE_STRCMP (s1p, s2p); > + FOR_EACH_IMPL (impl, 0) > + check_result (impl, s1p, s2p, exp_result); > + } > +} > > int > test_main (void) > @@ -367,6 +391,7 @@ test_main (void) > > test_init (); > check(); > + check2 (); > > printf ("%23s", ""); > FOR_EACH_IMPL (impl, 0) >
On Wed, Sep 23, 2020 at 5:46 PM Carlos O'Donell <carlos@redhat.com> wrote: > > On 6/12/20 4:10 PM, H.J. Lu via Libc-alpha wrote: > > Add a strncmp testcase to cover cases where both strings end on the > > page boundary. > > --- > > string/test-strcmp.c | 25 +++++++++++++++++++++++++ > > 1 file changed, 25 insertions(+) > > > > OK to commit if you: > - Add all the comments. > - s1a iterates over [30,32). > > Reviewed-by: Carlos O'Donell <carlos@redhat.com> > > > diff --git a/string/test-strcmp.c b/string/test-strcmp.c > > index 8d4784de80..41d95567c7 100644 > > --- a/string/test-strcmp.c > > +++ b/string/test-strcmp.c > > @@ -359,6 +359,30 @@ check (void) > > } > > } > > > > Add a comment: > > /* To trigger bug 25933 we need a size that is equal to the > vector length times 4. In the case of AVX2 for Intel we > need 32 * 4. We make this test generic and run it for all > architectures as additional boundary testing for such > related algorithms. */ > > > +static void > > +check2 (void) > > +{ > > + size_t size = 32 * 4; > > + CHAR *s1 = (CHAR *) (buf1 + (BUF1PAGES - 1) * page_size); > > + CHAR *s2 = (CHAR *) (buf2 + (BUF1PAGES - 1) * page_size); > > + int exp_result; > > + > > + memset (s1, 'a', page_size); > > + memset (s2, 'a', page_size); > > + s1[(page_size / CHARBYTES) - 1] = (CHAR) 0; > > + s2[(page_size / CHARBYTES) - 1] = (CHAR) 0; > > + > > Add comment: > > /* Iterate over a size that is just below where we expect > the bug to trigger up to the size we expect will trigger > the bug e.g. [99-128]. Likewise iterate the start of > two strings between 30 and 31 bytes away from the > boundary to simulate alignment changes. */ > > > + for (size_t s = 99; s <= size; s++) > > + for (size_t s1a = 31; s1a < 32; s1a++) > > Please make s1a iterate over [30,32) like s2a. > > > + for (size_t s2a = 30; s2a < 32; s2a++) > > + { > > + CHAR *s1p = s1 + (page_size / CHARBYTES - s) - s1a; > > + CHAR *s2p = s2 + (page_size / CHARBYTES - s) - s2a; > > + exp_result = SIMPLE_STRCMP (s1p, s2p); > > + FOR_EACH_IMPL (impl, 0) > > + check_result (impl, s1p, s2p, exp_result); > > + } > > +} > > > > int > > test_main (void) > > @@ -367,6 +391,7 @@ test_main (void) > > > > test_init (); > > check(); > > + check2 (); > > > > printf ("%23s", ""); > > FOR_EACH_IMPL (impl, 0) > > > This is the updated patch I am checking in. Thanks.
diff --git a/string/test-strcmp.c b/string/test-strcmp.c index 8d4784de80..41d95567c7 100644 --- a/string/test-strcmp.c +++ b/string/test-strcmp.c @@ -359,6 +359,30 @@ check (void) } } +static void +check2 (void) +{ + size_t size = 32 * 4; + CHAR *s1 = (CHAR *) (buf1 + (BUF1PAGES - 1) * page_size); + CHAR *s2 = (CHAR *) (buf2 + (BUF1PAGES - 1) * page_size); + int exp_result; + + memset (s1, 'a', page_size); + memset (s2, 'a', page_size); + s1[(page_size / CHARBYTES) - 1] = (CHAR) 0; + s2[(page_size / CHARBYTES) - 1] = (CHAR) 0; + + for (size_t s = 99; s <= size; s++) + for (size_t s1a = 31; s1a < 32; s1a++) + for (size_t s2a = 30; s2a < 32; s2a++) + { + CHAR *s1p = s1 + (page_size / CHARBYTES - s) - s1a; + CHAR *s2p = s2 + (page_size / CHARBYTES - s) - s2a; + exp_result = SIMPLE_STRCMP (s1p, s2p); + FOR_EACH_IMPL (impl, 0) + check_result (impl, s1p, s2p, exp_result); + } +} int test_main (void) @@ -367,6 +391,7 @@ test_main (void) test_init (); check(); + check2 (); printf ("%23s", ""); FOR_EACH_IMPL (impl, 0)