From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id B12023894C0F for ; Wed, 2 Sep 2020 14:00:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B12023894C0F Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-66-dCchIlcyOOe-h1OvizGFKg-1; Wed, 02 Sep 2020 10:00:13 -0400 X-MC-Unique: dCchIlcyOOe-h1OvizGFKg-1 Received: by mail-qt1-f197.google.com with SMTP id z16so3504682qtq.16 for ; Wed, 02 Sep 2020 07:00:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=7TZWx3bRlqLvDcbie60SEK6W0Rzams5pdx639b0XVFI=; b=ms5f3FgqMRypg8j3IuDRKQHNuu42ZRTXCKrsjlqA76vaXLUphzBa7/dmp2NK073kF8 keJMsdOMgvkg0PCWVrz/kcicxgpusWSEqDFfv+zPlUkn/5MIFQNEINzFnb2s+vize5OD bWecKkGpFOI1STY50TcGl3kco7QOJ4iXMQ3Zdog3/vxrSjNjnRnswqwGtFjVCxo/lncB obnzuh1E4mSbMQWinU+Wo3qdocoWv7UISXKRwVlOQSFB1emRdJZEhh1Qf7xMlOA2dIBq 4qkefkD8FNcFocoWhl6DwFQMcFEMs2cZeI2a/cvet7yGcXJZHyyMZfXbfvCT1thi8w2L 3sFg== X-Gm-Message-State: AOAM531B4cNvfaaNwFwknOxQZJo3oRyJQqClV5T7VfFV/oW8WJgDoMGk 0+cJal3VRlzbJPLhXLUYPwzL8eRBuCDm5gt3Hq6Vnf7RBNG7JyZ2BPcs8QksrrUlA2lx7LBdy1b eU/T59j1JUrw1q3dyG4zt X-Received: by 2002:a05:620a:6c3:: with SMTP id 3mr6960563qky.426.1599055212321; Wed, 02 Sep 2020 07:00:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK9nPFuaYm3DEmhSJu7dLNFPPgBdPBaXeglgCrNanU2t6u83IPfJpOEyQD05Rz5MenEU+tUA== X-Received: by 2002:a05:620a:6c3:: with SMTP id 3mr6960531qky.426.1599055212040; Wed, 02 Sep 2020 07:00:12 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id a203sm4838439qkg.30.2020.09.02.07.00.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Sep 2020 07:00:11 -0700 (PDT) Subject: Re: [PATCH] Use size_t for mallinfo fields. To: =?UTF-8?Q?Martin_Li=c5=a1ka?= , Joseph Myers , DJ Delorie Cc: libc-alpha@sourceware.org, fw@deneb.enyo.de, schwab@linux-m68k.org References: From: Carlos O'Donell Organization: Red Hat Message-ID: <41ca0d4c-dab7-e7d0-4e63-e52cd5ff92cf@redhat.com> Date: Wed, 2 Sep 2020 10:00:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Wed, 02 Sep 2020 14:00:16 -0000 On 9/2/20 9:19 AM, Martin Liška wrote: > On 9/1/20 7:26 PM, Joseph Myers wrote: >> There are several key pieces missing from the mallinfo2 commit. >> >> * mallinfo2 is not added to GLIBC_2.33 in malloc/Versions.  So it's not >> exported from shared glibc, so it can't actually be used at all. >> >> * Once a function is exported from shared libc, all the ABI test baselines >> need updating accordingly. >> >> * Any new function needs a testcase added to the testsuite.  If there were >> such a test, it would have shown up the first problem of the function not >> being exported (that's why there should be tests even for e.g. syscall >> wrappers for syscalls that don't do anything useful as non-root - simply >> testing that it's possible to compile and link a call to each public >> function is useful). >> >> * Any new function should be mentioned as a new feature in the NEWS file. >> >> * Any deprecation should be listed under "Deprecated and removed features, >> and other changes affecting compatibility:" in the NEWS file. >> > > Hello. > > Thank you for the hints Joseph. There's patch that survives regression tests. > > Martin > From 18528c416f23be7dafe4a9bf631c91b6cbb3e0cb Mon Sep 17 00:00:00 2001 > From: Martin Liska > Date: Wed, 2 Sep 2020 15:17:25 +0200 > Subject: [PATCH] mallinfo2: add missing bits > > The patch adds the function to Versions and both tests > now test the function. The function is also mentioned in NEWS. > --- > NEWS | 5 ++++- > malloc/Versions | 3 +++ > malloc/tst-malloc-tcache-leak.c | 17 +++++------------ > malloc/tst-mxfast.c | 12 ++---------- > 4 files changed, 14 insertions(+), 23 deletions(-) > > diff --git a/NEWS b/NEWS > index 06e43e0453..b21e5244ab 100644 > --- a/NEWS > +++ b/NEWS > @@ -20,9 +20,12 @@ Major new features: > The 32-bit RISC-V port requires at least Linux 5.4, GCC 7.1 and binutils > 2.28. > > +* A new function mallinfo2 (replaces mallinfo) uses size_t for values returned > + in mallinfo2 struct. > + > Deprecated and removed features, and other changes affecting compatibility: > > - [Add deprecations, removals and changes affecting compatibility here] > +* Function mallinfo is deprecated. > > Changes to build and runtime requirements: > > diff --git a/malloc/Versions b/malloc/Versions > index 2357cff3da..94c8ba8040 100644 > --- a/malloc/Versions > +++ b/malloc/Versions > @@ -64,6 +64,9 @@ libc { > GLIBC_2.26 { > reallocarray; > } > + GLIBC_2.33 { > + mallinfo2; > + } > GLIBC_PRIVATE { > # Internal startup hook for libpthread. > __libc_malloc_pthread_startup; > diff --git a/malloc/tst-malloc-tcache-leak.c b/malloc/tst-malloc-tcache-leak.c > index 2a7a0646c5..ae5e1fd252 100644 > --- a/malloc/tst-malloc-tcache-leak.c > +++ b/malloc/tst-malloc-tcache-leak.c > @@ -29,7 +29,6 @@ > #include > #include > #include > -#include > > #include > #include > @@ -61,7 +60,7 @@ static int > do_test (void) > { > pthread_t *thread; > - struct mallinfo info_before, info_after; > + struct mallinfo2 info_before, info_after; > void *retval; > > /* This is an arbitrary choice. We choose a total of THREADS > @@ -73,15 +72,11 @@ do_test (void) > pthread_t required to run the test. */ > thread = (pthread_t *) xcalloc (1, sizeof (pthread_t)); > > - /* The test below covers the deprecated mallinfo function. */ > - DIAG_PUSH_NEEDS_COMMENT; > - DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations"); > - > - info_before = mallinfo (); > + info_before = mallinfo2 (); > > assert (info_before.uordblks != 0); > > - printf ("INFO: %d (bytes) are in use before starting threads.\n", > + printf ("INFO: %ld (bytes) are in use before starting threads.\n", > info_before.uordblks); > > for (int loop = 0; loop < threads; loop++) > @@ -91,8 +86,8 @@ do_test (void) > free (retval); > } > > - info_after = mallinfo (); > - printf ("INFO: %d (bytes) are in use after all threads joined.\n", > + info_after = mallinfo2 (); > + printf ("INFO: %ld (bytes) are in use after all threads joined.\n", > info_after.uordblks); > > /* We need to compare the memory in use before and the memory in use > @@ -109,8 +104,6 @@ do_test (void) > if (info_after.uordblks > (info_before.uordblks + threads)) > FAIL_EXIT1 ("Memory usage after threads is too high.\n"); > > - DIAG_POP_NEEDS_COMMENT; > - > /* Did not detect excessive memory usage. */ > free (thread); > exit (0); > diff --git a/malloc/tst-mxfast.c b/malloc/tst-mxfast.c > index 8afee0f9d5..0a41e1112c 100644 > --- a/malloc/tst-mxfast.c > +++ b/malloc/tst-mxfast.c > @@ -21,13 +21,12 @@ > the fast bins. */ > > #include > -#include > #include > > int > do_test (void) > { > - struct mallinfo m; > + struct mallinfo2 m; > char *volatile p1; > char *volatile p2; > > @@ -37,14 +36,7 @@ do_test (void) > p2 = malloc (512); > free (p1); > > - /* The test below covers the deprecated mallinfo function. */ > - DIAG_PUSH_NEEDS_COMMENT; > - DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations"); > - > - m = mallinfo (); > - > - DIAG_POP_NEEDS_COMMENT; > - > + m = mallinfo2 (); Why are we removing testing for mallinfo? We need to continue to test old interfaces. If we add a new function we need a new test that exercise the new function and the differences. > /* This will fail if there are any blocks in the fastbins. */ > TEST_COMPARE (m.smblks, 0); > > -- > 2.28.0 > -- Cheers, Carlos.