From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 723DA3858D1E for ; Tue, 8 Feb 2022 13:59:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 723DA3858D1E Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 218DmUPl029567 for ; Tue, 8 Feb 2022 13:59:30 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e22wj1nb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 08 Feb 2022 13:59:29 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 218DwfoV013288 for ; Tue, 8 Feb 2022 13:59:29 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 3e22wj1nak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 13:59:29 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 218Drivp017435; Tue, 8 Feb 2022 13:59:28 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma01wdc.us.ibm.com with ESMTP id 3e1gvac1n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Feb 2022 13:59:28 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 218DxRZv28836214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Feb 2022 13:59:27 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C34D6112069; Tue, 8 Feb 2022 13:59:27 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A661112065; Tue, 8 Feb 2022 13:59:26 +0000 (GMT) Received: from TP480.linux.ibm.com (unknown [9.65.93.177]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 8 Feb 2022 13:59:26 +0000 (GMT) References: <20220207201624.601598-1-goldstein.w.n@gmail.com> <20220207214136.3443442-1-goldstein.w.n@gmail.com> User-agent: mu4e 1.6.6; emacs 27.2 From: Matheus Castanho To: Noah Goldstein Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2] String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize' Date: Tue, 08 Feb 2022 10:14:32 -0300 In-reply-to: <20220207214136.3443442-1-goldstein.w.n@gmail.com> Message-ID: <87bkzhcvcz.fsf@linux.ibm.com> Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: TTvmxf3ihOJcCtAb4_2by-biMclw9-TK X-Proofpoint-ORIG-GUID: oa1cPuXYx7HFbjFDd4ZlbNHof8WmUMjp X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_04,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080084 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Tue, 08 Feb 2022 13:59:32 -0000 string/test-strcmp and wcsmbs/test-wcscmp are passing with this new patch, but string/test-strncmp and wcsmbs/test-wcsncmp are failing to compile. With the fix below all tests pass. Tested on powerpc, powerpc64 and powerpc64le. Noah Goldstein via Libc-alpha writes: > When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would > not be a multiple of system page size if system page size > 4096. > --- > string/test-strcmp.c | 14 +++++++------- > string/test-strncmp.c | 18 +++++++++--------- > 2 files changed, 16 insertions(+), 16 deletions(-) > > diff --git a/string/test-strcmp.c b/string/test-strcmp.c > index eacbdc8857..0abce769d0 100644 > --- a/string/test-strcmp.c > +++ b/string/test-strcmp.c > @@ -16,7 +16,7 @@ > License along with the GNU C Library; if not, see > . */ > > -#define TEST_LEN (4096 * 3) > +#define TEST_LEN (getpagesize () * 3) > #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ()) > > #define TEST_MAIN > @@ -393,7 +393,7 @@ int > test_main (void) > { > size_t i, j; > - > + const size_t test_len = MIN(TEST_LEN, 3 * 4096); > test_init (); > check(); > check2 (); > @@ -435,7 +435,7 @@ test_main (void) > > for (j = 0; j < 160; ++j) > { > - for (i = 0; i < TEST_LEN;) > + for (i = 0; i < test_len;) > { > do_test (getpagesize () - j - 1, 0, i, 127, 0); > do_test (getpagesize () - j - 1, 0, i, 127, 1); > @@ -461,17 +461,17 @@ test_main (void) > { > i += 7; > } > - else if (i + 161 < TEST_LEN) > + else if (i + 161 < test_len) > { > i += 31; > i *= 17; > i /= 16; > - if (i + 161 > TEST_LEN) > + if (i + 161 > test_len) > { > - i = TEST_LEN - 160; > + i = test_len - 160; > } > } > - else if (i + 32 < TEST_LEN) > + else if (i + 32 < test_len) > { > i += 7; > } > diff --git a/string/test-strncmp.c b/string/test-strncmp.c > index 1a3cee1792..1966bde3fe 100644 > --- a/string/test-strncmp.c > +++ b/string/test-strncmp.c > @@ -16,7 +16,7 @@ > License along with the GNU C Library; if not, see > . */ > > -#define TEST_LEN (4096 * 3) > +#define TEST_LEN (getpagesize () * 3) > #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ()) > > #define TEST_MAIN > @@ -430,7 +430,7 @@ check_overflow (void) > const size_t of_masks[] > = { ULONG_MAX, LONG_MIN, ULONG_MAX - (ULONG_MAX >> 2), > ((size_t)LONG_MAX) >> 1 }; > - > + const size_t test_len = MIN(test_len, 3 * 4096); Should be MIN(TEST_LEN, 3 * 4096) > for (of_idx = 0; of_idx < sizeof (of_masks) / sizeof (of_masks[0]); ++of_idx) > { > of_mask = of_masks[of_idx]; > @@ -484,7 +484,7 @@ check_overflow (void) > of_mask - j * 2, 0, 127, -1); > } > > - for (i = 1; i < TEST_LEN; i += i) > + for (i = 1; i < test_len; i += i) > { > do_test_n (j, 0, i - 1, of_mask, 0, 127, 0); > do_test_n (j, 0, i - 1, of_mask, 0, 127, 1); > @@ -540,7 +540,7 @@ int > test_main (void) > { > size_t i, j; > - > + const size_t test_len = MIN(test_len, 3 * 4096); Should be MIN(TEST_LEN, 3 * 4096) > test_init (); > > check1 (); > @@ -608,7 +608,7 @@ test_main (void) > > for (j = 0; j < 160; ++j) > { > - for (i = 0; i < TEST_LEN;) > + for (i = 0; i < test_len;) > { > do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 0); > do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 1); > @@ -677,17 +677,17 @@ test_main (void) > { > i += 7; > } > - else if (i + 161 < TEST_LEN) > + else if (i + 161 < test_len) > { > i += 31; > i *= 17; > i /= 16; > - if (i + 161 > TEST_LEN) > + if (i + 161 > test_len) > { > - i = TEST_LEN - 160; > + i = test_len - 160; > } > } > - else if (i + 32 < TEST_LEN) > + else if (i + 32 < test_len) > { > i += 7; > } -- Matheus Castanho