From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: "Martin Liška" <mliska@suse.cz>,
"Joseph Myers" <joseph@codesourcery.com>,
"DJ Delorie" <dj@redhat.com>
Cc: libc-alpha@sourceware.org, fw@deneb.enyo.de, schwab@linux-m68k.org
Subject: Re: [PATCH] Use size_t for mallinfo fields.
Date: Wed, 2 Sep 2020 10:34:09 -0300 [thread overview]
Message-ID: <c217b943-27cd-4315-f891-d23089ad519e@linaro.org> (raw)
In-Reply-To: <d9016a5d-5734-8164-7942-cbace560ba48@suse.cz>
On 02/09/2020 10:19, 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 <mliska@suse.cz>
> 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.
You still need to run 'make update-abi' for each supported architecture
and ABI variations to update each libc.abilist. And the missing symbol in
the libc.abilist should have raised a failure in the make check.
> ---
> 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 <malloc.h>
> #include <pthread.h>
> #include <assert.h>
> -#include <libc-diag.h>
>
> #include <support/check.h>
> #include <support/support.h>
> @@ -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++)
I think should be '%zu' since uordblks is a size_t.
> @@ -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
Same as before.
> @@ -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 <malloc.h>
> -#include <libc-diag.h>
> #include <support/check.h>
>
> 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 ();
> /* This will fail if there are any blocks in the fastbins. */
> TEST_COMPARE (m.smblks, 0);
>
> --
> 2.28.0
next prev parent reply other threads:[~2020-09-02 13:34 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 12:00 Martin Liška
2020-07-07 12:17 ` Andreas Schwab
2020-07-07 13:07 ` Martin Liška
2020-07-07 13:19 ` H.J. Lu
2020-07-07 13:49 ` Florian Weimer
2020-07-07 13:52 ` Martin Liška
2020-07-07 14:22 ` Florian Weimer
2020-07-07 14:32 ` Andreas Schwab
2020-07-07 14:36 ` Florian Weimer
2020-07-08 7:25 ` Martin Liška
2020-07-08 7:24 ` Martin Liška
2020-07-23 10:23 ` Martin Liška
2020-07-23 14:38 ` Szabolcs Nagy
2020-07-27 12:08 ` Martin Liška
2020-07-27 12:21 ` Florian Weimer
2020-07-27 12:45 ` Martin Liška
2020-08-11 12:26 ` Martin Liška
2020-08-11 13:44 ` Florian Weimer
2020-08-11 17:08 ` DJ Delorie
2020-08-12 12:29 ` Martin Liška
2020-08-24 9:55 ` Martin Liška
2020-08-28 19:05 ` DJ Delorie
2020-08-31 13:35 ` H.J. Lu
2020-08-31 13:56 ` Adhemerval Zanella
2020-08-31 14:00 ` H.J. Lu
2020-08-31 14:10 ` Adhemerval Zanella
2020-09-01 17:26 ` Joseph Myers
2020-09-02 13:19 ` Martin Liška
2020-09-02 13:34 ` Adhemerval Zanella [this message]
2020-09-02 14:00 ` Carlos O'Donell
2020-09-02 16:11 ` DJ Delorie
2020-09-21 8:49 ` Martin Liška
2020-09-02 20:16 ` DJ Delorie
2020-09-02 20:24 ` Florian Weimer
2020-09-02 21:04 ` [PATCH/v2] " DJ Delorie
2020-09-03 11:17 ` Adhemerval Zanella
2020-09-03 21:33 ` DJ Delorie
2020-09-17 23:02 ` DJ Delorie
2020-09-02 20:25 ` [PATCH] " Joseph Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c217b943-27cd-4315-f891-d23089ad519e@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=dj@redhat.com \
--cc=fw@deneb.enyo.de \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=mliska@suse.cz \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).