From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by sourceware.org (Postfix) with ESMTPS id D7BA7386F439 for ; Mon, 15 Jun 2020 21:34:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D7BA7386F439 Received: by mail-io1-xd42.google.com with SMTP id u13so2061102iol.10 for ; Mon, 15 Jun 2020 14:34:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jowGBsCO6nYqh5Oe6PjGwL2Yd+LzViqn6LGup9U/gbE=; b=slzOF02nLtmcVo2SVifd2e1Vflu6bu1H3IAnNTyNqVzfEL1FJuiFK0TIeN2ZPeNbI4 qHR0m0aWo0XLUZpkUTt6VQqr2CRgl+PIPJmHGwun01ndZG5VOwBulSXPGwGyEMz2lFja +l6s0HOlZrOY5UGZ0vBwHA3ko4JNJ7tbADz0KlK9PFPW3d/kOtBw28iJ55dBfSIXr/zY Y/YAnQbaTLnHPJe2FgH0JCusmpRN0D/N2joJeRVa24g1sapa+UvbJRvB/DiiB+RU/R9x QPlcKyFS61HUMPMpW+EkmbzPd6KW3jUkatrrCfRR9+rqL4ucrYClNga5bQl3+buwxBfL f2Iw== X-Gm-Message-State: AOAM532VClYEwYO6GPtwOl1J3tWnjL9hI/4GnGIPIjB6RbDd+CKM1dTH FkqunrChYFU7ZA4rQnx+MH1/CN92FmEWadX/tcePhP4s X-Google-Smtp-Source: ABdhPJwuw2HXhpAlhSNCA56i3AaOg1/xjmo8WH/BmT0y3idlEFMc70n1pLlqUjljml0ynAMFzm1ike1+p0n2O2YvUt0= X-Received: by 2002:a5e:c112:: with SMTP id v18mr30111581iol.37.1592256889296; Mon, 15 Jun 2020 14:34:49 -0700 (PDT) MIME-Version: 1.0 References: <20200612201056.228614-1-hjl.tools@gmail.com> <20200615202934.GA24739@oc3272150783.ibm.com> In-Reply-To: <20200615202934.GA24739@oc3272150783.ibm.com> From: "H.J. Lu" Date: Mon, 15 Jun 2020 14:34:13 -0700 Message-ID: Subject: Re: [PATCH 1/4] strncmp: Add a testcase for page boundary [BZ #25933] To: "Paul A. Clarke" Cc: GNU C Library , rzinsly@linux.ibm.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.7 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-List-Received-Date: Mon, 15 Jun 2020 21:34:51 -0000 On Mon, Jun 15, 2020 at 1:29 PM Paul A. Clarke wrote: > > On Fri, Jun 12, 2020 at 01:10:53PM -0700, H.J. Lu via Libc-alpha wrote: > > Add a strncmp testcase to cover cases where one of strings ends on the > > page boundary. > > --- > > string/test-strncmp.c | 25 +++++++++++++++++++++++++ > > 1 file changed, 25 insertions(+) > > > > diff --git a/string/test-strncmp.c b/string/test-strncmp.c > > index d961ac4493..d0928a2864 100644 > > --- a/string/test-strncmp.c > > +++ b/string/test-strncmp.c > > @@ -403,6 +403,30 @@ check2 (void) > > free (s2); > > } > > > > +static void > > +check3 (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; > > + > > + 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_STRNCMP (s1p, s2p, s); > > + FOR_EACH_IMPL (impl, 0) > > + check_result (impl, s1p, s2p, s, exp_result); > > + } > > +} > > There are lots of magic numbers here. > > Could you add some context around those number My commit log says --- Add a strncmp testcase to cover cases where one of strings ends on the page boundary. --- > If they are meant to reflect a cache line length, then it's No. My testcase is for correctness, not for performance. > appropriate to support different cache line sizes. > Rafael Zinsly just did this with strncasecmp in the > last week or so. > > > + > > int > > test_main (void) > > { > > @@ -412,6 +436,7 @@ test_main (void) > > > > check1 (); > > check2 (); > > + check3 (); > > > > printf ("%23s", ""); > > FOR_EACH_IMPL (impl, 0) > > -- > > 2.26.2 > > -- H.J.