public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use size_t for mallinfo fields.
@ 2020-07-07 12:00 Martin Liška
  2020-07-07 12:17 ` Andreas Schwab
  0 siblings, 1 reply; 39+ messages in thread
From: Martin Liška @ 2020-07-07 12:00 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

Hi.

The current int type can easily overflow for allocation of more
than 4GB.

The following patch changes that to size_t. I guess I need to adjust
the API version of the function, right?

Thanks,
Martin

---
  malloc/malloc.h    | 20 ++++++++++----------
  manual/memory.texi | 22 +++++++++++-----------
  2 files changed, 21 insertions(+), 21 deletions(-)



[-- Attachment #2: 0001-Use-size_t-for-mallinfo-fields.patch --]
[-- Type: text/x-patch, Size: 3018 bytes --]

diff --git a/malloc/malloc.h b/malloc/malloc.h
index a6903fdd54..785c38e164 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -85,16 +85,16 @@ __THROW __attribute_malloc__;
 
 struct mallinfo
 {
-  int arena;    /* non-mmapped space allocated from system */
-  int ordblks;  /* number of free chunks */
-  int smblks;   /* number of fastbin blocks */
-  int hblks;    /* number of mmapped regions */
-  int hblkhd;   /* space in mmapped regions */
-  int usmblks;  /* always 0, preserved for backwards compatibility */
-  int fsmblks;  /* space available in freed fastbin blocks */
-  int uordblks; /* total allocated space */
-  int fordblks; /* total free space */
-  int keepcost; /* top-most, releasable (via malloc_trim) space */
+  size_t arena;    /* non-mmapped space allocated from system */
+  size_t ordblks;  /* number of free chunks */
+  size_t smblks;   /* number of fastbin blocks */
+  size_t hblks;    /* number of mmapped regions */
+  size_t hblkhd;   /* space in mmapped regions */
+  size_t usmblks;  /* always 0, preserved for backwards compatibility */
+  size_t fsmblks;  /* space available in freed fastbin blocks */
+  size_t uordblks; /* total allocated space */
+  size_t fordblks; /* total free space */
+  size_t keepcost; /* top-most, releasable (via malloc_trim) space */
 };
 
 /* Returns a copy of the updated current mallinfo. */
diff --git a/manual/memory.texi b/manual/memory.texi
index aa5011e4f9..ac803dd2d5 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -1516,39 +1516,39 @@ This structure type is used to return information about the dynamic
 memory allocator.  It contains the following members:
 
 @table @code
-@item int arena
+@item size_t arena
 This is the total size of memory allocated with @code{sbrk} by
 @code{malloc}, in bytes.
 
-@item int ordblks
+@item size_t ordblks
 This is the number of chunks not in use.  (The memory allocator
-internally gets chunks of memory from the operating system, and then
+size_ternally gets chunks of memory from the operating system, and then
 carves them up to satisfy individual @code{malloc} requests;
 @pxref{The GNU Allocator}.)
 
-@item int smblks
+@item size_t smblks
 This field is unused.
 
-@item int hblks
+@item size_t hblks
 This is the total number of chunks allocated with @code{mmap}.
 
-@item int hblkhd
+@item size_t hblkhd
 This is the total size of memory allocated with @code{mmap}, in bytes.
 
-@item int usmblks
+@item size_t usmblks
 This field is unused and always 0.
 
-@item int fsmblks
+@item size_t fsmblks
 This field is unused.
 
-@item int uordblks
+@item size_t uordblks
 This is the total size of memory occupied by chunks handed out by
 @code{malloc}.
 
-@item int fordblks
+@item size_t fordblks
 This is the total size of memory occupied by free (not in use) chunks.
 
-@item int keepcost
+@item size_t keepcost
 This is the size of the top-most releasable chunk that normally
 borders the end of the heap (i.e., the high end of the virtual address
 space's data segment).


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-07 12:00 [PATCH] Use size_t for mallinfo fields Martin Liška
@ 2020-07-07 12:17 ` Andreas Schwab
  2020-07-07 13:07   ` Martin Liška
  0 siblings, 1 reply; 39+ messages in thread
From: Andreas Schwab @ 2020-07-07 12:17 UTC (permalink / raw)
  To: Martin Liška; +Cc: libc-alpha

On Jul 07 2020, Martin Liška wrote:

> The current int type can easily overflow for allocation of more
> than 4GB.
>
> The following patch changes that to size_t. I guess I need to adjust
> the API version of the function, right?

Not only that, it breaks the ABI of mallinfo.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  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
  0 siblings, 2 replies; 39+ messages in thread
From: Martin Liška @ 2020-07-07 13:07 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

On 7/7/20 2:17 PM, Andreas Schwab wrote:
> On Jul 07 2020, Martin Liška wrote:
> 
>> The current int type can easily overflow for allocation of more
>> than 4GB.
>>
>> The following patch changes that to size_t. I guess I need to adjust
>> the API version of the function, right?
> 
> Not only that, it breaks the ABI of mallinfo.

Sure, so what options do I have? I'm new to glibc so a hint would be appreciated.

Thanks,
Martin

> 
> Andreas.
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-07 13:07   ` Martin Liška
@ 2020-07-07 13:19     ` H.J. Lu
  2020-07-07 13:49     ` Florian Weimer
  1 sibling, 0 replies; 39+ messages in thread
From: H.J. Lu @ 2020-07-07 13:19 UTC (permalink / raw)
  To: Martin Liška; +Cc: Andreas Schwab, GNU C Library

On Tue, Jul 7, 2020 at 6:08 AM Martin Liška <mliska@suse.cz> wrote:
>
> On 7/7/20 2:17 PM, Andreas Schwab wrote:
> > On Jul 07 2020, Martin Liška wrote:
> >
> >> The current int type can easily overflow for allocation of more
> >> than 4GB.
> >>
> >> The following patch changes that to size_t. I guess I need to adjust
> >> the API version of the function, right?
> >
> > Not only that, it breaks the ABI of mallinfo.
>
> Sure, so what options do I have? I'm new to glibc so a hint would be appreciated.
>

You need to keep the old version of mallinfo in libc.so.  There are
plenty of examples
in glibc source:

malloc/hooks.c:#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_25)
malloc/hooks.c:#endif   /* SHLIB_COMPAT */
malloc/malloc.c:#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_24)
malloc/malloc.c:#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_26)
malloc/obstack.c:#  if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)

-- 
H.J.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  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
  1 sibling, 1 reply; 39+ messages in thread
From: Florian Weimer @ 2020-07-07 13:49 UTC (permalink / raw)
  To: Martin Liška; +Cc: Andreas Schwab, libc-alpha

* Martin Liška:

> On 7/7/20 2:17 PM, Andreas Schwab wrote:
>> On Jul 07 2020, Martin Liška wrote:
>>
>>> The current int type can easily overflow for allocation of more
>>> than 4GB.
>>>
>>> The following patch changes that to size_t. I guess I need to adjust
>>> the API version of the function, right?
>>
>> Not only that, it breaks the ABI of mallinfo.
>
> Sure, so what options do I have? I'm new to glibc so a hint would be
> appreciated.

We need to add a new function.  Symbol versioning does not work because
mallinfo is interposed by alternative mallocs (tcmalloc, Address
Sanitizer, etc.).  Without the new function name, the interposer does
not know which ABI the application expects, so it's going to be quite
messy.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-07 13:49     ` Florian Weimer
@ 2020-07-07 13:52       ` Martin Liška
  2020-07-07 14:22         ` Florian Weimer
  0 siblings, 1 reply; 39+ messages in thread
From: Martin Liška @ 2020-07-07 13:52 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Andreas Schwab, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]

On 7/7/20 3:49 PM, Florian Weimer wrote:
> * Martin Liška:
> 
>> On 7/7/20 2:17 PM, Andreas Schwab wrote:
>>> On Jul 07 2020, Martin Liška wrote:
>>>
>>>> The current int type can easily overflow for allocation of more
>>>> than 4GB.
>>>>
>>>> The following patch changes that to size_t. I guess I need to adjust
>>>> the API version of the function, right?
>>>
>>> Not only that, it breaks the ABI of mallinfo.
>>
>> Sure, so what options do I have? I'm new to glibc so a hint would be
>> appreciated.
> 
> We need to add a new function.  Symbol versioning does not work because
> mallinfo is interposed by alternative mallocs (tcmalloc, Address
> Sanitizer, etc.).  Without the new function name, the interposer does
> not know which ABI the application expects, so it's going to be quite
> messy.
> 
> Thanks,
> Florian
> 

All right, am I closer with the suggested patch?

Martin

[-- Attachment #2: 0001-Use-size_t-for-mallinfo-fields.patch --]
[-- Type: text/x-patch, Size: 4840 bytes --]

From 514b41592d8f435d066817580e0cec29df15b818 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 7 Jul 2020 13:58:24 +0200
Subject: [PATCH] Use size_t for mallinfo fields.

The current int type can easily overflow for allocation of more
than 4GB.
---
 malloc/malloc.c    | 27 ++++++++++++++++++++++++++-
 malloc/malloc.h    | 16 +++++++++++++++-
 manual/memory.texi | 22 +++++++++++-----------
 3 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index ee87ddbbf9..9944473a72 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -640,6 +640,8 @@ libc_hidden_proto (__libc_mallopt)
 */
 struct mallinfo __libc_mallinfo(void);
 
+struct mallinfo_compat __libc_mallinfo_compat(void);
+
 
 /*
   pvalloc(size_t n);
@@ -4998,6 +5000,27 @@ __libc_mallinfo (void)
   return m;
 }
 
+struct mallinfo_compat
+__libc_mallinfo_compat (void)
+{
+  struct mallinfo_compat m;
+  struct mallinfo mnew = __libc_mallinfo ();
+
+  m.arena = mnew.arena;
+  m.ordblks = mnew.ordblks;
+  m.smblks = mnew.smblks;
+  m.hblks = mnew.hblks;
+  m.hblkhd = mnew.hblkhd;
+  m.usmblks = mnew.usmblks;
+  m.fsmblks = mnew.fsmblks;
+  m.uordblks = mnew.uordblks;
+  m.fordblks = mnew.fordblks;
+  m.keepcost = mnew.keepcost;
+
+  return m;
+}
+
+
 /*
    ------------------------------ malloc_stats ------------------------------
  */
@@ -5630,8 +5653,10 @@ weak_alias (__libc_memalign, memalign)
 strong_alias (__libc_realloc, __realloc) strong_alias (__libc_realloc, realloc)
 strong_alias (__libc_valloc, __valloc) weak_alias (__libc_valloc, valloc)
 strong_alias (__libc_pvalloc, __pvalloc) weak_alias (__libc_pvalloc, pvalloc)
-strong_alias (__libc_mallinfo, __mallinfo)
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32)
 weak_alias (__libc_mallinfo, mallinfo)
+compat_symbol (libc, __libc_mallinfo_compat, mallinfo, GLIBC_2_32);
+#endif
 strong_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt)
 
 weak_alias (__malloc_stats, malloc_stats)
diff --git a/malloc/malloc.h b/malloc/malloc.h
index a6903fdd54..500012bea8 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -83,7 +83,7 @@ __THROW __attribute_malloc__;
 
 /* SVID2/XPG mallinfo structure */
 
-struct mallinfo
+struct mallinfo_compat
 {
   int arena;    /* non-mmapped space allocated from system */
   int ordblks;  /* number of free chunks */
@@ -97,6 +97,20 @@ struct mallinfo
   int keepcost; /* top-most, releasable (via malloc_trim) space */
 };
 
+struct mallinfo
+{
+  size_t arena;    /* non-mmapped space allocated from system */
+  size_t ordblks;  /* number of free chunks */
+  size_t smblks;   /* number of fastbin blocks */
+  size_t hblks;    /* number of mmapped regions */
+  size_t hblkhd;   /* space in mmapped regions */
+  size_t usmblks;  /* always 0, preserved for backwards compatibility */
+  size_t fsmblks;  /* space available in freed fastbin blocks */
+  size_t uordblks; /* total allocated space */
+  size_t fordblks; /* total free space */
+  size_t keepcost; /* top-most, releasable (via malloc_trim) space */
+};
+
 /* Returns a copy of the updated current mallinfo. */
 extern struct mallinfo mallinfo (void) __THROW;
 
diff --git a/manual/memory.texi b/manual/memory.texi
index aa5011e4f9..ac803dd2d5 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -1516,39 +1516,39 @@ This structure type is used to return information about the dynamic
 memory allocator.  It contains the following members:
 
 @table @code
-@item int arena
+@item size_t arena
 This is the total size of memory allocated with @code{sbrk} by
 @code{malloc}, in bytes.
 
-@item int ordblks
+@item size_t ordblks
 This is the number of chunks not in use.  (The memory allocator
-internally gets chunks of memory from the operating system, and then
+size_ternally gets chunks of memory from the operating system, and then
 carves them up to satisfy individual @code{malloc} requests;
 @pxref{The GNU Allocator}.)
 
-@item int smblks
+@item size_t smblks
 This field is unused.
 
-@item int hblks
+@item size_t hblks
 This is the total number of chunks allocated with @code{mmap}.
 
-@item int hblkhd
+@item size_t hblkhd
 This is the total size of memory allocated with @code{mmap}, in bytes.
 
-@item int usmblks
+@item size_t usmblks
 This field is unused and always 0.
 
-@item int fsmblks
+@item size_t fsmblks
 This field is unused.
 
-@item int uordblks
+@item size_t uordblks
 This is the total size of memory occupied by chunks handed out by
 @code{malloc}.
 
-@item int fordblks
+@item size_t fordblks
 This is the total size of memory occupied by free (not in use) chunks.
 
-@item int keepcost
+@item size_t keepcost
 This is the size of the top-most releasable chunk that normally
 borders the end of the heap (i.e., the high end of the virtual address
 space's data segment).
-- 
2.27.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-07 13:52       ` Martin Liška
@ 2020-07-07 14:22         ` Florian Weimer
  2020-07-07 14:32           ` Andreas Schwab
  2020-07-08  7:24           ` Martin Liška
  0 siblings, 2 replies; 39+ messages in thread
From: Florian Weimer @ 2020-07-07 14:22 UTC (permalink / raw)
  To: Martin Liška; +Cc: Andreas Schwab, libc-alpha

* Martin Liška:

> On 7/7/20 3:49 PM, Florian Weimer wrote:
>> * Martin Liška:
>>
>>> On 7/7/20 2:17 PM, Andreas Schwab wrote:
>>>> On Jul 07 2020, Martin Liška wrote:
>>>>
>>>>> The current int type can easily overflow for allocation of more
>>>>> than 4GB.
>>>>>
>>>>> The following patch changes that to size_t. I guess I need to adjust
>>>>> the API version of the function, right?
>>>>
>>>> Not only that, it breaks the ABI of mallinfo.
>>>
>>> Sure, so what options do I have? I'm new to glibc so a hint would be
>>> appreciated.
>>
>> We need to add a new function.  Symbol versioning does not work because
>> mallinfo is interposed by alternative mallocs (tcmalloc, Address
>> Sanitizer, etc.).  Without the new function name, the interposer does
>> not know which ABI the application expects, so it's going to be quite
>> messy.

> All right, am I closer with the suggested patch?

If what I wrote above is right (we'd first gather consensus around
that), we should probably add struct mallinfo2 and mallinfo2, deprecate
the original mallinfo function, and eventually remove them from the
public API (turning the original mallinfo into a compatibility symbol).

I suppose it would make sense to raise this issue with the tcmalloc, tbb
and Address Sanitizer people, to see if they would be willing to
implement mallinfo2 on their end.

The end result, having mallinfo2 and not mallinfo, is a bit ugly, but
it's an improvement over the current state.  I do not see a need to get
creative with symbol redirects or symbol versions.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  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:24           ` Martin Liška
  1 sibling, 1 reply; 39+ messages in thread
From: Andreas Schwab @ 2020-07-07 14:32 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Martin Liška, libc-alpha

On Jul 07 2020, Florian Weimer wrote:

> If what I wrote above is right (we'd first gather consensus around
> that), we should probably add struct mallinfo2 and mallinfo2, deprecate
> the original mallinfo function, and eventually remove them from the
> public API (turning the original mallinfo into a compatibility symbol).

Isn't mallinfo obsoleted by malloc_info anyway?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-07 14:32           ` Andreas Schwab
@ 2020-07-07 14:36             ` Florian Weimer
  2020-07-08  7:25               ` Martin Liška
  0 siblings, 1 reply; 39+ messages in thread
From: Florian Weimer @ 2020-07-07 14:36 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Martin Liška, libc-alpha

* Andreas Schwab:

> On Jul 07 2020, Florian Weimer wrote:
>
>> If what I wrote above is right (we'd first gather consensus around
>> that), we should probably add struct mallinfo2 and mallinfo2, deprecate
>> the original mallinfo function, and eventually remove them from the
>> public API (turning the original mallinfo into a compatibility symbol).
>
> Isn't mallinfo obsoleted by malloc_info anyway?

None of the malloc alternatives seem to have picked it up.

Martin, why do you want to change mallinfo, rather than switching to
malloc_info?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-07 14:22         ` Florian Weimer
  2020-07-07 14:32           ` Andreas Schwab
@ 2020-07-08  7:24           ` Martin Liška
  2020-07-23 10:23             ` Martin Liška
  2020-07-23 14:38             ` Szabolcs Nagy
  1 sibling, 2 replies; 39+ messages in thread
From: Martin Liška @ 2020-07-08  7:24 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Andreas Schwab, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1787 bytes --]

On 7/7/20 4:22 PM, Florian Weimer wrote:
> * Martin Liška:
> 
>> On 7/7/20 3:49 PM, Florian Weimer wrote:
>>> * Martin Liška:
>>>
>>>> On 7/7/20 2:17 PM, Andreas Schwab wrote:
>>>>> On Jul 07 2020, Martin Liška wrote:
>>>>>
>>>>>> The current int type can easily overflow for allocation of more
>>>>>> than 4GB.
>>>>>>
>>>>>> The following patch changes that to size_t. I guess I need to adjust
>>>>>> the API version of the function, right?
>>>>>
>>>>> Not only that, it breaks the ABI of mallinfo.
>>>>
>>>> Sure, so what options do I have? I'm new to glibc so a hint would be
>>>> appreciated.
>>>
>>> We need to add a new function.  Symbol versioning does not work because
>>> mallinfo is interposed by alternative mallocs (tcmalloc, Address
>>> Sanitizer, etc.).  Without the new function name, the interposer does
>>> not know which ABI the application expects, so it's going to be quite
>>> messy.
> 
>> All right, am I closer with the suggested patch?
> 
> If what I wrote above is right (we'd first gather consensus around
> that), we should probably add struct mallinfo2 and mallinfo2, deprecate
> the original mallinfo function, and eventually remove them from the
> public API (turning the original mallinfo into a compatibility symbol).

All right, I'm sending patch for that.

> 
> I suppose it would make sense to raise this issue with the tcmalloc, tbb
> and Address Sanitizer people, to see if they would be willing to
> implement mallinfo2 on their end.

Once we're done I can file issues to all these to inform them.

Thoughts?
Martin

> 
> The end result, having mallinfo2 and not mallinfo, is a bit ugly, but
> it's an improvement over the current state.  I do not see a need to get
> creative with symbol redirects or symbol versions.
> 
> Thanks,
> Florian
> 


[-- Attachment #2: 0001-Add-mallinfo2-function-that-support-sizes-4GB.patch --]
[-- Type: text/x-patch, Size: 8176 bytes --]

From c2e2da55d722450b65051e641b4b19ac81741a93 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 7 Jul 2020 13:58:24 +0200
Subject: [PATCH] Add mallinfo2 function that support sizes >= 4GB.

The current int type can easily overflow for allocation of more
than 4GB.
---
 malloc/malloc.c    | 35 ++++++++++++++++++++++++++++++-----
 malloc/malloc.h    | 21 +++++++++++++++++++++
 manual/memory.texi | 36 ++++++++++++++++++------------------
 3 files changed, 69 insertions(+), 23 deletions(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index ee87ddbbf9..560fee2c31 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -638,6 +638,8 @@ libc_hidden_proto (__libc_mallopt)
   be kept as longs, the reported values may wrap around zero and
   thus be inaccurate.
 */
+struct mallinfo2 __libc_mallinfo2(void);
+
 struct mallinfo __libc_mallinfo(void);
 
 
@@ -4911,7 +4913,7 @@ __malloc_usable_size (void *m)
  */
 
 static void
-int_mallinfo (mstate av, struct mallinfo *m)
+int_mallinfo (mstate av, struct mallinfo2 *m)
 {
   size_t i;
   mbinptr b;
@@ -4974,10 +4976,10 @@ int_mallinfo (mstate av, struct mallinfo *m)
 }
 
 
-struct mallinfo
-__libc_mallinfo (void)
+struct mallinfo2
+__libc_mallinfo2 (void)
 {
-  struct mallinfo m;
+  struct mallinfo2 m;
   mstate ar_ptr;
 
   if (__malloc_initialized < 0)
@@ -4998,6 +5000,27 @@ __libc_mallinfo (void)
   return m;
 }
 
+struct mallinfo
+__libc_mallinfo (void)
+{
+  struct mallinfo m;
+  struct mallinfo2 m2 = __libc_mallinfo2 ();
+
+  m.arena = m2.arena;
+  m.ordblks = m2.ordblks;
+  m.smblks = m2.smblks;
+  m.hblks = m2.hblks;
+  m.hblkhd = m2.hblkhd;
+  m.usmblks = m2.usmblks;
+  m.fsmblks = m2.fsmblks;
+  m.uordblks = m2.uordblks;
+  m.fordblks = m2.fordblks;
+  m.keepcost = m2.keepcost;
+
+  return m;
+}
+
+
 /*
    ------------------------------ malloc_stats ------------------------------
  */
@@ -5016,7 +5039,7 @@ __malloc_stats (void)
   stderr->_flags2 |= _IO_FLAGS2_NOTCANCEL;
   for (i = 0, ar_ptr = &main_arena;; i++)
     {
-      struct mallinfo mi;
+      struct mallinfo2 mi;
 
       memset (&mi, 0, sizeof (mi));
       __libc_lock_lock (ar_ptr->mutex);
@@ -5632,6 +5655,8 @@ strong_alias (__libc_valloc, __valloc) weak_alias (__libc_valloc, valloc)
 strong_alias (__libc_pvalloc, __pvalloc) weak_alias (__libc_pvalloc, pvalloc)
 strong_alias (__libc_mallinfo, __mallinfo)
 weak_alias (__libc_mallinfo, mallinfo)
+strong_alias (__libc_mallinfo2, __mallinfo2)
+weak_alias (__libc_mallinfo2, mallinfo2)
 strong_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt)
 
 weak_alias (__malloc_stats, malloc_stats)
diff --git a/malloc/malloc.h b/malloc/malloc.h
index a6903fdd54..e8b5c1d736 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -97,9 +97,30 @@ struct mallinfo
   int keepcost; /* top-most, releasable (via malloc_trim) space */
 };
 
+/* SVID2/XPG mallinfo2 structure which can handle allocations
+   bigger than 4GB.  */
+
+struct mallinfo2
+{
+  size_t arena;    /* non-mmapped space allocated from system */
+  size_t ordblks;  /* number of free chunks */
+  size_t smblks;   /* number of fastbin blocks */
+  size_t hblks;    /* number of mmapped regions */
+  size_t hblkhd;   /* space in mmapped regions */
+  size_t usmblks;  /* always 0, preserved for backwards compatibility */
+  size_t fsmblks;  /* space available in freed fastbin blocks */
+  size_t uordblks; /* total allocated space */
+  size_t fordblks; /* total free space */
+  size_t keepcost; /* top-most, releasable (via malloc_trim) space */
+};
+
 /* Returns a copy of the updated current mallinfo. */
+__MALLOC_DEPRECATED;
 extern struct mallinfo mallinfo (void) __THROW;
 
+/* Returns a copy of the updated current mallinfo. */
+extern struct mallinfo2 mallinfo2 (void) __THROW;
+
 /* SVID2/XPG mallopt options */
 #ifndef M_MXFAST
 # define M_MXFAST  1    /* maximum request size for "fastbins" */
diff --git a/manual/memory.texi b/manual/memory.texi
index aa5011e4f9..e5ea71bc6d 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -1505,50 +1505,50 @@ installing such hooks.
 
 @cindex allocation statistics
 You can get information about dynamic memory allocation by calling the
-@code{mallinfo} function.  This function and its associated data type
+@code{mallinfo2} function.  This function and its associated data type
 are declared in @file{malloc.h}; they are an extension of the standard
 SVID/XPG version.
 @pindex malloc.h
 
-@deftp {Data Type} {struct mallinfo}
+@deftp {Data Type} {struct mallinfo2}
 @standards{GNU, malloc.h}
 This structure type is used to return information about the dynamic
 memory allocator.  It contains the following members:
 
 @table @code
-@item int arena
+@item size_t arena
 This is the total size of memory allocated with @code{sbrk} by
 @code{malloc}, in bytes.
 
-@item int ordblks
+@item size_t ordblks
 This is the number of chunks not in use.  (The memory allocator
-internally gets chunks of memory from the operating system, and then
+size_ternally gets chunks of memory from the operating system, and then
 carves them up to satisfy individual @code{malloc} requests;
 @pxref{The GNU Allocator}.)
 
-@item int smblks
+@item size_t smblks
 This field is unused.
 
-@item int hblks
+@item size_t hblks
 This is the total number of chunks allocated with @code{mmap}.
 
-@item int hblkhd
+@item size_t hblkhd
 This is the total size of memory allocated with @code{mmap}, in bytes.
 
-@item int usmblks
+@item size_t usmblks
 This field is unused and always 0.
 
-@item int fsmblks
+@item size_t fsmblks
 This field is unused.
 
-@item int uordblks
+@item size_t uordblks
 This is the total size of memory occupied by chunks handed out by
 @code{malloc}.
 
-@item int fordblks
+@item size_t fordblks
 This is the total size of memory occupied by free (not in use) chunks.
 
-@item int keepcost
+@item size_t keepcost
 This is the size of the top-most releasable chunk that normally
 borders the end of the heap (i.e., the high end of the virtual address
 space's data segment).
@@ -1556,7 +1556,7 @@ space's data segment).
 @end table
 @end deftp
 
-@deftypefun {struct mallinfo} mallinfo (void)
+@deftypefun {struct mallinfo2} mallinfo2 (void)
 @standards{SVID, malloc.h}
 @safety{@prelim{}@mtunsafe{@mtuinit{} @mtasuconst{:mallopt}}@asunsafe{@asuinit{} @asulock{}}@acunsafe{@acuinit{} @aculock{}}}
 @c Accessing mp_.n_mmaps and mp_.max_mmapped_mem, modified with atomics
@@ -1564,7 +1564,7 @@ space's data segment).
 @c mark the statistics as unsafe, rather than the fast-path functions
 @c that collect the possibly inconsistent data.
 
-@c __libc_mallinfo @mtuinit @mtasuconst:mallopt @asuinit @asulock @aculock
+@c __libc_mallinfo2 @mtuinit @mtasuconst:mallopt @asuinit @asulock @aculock
 @c  ptmalloc_init (once) dup @mtsenv @asulock @aculock @acsfd @acsmem
 @c  mutex_lock dup @asulock @aculock
 @c  int_mallinfo @mtasuconst:mallopt [mp_ access on main_arena]
@@ -1577,7 +1577,7 @@ space's data segment).
 @c  mutex_unlock @aculock
 
 This function returns information about the current dynamic memory usage
-in a structure of type @code{struct mallinfo}.
+in a structure of type @code{struct mallinfo2}.
 @end deftypefun
 
 @node Summary of Malloc
@@ -1644,7 +1644,7 @@ A pointer to a function that @code{free} uses whenever it is called.
 A pointer to a function that @code{aligned_alloc}, @code{memalign},
 @code{posix_memalign} and @code{valloc} use whenever they are called.
 
-@item struct mallinfo mallinfo (void)
+@item struct mallinfo2 mallinfo2 (void)
 Return information about the current dynamic memory usage.
 @xref{Statistics of Malloc}.
 @end table
@@ -1970,7 +1970,7 @@ In addition, very old applications may use the obsolete @code{cfree}
 function.
 
 Further @code{malloc}-related functions such as @code{mallopt} or
-@code{mallinfo} will not have any effect or return incorrect statistics
+@code{mallinfo2} will not have any effect or return incorrect statistics
 when a replacement @code{malloc} is in use.  However, failure to replace
 these functions typically does not result in crashes or other incorrect
 application behavior, but may result in static linking failures.
-- 
2.27.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-07 14:36             ` Florian Weimer
@ 2020-07-08  7:25               ` Martin Liška
  0 siblings, 0 replies; 39+ messages in thread
From: Martin Liška @ 2020-07-08  7:25 UTC (permalink / raw)
  To: Florian Weimer, Andreas Schwab; +Cc: libc-alpha

On 7/7/20 4:36 PM, Florian Weimer wrote:
> * Andreas Schwab:
> 
>> On Jul 07 2020, Florian Weimer wrote:
>>
>>> If what I wrote above is right (we'd first gather consensus around
>>> that), we should probably add struct mallinfo2 and mallinfo2, deprecate
>>> the original mallinfo function, and eventually remove them from the
>>> public API (turning the original mallinfo into a compatibility symbol).
>>
>> Isn't mallinfo obsoleted by malloc_info anyway?
> 
> None of the malloc alternatives seem to have picked it up.
> 
> Martin, why do you want to change mallinfo, rather than switching to
> malloc_info?

We use it in the GCC to inform about current memory usage (it's handy for LTO debugging).

If I see correctly, for malloc_info, one would have to parse a XML output..

Martin

> 
> Thanks,
> Florian
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-08  7:24           ` Martin Liška
@ 2020-07-23 10:23             ` Martin Liška
  2020-07-23 14:38             ` Szabolcs Nagy
  1 sibling, 0 replies; 39+ messages in thread
From: Martin Liška @ 2020-07-23 10:23 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, Andreas Schwab

PING^1

On 7/8/20 9:24 AM, Martin Liška wrote:
> On 7/7/20 4:22 PM, Florian Weimer wrote:
>> * Martin Liška:
>>
>>> On 7/7/20 3:49 PM, Florian Weimer wrote:
>>>> * Martin Liška:
>>>>
>>>>> On 7/7/20 2:17 PM, Andreas Schwab wrote:
>>>>>> On Jul 07 2020, Martin Liška wrote:
>>>>>>
>>>>>>> The current int type can easily overflow for allocation of more
>>>>>>> than 4GB.
>>>>>>>
>>>>>>> The following patch changes that to size_t. I guess I need to adjust
>>>>>>> the API version of the function, right?
>>>>>>
>>>>>> Not only that, it breaks the ABI of mallinfo.
>>>>>
>>>>> Sure, so what options do I have? I'm new to glibc so a hint would be
>>>>> appreciated.
>>>>
>>>> We need to add a new function.  Symbol versioning does not work because
>>>> mallinfo is interposed by alternative mallocs (tcmalloc, Address
>>>> Sanitizer, etc.).  Without the new function name, the interposer does
>>>> not know which ABI the application expects, so it's going to be quite
>>>> messy.
>>
>>> All right, am I closer with the suggested patch?
>>
>> If what I wrote above is right (we'd first gather consensus around
>> that), we should probably add struct mallinfo2 and mallinfo2, deprecate
>> the original mallinfo function, and eventually remove them from the
>> public API (turning the original mallinfo into a compatibility symbol).
> 
> All right, I'm sending patch for that.
> 
>>
>> I suppose it would make sense to raise this issue with the tcmalloc, tbb
>> and Address Sanitizer people, to see if they would be willing to
>> implement mallinfo2 on their end.
> 
> Once we're done I can file issues to all these to inform them.
> 
> Thoughts?
> Martin
> 
>>
>> The end result, having mallinfo2 and not mallinfo, is a bit ugly, but
>> it's an improvement over the current state.  I do not see a need to get
>> creative with symbol redirects or symbol versions.
>>
>> Thanks,
>> Florian
>>
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  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
  1 sibling, 1 reply; 39+ messages in thread
From: Szabolcs Nagy @ 2020-07-23 14:38 UTC (permalink / raw)
  To: Martin Liška; +Cc: Florian Weimer, libc-alpha, Andreas Schwab

The 07/08/2020 09:24, Martin Liška wrote:
> Subject: [PATCH] Add mallinfo2 function that support sizes >= 4GB.
> 
> The current int type can easily overflow for allocation of more
> than 4GB.

i don't think a new symbol with a similar bad
design as the old one is desirable.

(i think a good design would allow exposing malloc
internal info without abi and api issues when the
internals change, e.g. no struct field names and
struct layout that are tied to internals. and
supportable by other implementations so whatever
gcc is doing would work elsewhere not just on glibc)

one hack that may be acceptable is to use some
nonsensical value in a mallinfo field to signal that
the fields have new meaning, then the api can work
backward compatibly when all field values are less
than 2G and after that things are broken anyway so
we can switch to some different struct content that
has no overflow issue, but abi compatible with the
old struct (e.g. round up the values to multiples of
1M), so we don't need a new abi symbol and interposers
continue to work. (but i'm not entirely sure this
is a good idea either)

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-23 14:38             ` Szabolcs Nagy
@ 2020-07-27 12:08               ` Martin Liška
  2020-07-27 12:21                 ` Florian Weimer
  0 siblings, 1 reply; 39+ messages in thread
From: Martin Liška @ 2020-07-27 12:08 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: Florian Weimer, libc-alpha, Andreas Schwab

On 7/23/20 4:38 PM, Szabolcs Nagy wrote:
> The 07/08/2020 09:24, Martin Liška wrote:
>> Subject: [PATCH] Add mallinfo2 function that support sizes >= 4GB.
>>
>> The current int type can easily overflow for allocation of more
>> than 4GB.
> 
> i don't think a new symbol with a similar bad
> design as the old one is desirable.
> 
> (i think a good design would allow exposing malloc
> internal info without abi and api issues when the
> internals change, e.g. no struct field names and
> struct layout that are tied to internals. and
> supportable by other implementations so whatever
> gcc is doing would work elsewhere not just on glibc)

Hello.

All right, I agree with that. So something like:

enum malloc_info
{
   ARENA_BYTES,
   ...
};

size_t get_mallinfo (malloc_info type) ?

That would allow adding new enum values that can supported in the future.

> 
> one hack that may be acceptable is to use some
> nonsensical value in a mallinfo field to signal that
> the fields have new meaning, then the api can work
> backward compatibly when all field values are less
> than 2G and after that things are broken anyway so
> we can switch to some different struct content that
> has no overflow issue, but abi compatible with the
> old struct (e.g. round up the values to multiples of
> 1M), so we don't need a new abi symbol and interposers
> continue to work. (but i'm not entirely sure this
> is a good idea either)

Huh, that's quite hacky approach and I don't like it much :)
Let's forget about the old API/ABI and design a new proper one.

Martin

> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-27 12:08               ` Martin Liška
@ 2020-07-27 12:21                 ` Florian Weimer
  2020-07-27 12:45                   ` Martin Liška
  0 siblings, 1 reply; 39+ messages in thread
From: Florian Weimer @ 2020-07-27 12:21 UTC (permalink / raw)
  To: Martin Liška; +Cc: Szabolcs Nagy, libc-alpha, Andreas Schwab

* Martin Liška:

> All right, I agree with that. So something like:
>
> enum malloc_info
> {
>   ARENA_BYTES,
>   ...
> };
>
> size_t get_mallinfo (malloc_info type) ?
>
> That would allow adding new enum values that can supported in the future.

It does not allow to obtain a consistent snapshot of multiple values,
though.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  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
  0 siblings, 2 replies; 39+ messages in thread
From: Martin Liška @ 2020-07-27 12:45 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Szabolcs Nagy, libc-alpha, Andreas Schwab

On 7/27/20 2:21 PM, Florian Weimer wrote:
> * Martin Liška:
> 
>> All right, I agree with that. So something like:
>>
>> enum malloc_info
>> {
>>    ARENA_BYTES,
>>    ...
>> };
>>
>> size_t get_mallinfo (malloc_info type) ?
>>
>> That would allow adding new enum values that can supported in the future.
> 
> It does not allow to obtain a consistent snapshot of multiple values,
> though.

Good point!

So are we back to mallinfo2 which I suggested in patch?
Can you please make an opinion about it?

Thanks,
Martin

> 
> Thanks,
> Florian
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-07-27 12:45                   ` Martin Liška
@ 2020-08-11 12:26                     ` Martin Liška
  2020-08-11 13:44                     ` Florian Weimer
  1 sibling, 0 replies; 39+ messages in thread
From: Martin Liška @ 2020-08-11 12:26 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Andreas Schwab, libc-alpha

PING^1

On 7/27/20 2:45 PM, Martin Liška wrote:
> On 7/27/20 2:21 PM, Florian Weimer wrote:
>> * Martin Liška:
>>
>>> All right, I agree with that. So something like:
>>>
>>> enum malloc_info
>>> {
>>>    ARENA_BYTES,
>>>    ...
>>> };
>>>
>>> size_t get_mallinfo (malloc_info type) ?
>>>
>>> That would allow adding new enum values that can supported in the future.
>>
>> It does not allow to obtain a consistent snapshot of multiple values,
>> though.
> 
> Good point!
> 
> So are we back to mallinfo2 which I suggested in patch?
> Can you please make an opinion about it?
> 
> Thanks,
> Martin
> 
>>
>> Thanks,
>> Florian
>>
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  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
  1 sibling, 1 reply; 39+ messages in thread
From: Florian Weimer @ 2020-08-11 13:44 UTC (permalink / raw)
  To: dj; +Cc: Martin Liška, Andreas Schwab, libc-alpha

* Martin Liška:

> On 7/27/20 2:21 PM, Florian Weimer wrote:
>> * Martin Liška:
>> 
>>> All right, I agree with that. So something like:
>>>
>>> enum malloc_info
>>> {
>>>    ARENA_BYTES,
>>>    ...
>>> };
>>>
>>> size_t get_mallinfo (malloc_info type) ?
>>>
>>> That would allow adding new enum values that can supported in the future.
>> 
>> It does not allow to obtain a consistent snapshot of multiple values,
>> though.
>
> Good point!
>
> So are we back to mallinfo2 which I suggested in patch?
> Can you please make an opinion about it?

DJ, what do you think about this patch?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-11 13:44                     ` Florian Weimer
@ 2020-08-11 17:08                       ` DJ Delorie
  2020-08-12 12:29                         ` Martin Liška
  0 siblings, 1 reply; 39+ messages in thread
From: DJ Delorie @ 2020-08-11 17:08 UTC (permalink / raw)
  To: Florian Weimer; +Cc: mliska, schwab, libc-alpha

Florian Weimer <fw@deneb.enyo.de> writes:
> DJ, what do you think about this patch?

I have no real problems with the patch, but two minor things that could
be handled in a follow-up patch...

1. The copy code for the old function doesn't handle overflow.  We've
   seen bug reports for this before so should consider the edge cases.
   IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
   should be stored instead of a randomly truncated value.

2. The new documentation makes no mention of the older "compatible"
   interface.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-11 17:08                       ` DJ Delorie
@ 2020-08-12 12:29                         ` Martin Liška
  2020-08-24  9:55                           ` Martin Liška
  0 siblings, 1 reply; 39+ messages in thread
From: Martin Liška @ 2020-08-12 12:29 UTC (permalink / raw)
  To: DJ Delorie, Florian Weimer; +Cc: schwab, libc-alpha

On 8/11/20 7:08 PM, DJ Delorie wrote:
> Florian Weimer <fw@deneb.enyo.de> writes:
>> DJ, what do you think about this patch?
> 
> I have no real problems with the patch, but two minor things that could
> be handled in a follow-up patch...

Thank you for the review.
Can I read it as ready to go into master?

> 
> 1. The copy code for the old function doesn't handle overflow.  We've
>     seen bug reports for this before so should consider the edge cases.
>     IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
>     should be stored instead of a randomly truncated value.
> 
> 2. The new documentation makes no mention of the older "compatible"
>     interface.
> 

Both comments are valid to me and I can address them in a follow-up patch.

Martin

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-12 12:29                         ` Martin Liška
@ 2020-08-24  9:55                           ` Martin Liška
  2020-08-28 19:05                             ` DJ Delorie
  0 siblings, 1 reply; 39+ messages in thread
From: Martin Liška @ 2020-08-24  9:55 UTC (permalink / raw)
  To: DJ Delorie, Florian Weimer; +Cc: libc-alpha, schwab

PING^1

On 8/12/20 2:29 PM, Martin Liška wrote:
> On 8/11/20 7:08 PM, DJ Delorie wrote:
>> Florian Weimer <fw@deneb.enyo.de> writes:
>>> DJ, what do you think about this patch?
>>
>> I have no real problems with the patch, but two minor things that could
>> be handled in a follow-up patch...
> 
> Thank you for the review.
> Can I read it as ready to go into master?
> 
>>
>> 1. The copy code for the old function doesn't handle overflow.  We've
>>     seen bug reports for this before so should consider the edge cases.
>>     IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
>>     should be stored instead of a randomly truncated value.
>>
>> 2. The new documentation makes no mention of the older "compatible"
>>     interface.
>>
> 
> Both comments are valid to me and I can address them in a follow-up patch.
> 
> Martin


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-24  9:55                           ` Martin Liška
@ 2020-08-28 19:05                             ` DJ Delorie
  2020-08-31 13:35                               ` H.J. Lu
  2020-09-01 17:26                               ` Joseph Myers
  0 siblings, 2 replies; 39+ messages in thread
From: DJ Delorie @ 2020-08-28 19:05 UTC (permalink / raw)
  To: Martin Liška; +Cc: fw, libc-alpha, schwab

Martin Li¡ka <mliska@suse.cz> writes:

> PING^1

LGTM

Reviewed-by: DJ Delorie <dj@redhat.com>

> On 8/12/20 2:29 PM, Martin Liška wrote:
>> On 8/11/20 7:08 PM, DJ Delorie wrote:
>>> Florian Weimer <fw@deneb.enyo.de> writes:
>>>> DJ, what do you think about this patch?
>>>
>>> I have no real problems with the patch, but two minor things that could
>>> be handled in a follow-up patch...
>> 
>> Thank you for the review.
>> Can I read it as ready to go into master?
>> 
>>>
>>> 1. The copy code for the old function doesn't handle overflow.  We've
>>>     seen bug reports for this before so should consider the edge cases.
>>>     IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
>>>     should be stored instead of a randomly truncated value.
>>>
>>> 2. The new documentation makes no mention of the older "compatible"
>>>     interface.
>>>
>> 
>> Both comments are valid to me and I can address them in a follow-up patch.
>> 
>> Martin


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-28 19:05                             ` DJ Delorie
@ 2020-08-31 13:35                               ` H.J. Lu
  2020-08-31 13:56                                 ` Adhemerval Zanella
  2020-09-01 17:26                               ` Joseph Myers
  1 sibling, 1 reply; 39+ messages in thread
From: H.J. Lu @ 2020-08-31 13:35 UTC (permalink / raw)
  To: DJ Delorie
  Cc: Martin Liška, Andreas Schwab, Florian Weimer, GNU C Library

On Fri, Aug 28, 2020 at 12:06 PM DJ Delorie via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> Martin Li¡ka <mliska@suse.cz> writes:
>
> > PING^1
>
> LGTM
>
> Reviewed-by: DJ Delorie <dj@redhat.com>
>
> > On 8/12/20 2:29 PM, Martin Liška wrote:
> >> On 8/11/20 7:08 PM, DJ Delorie wrote:
> >>> Florian Weimer <fw@deneb.enyo.de> writes:
> >>>> DJ, what do you think about this patch?
> >>>
> >>> I have no real problems with the patch, but two minor things that could
> >>> be handled in a follow-up patch...
> >>
> >> Thank you for the review.
> >> Can I read it as ready to go into master?
> >>
> >>>
> >>> 1. The copy code for the old function doesn't handle overflow.  We've
> >>> Â Â Â  seen bug reports for this before so should consider the edge cases.
> >>> Â Â Â  IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
> >>> Â Â Â  should be stored instead of a randomly truncated value.
> >>>
> >>> 2. The new documentation makes no mention of the older "compatible"
> >>> Â Â Â  interface.
> >>>
> >>
> >> Both comments are valid to me and I can address them in a follow-up patch.
> >>
> >> Martin
>

$ gcc ../sysdeps/x86_64/multiarch/test-multiarch.c -c -std=gnu11
-fgnu89-inline  -O2 -g -Wall -Wwrite-strings -Wundef -Werror
-fmerge-all-constants -frounding-math -fno-stack-protector
-Wstrict-prototypes -Wold-style-definition -fmath-errno
-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0         -I../include
-I/export/build/gnu/tools-build/glibc/build-x86_64-linux/csu
-I/export/build/gnu/tools-build/glibc/build-x86_64-linux
-I../sysdeps/unix/sysv/linux/x86_64/64
-I../sysdeps/unix/sysv/linux/x86_64
-I../sysdeps/unix/sysv/linux/x86/include
-I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl
-I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl
-I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux
-I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu
-I../sysdeps/unix/inet  -I../sysdeps/unix/sysv
-I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix
-I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch
-I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu
-I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86
-I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include
-I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64
-I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32
-I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic
-I.. -I../libio -I.   -D_LIBC_REENTRANT -include
/export/build/gnu/tools-build/glibc/build-x86_64-linux/libc-modules.h
-DMODULE_NAME=testsuite -include ../include/libc-symbols.h
-DTOP_NAMESPACE=glibc -o
/export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
-MD -MP -MF /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o.dt
-MT /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o

In file included from ../include/malloc.h:3,
                 from ../sysdeps/x86_64/multiarch/../../../test-skeleton.c:31,
                 from ../sysdeps/x86_64/multiarch/test-multiarch.c:96:
../malloc/malloc.h:118:1: error: empty declaration [-Werror]
  118 | __MALLOC_DEPRECATED;
      | ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

-- 
H.J.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-31 13:35                               ` H.J. Lu
@ 2020-08-31 13:56                                 ` Adhemerval Zanella
  2020-08-31 14:00                                   ` H.J. Lu
  0 siblings, 1 reply; 39+ messages in thread
From: Adhemerval Zanella @ 2020-08-31 13:56 UTC (permalink / raw)
  To: libc-alpha



On 31/08/2020 10:35, H.J. Lu via Libc-alpha wrote:
> On Fri, Aug 28, 2020 at 12:06 PM DJ Delorie via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>> Martin Li¡ka <mliska@suse.cz> writes:
>>
>>> PING^1
>>
>> LGTM
>>
>> Reviewed-by: DJ Delorie <dj@redhat.com>
>>
>>> On 8/12/20 2:29 PM, Martin Liška wrote:
>>>> On 8/11/20 7:08 PM, DJ Delorie wrote:
>>>>> Florian Weimer <fw@deneb.enyo.de> writes:
>>>>>> DJ, what do you think about this patch?
>>>>>
>>>>> I have no real problems with the patch, but two minor things that could
>>>>> be handled in a follow-up patch...
>>>>
>>>> Thank you for the review.
>>>> Can I read it as ready to go into master?
>>>>
>>>>>
>>>>> 1. The copy code for the old function doesn't handle overflow.  We've
>>>>> Â Â Â  seen bug reports for this before so should consider the edge cases.
>>>>> Â Â Â  IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
>>>>> Â Â Â  should be stored instead of a randomly truncated value.
>>>>>
>>>>> 2. The new documentation makes no mention of the older "compatible"
>>>>> Â Â Â  interface.
>>>>>
>>>>
>>>> Both comments are valid to me and I can address them in a follow-up patch.
>>>>
>>>> Martin
>>
> 
> $ gcc ../sysdeps/x86_64/multiarch/test-multiarch.c -c -std=gnu11
> -fgnu89-inline  -O2 -g -Wall -Wwrite-strings -Wundef -Werror
> -fmerge-all-constants -frounding-math -fno-stack-protector
> -Wstrict-prototypes -Wold-style-definition -fmath-errno
> -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0         -I../include
> -I/export/build/gnu/tools-build/glibc/build-x86_64-linux/csu
> -I/export/build/gnu/tools-build/glibc/build-x86_64-linux
> -I../sysdeps/unix/sysv/linux/x86_64/64
> -I../sysdeps/unix/sysv/linux/x86_64
> -I../sysdeps/unix/sysv/linux/x86/include
> -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl
> -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl
> -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux
> -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu
> -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv
> -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix
> -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch
> -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu
> -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86
> -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include
> -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64
> -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32
> -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic
> -I.. -I../libio -I.   -D_LIBC_REENTRANT -include
> /export/build/gnu/tools-build/glibc/build-x86_64-linux/libc-modules.h
> -DMODULE_NAME=testsuite -include ../include/libc-symbols.h
> -DTOP_NAMESPACE=glibc -o
> /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
> -MD -MP -MF /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o.dt
> -MT /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
> 
> In file included from ../include/malloc.h:3,
>                  from ../sysdeps/x86_64/multiarch/../../../test-skeleton.c:31,
>                  from ../sysdeps/x86_64/multiarch/test-multiarch.c:96:
> ../malloc/malloc.h:118:1: error: empty declaration [-Werror]
>   118 | __MALLOC_DEPRECATED;
>       | ^~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 

I hit this today as well, I think the straightforward fix is:

diff --git a/malloc/malloc.h b/malloc/malloc.h
index e25b33462a..b2371f7704 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -115,8 +115,7 @@ struct mallinfo2
 };
 
 /* Returns a copy of the updated current mallinfo. */
-__MALLOC_DEPRECATED;
-extern struct mallinfo mallinfo (void) __THROW;
+extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
 
 /* Returns a copy of the updated current mallinfo. */
 extern struct mallinfo2 mallinfo2 (void) __THROW;

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-31 13:56                                 ` Adhemerval Zanella
@ 2020-08-31 14:00                                   ` H.J. Lu
  2020-08-31 14:10                                     ` Adhemerval Zanella
  0 siblings, 1 reply; 39+ messages in thread
From: H.J. Lu @ 2020-08-31 14:00 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GNU C Library

On Mon, Aug 31, 2020 at 6:57 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
>
>
> On 31/08/2020 10:35, H.J. Lu via Libc-alpha wrote:
> > On Fri, Aug 28, 2020 at 12:06 PM DJ Delorie via Libc-alpha
> > <libc-alpha@sourceware.org> wrote:
> >>
> >> Martin Li¡ka <mliska@suse.cz> writes:
> >>
> >>> PING^1
> >>
> >> LGTM
> >>
> >> Reviewed-by: DJ Delorie <dj@redhat.com>
> >>
> >>> On 8/12/20 2:29 PM, Martin Liška wrote:
> >>>> On 8/11/20 7:08 PM, DJ Delorie wrote:
> >>>>> Florian Weimer <fw@deneb.enyo.de> writes:
> >>>>>> DJ, what do you think about this patch?
> >>>>>
> >>>>> I have no real problems with the patch, but two minor things that could
> >>>>> be handled in a follow-up patch...
> >>>>
> >>>> Thank you for the review.
> >>>> Can I read it as ready to go into master?
> >>>>
> >>>>>
> >>>>> 1. The copy code for the old function doesn't handle overflow.  We've
> >>>>> Â Â Â  seen bug reports for this before so should consider the edge cases.
> >>>>> Â Â Â  IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
> >>>>> Â Â Â  should be stored instead of a randomly truncated value.
> >>>>>
> >>>>> 2. The new documentation makes no mention of the older "compatible"
> >>>>> Â Â Â  interface.
> >>>>>
> >>>>
> >>>> Both comments are valid to me and I can address them in a follow-up patch.
> >>>>
> >>>> Martin
> >>
> >
> > $ gcc ../sysdeps/x86_64/multiarch/test-multiarch.c -c -std=gnu11
> > -fgnu89-inline  -O2 -g -Wall -Wwrite-strings -Wundef -Werror
> > -fmerge-all-constants -frounding-math -fno-stack-protector
> > -Wstrict-prototypes -Wold-style-definition -fmath-errno
> > -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0         -I../include
> > -I/export/build/gnu/tools-build/glibc/build-x86_64-linux/csu
> > -I/export/build/gnu/tools-build/glibc/build-x86_64-linux
> > -I../sysdeps/unix/sysv/linux/x86_64/64
> > -I../sysdeps/unix/sysv/linux/x86_64
> > -I../sysdeps/unix/sysv/linux/x86/include
> > -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl
> > -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl
> > -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux
> > -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu
> > -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv
> > -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix
> > -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch
> > -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu
> > -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86
> > -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include
> > -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64
> > -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32
> > -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic
> > -I.. -I../libio -I.   -D_LIBC_REENTRANT -include
> > /export/build/gnu/tools-build/glibc/build-x86_64-linux/libc-modules.h
> > -DMODULE_NAME=testsuite -include ../include/libc-symbols.h
> > -DTOP_NAMESPACE=glibc -o
> > /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
> > -MD -MP -MF /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o.dt
> > -MT /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
> >
> > In file included from ../include/malloc.h:3,
> >                  from ../sysdeps/x86_64/multiarch/../../../test-skeleton.c:31,
> >                  from ../sysdeps/x86_64/multiarch/test-multiarch.c:96:
> > ../malloc/malloc.h:118:1: error: empty declaration [-Werror]
> >   118 | __MALLOC_DEPRECATED;
> >       | ^~~~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> >
>
> I hit this today as well, I think the straightforward fix is:
>
> diff --git a/malloc/malloc.h b/malloc/malloc.h
> index e25b33462a..b2371f7704 100644
> --- a/malloc/malloc.h
> +++ b/malloc/malloc.h
> @@ -115,8 +115,7 @@ struct mallinfo2
>  };
>
>  /* Returns a copy of the updated current mallinfo. */
> -__MALLOC_DEPRECATED;
> -extern struct mallinfo mallinfo (void) __THROW;
> +extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
>
>  /* Returns a copy of the updated current mallinfo. */
>  extern struct mallinfo2 mallinfo2 (void) __THROW;

LGTM.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-31 14:00                                   ` H.J. Lu
@ 2020-08-31 14:10                                     ` Adhemerval Zanella
  0 siblings, 0 replies; 39+ messages in thread
From: Adhemerval Zanella @ 2020-08-31 14:10 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library



On 31/08/2020 11:00, H.J. Lu wrote:
> On Mon, Aug 31, 2020 at 6:57 AM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>>
>>
>> On 31/08/2020 10:35, H.J. Lu via Libc-alpha wrote:
>>> On Fri, Aug 28, 2020 at 12:06 PM DJ Delorie via Libc-alpha
>>> <libc-alpha@sourceware.org> wrote:
>>>>
>>>> Martin Li¡ka <mliska@suse.cz> writes:
>>>>
>>>>> PING^1
>>>>
>>>> LGTM
>>>>
>>>> Reviewed-by: DJ Delorie <dj@redhat.com>
>>>>
>>>>> On 8/12/20 2:29 PM, Martin Liška wrote:
>>>>>> On 8/11/20 7:08 PM, DJ Delorie wrote:
>>>>>>> Florian Weimer <fw@deneb.enyo.de> writes:
>>>>>>>> DJ, what do you think about this patch?
>>>>>>>
>>>>>>> I have no real problems with the patch, but two minor things that could
>>>>>>> be handled in a follow-up patch...
>>>>>>
>>>>>> Thank you for the review.
>>>>>> Can I read it as ready to go into master?
>>>>>>
>>>>>>>
>>>>>>> 1. The copy code for the old function doesn't handle overflow.  We've
>>>>>>> Â Â Â  seen bug reports for this before so should consider the edge cases.
>>>>>>> Â Â Â  IMHO if a size_t value is larger than MAXINT, then MAXINT (or -1)
>>>>>>> Â Â Â  should be stored instead of a randomly truncated value.
>>>>>>>
>>>>>>> 2. The new documentation makes no mention of the older "compatible"
>>>>>>> Â Â Â  interface.
>>>>>>>
>>>>>>
>>>>>> Both comments are valid to me and I can address them in a follow-up patch.
>>>>>>
>>>>>> Martin
>>>>
>>>
>>> $ gcc ../sysdeps/x86_64/multiarch/test-multiarch.c -c -std=gnu11
>>> -fgnu89-inline  -O2 -g -Wall -Wwrite-strings -Wundef -Werror
>>> -fmerge-all-constants -frounding-math -fno-stack-protector
>>> -Wstrict-prototypes -Wold-style-definition -fmath-errno
>>> -fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0         -I../include
>>> -I/export/build/gnu/tools-build/glibc/build-x86_64-linux/csu
>>> -I/export/build/gnu/tools-build/glibc/build-x86_64-linux
>>> -I../sysdeps/unix/sysv/linux/x86_64/64
>>> -I../sysdeps/unix/sysv/linux/x86_64
>>> -I../sysdeps/unix/sysv/linux/x86/include
>>> -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl
>>> -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl
>>> -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux
>>> -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu
>>> -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv
>>> -I../sysdeps/unix/x86_64  -I../sysdeps/unix  -I../sysdeps/posix
>>> -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch
>>> -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu
>>> -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64  -I../sysdeps/x86
>>> -I../sysdeps/ieee754/float128  -I../sysdeps/ieee754/ldbl-96/include
>>> -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64
>>> -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32
>>> -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic
>>> -I.. -I../libio -I.   -D_LIBC_REENTRANT -include
>>> /export/build/gnu/tools-build/glibc/build-x86_64-linux/libc-modules.h
>>> -DMODULE_NAME=testsuite -include ../include/libc-symbols.h
>>> -DTOP_NAMESPACE=glibc -o
>>> /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
>>> -MD -MP -MF /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o.dt
>>> -MT /export/build/gnu/tools-build/glibc/build-x86_64-linux/csu/test-multiarch.o
>>>
>>> In file included from ../include/malloc.h:3,
>>>                  from ../sysdeps/x86_64/multiarch/../../../test-skeleton.c:31,
>>>                  from ../sysdeps/x86_64/multiarch/test-multiarch.c:96:
>>> ../malloc/malloc.h:118:1: error: empty declaration [-Werror]
>>>   118 | __MALLOC_DEPRECATED;
>>>       | ^~~~~~~~~~~~~~~~~~~
>>> cc1: all warnings being treated as errors
>>>
>>
>> I hit this today as well, I think the straightforward fix is:
>>
>> diff --git a/malloc/malloc.h b/malloc/malloc.h
>> index e25b33462a..b2371f7704 100644
>> --- a/malloc/malloc.h
>> +++ b/malloc/malloc.h
>> @@ -115,8 +115,7 @@ struct mallinfo2
>>  };
>>
>>  /* Returns a copy of the updated current mallinfo. */
>> -__MALLOC_DEPRECATED;
>> -extern struct mallinfo mallinfo (void) __THROW;
>> +extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
>>
>>  /* Returns a copy of the updated current mallinfo. */
>>  extern struct mallinfo2 mallinfo2 (void) __THROW;
> 
> LGTM.

In fact we need to additionally handle on the tests to avoid the warning
errors.  The full patch is:

---

diff --git a/malloc/malloc.h b/malloc/malloc.h
index e25b33462a..b2371f7704 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -115,8 +115,7 @@ struct mallinfo2
 };
 
 /* Returns a copy of the updated current mallinfo. */
-__MALLOC_DEPRECATED;
-extern struct mallinfo mallinfo (void) __THROW;
+extern struct mallinfo mallinfo (void) __THROW __MALLOC_DEPRECATED;
 
 /* Returns a copy of the updated current mallinfo. */
 extern struct mallinfo2 mallinfo2 (void) __THROW;
diff --git a/malloc/tst-malloc-tcache-leak.c b/malloc/tst-malloc-tcache-leak.c
index f6f6023b5a..2a7a0646c5 100644
--- a/malloc/tst-malloc-tcache-leak.c
+++ b/malloc/tst-malloc-tcache-leak.c
@@ -29,6 +29,7 @@
 #include <malloc.h>
 #include <pthread.h>
 #include <assert.h>
+#include <libc-diag.h>
 
 #include <support/check.h>
 #include <support/support.h>
@@ -72,6 +73,10 @@ 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 ();
 
   assert (info_before.uordblks != 0);
@@ -104,6 +109,8 @@ 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 57b4a0a8dc..8afee0f9d5 100644
--- a/malloc/tst-mxfast.c
+++ b/malloc/tst-mxfast.c
@@ -21,6 +21,7 @@
    the fast bins.  */
 
 #include <malloc.h>
+#include <libc-diag.h>
 #include <support/check.h>
 
 int
@@ -36,8 +37,14 @@ 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;
+
   /* This will fail if there are any blocks in the fastbins.  */
   TEST_COMPARE (m.smblks, 0);
 

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-08-28 19:05                             ` DJ Delorie
  2020-08-31 13:35                               ` H.J. Lu
@ 2020-09-01 17:26                               ` Joseph Myers
  2020-09-02 13:19                                 ` Martin Liška
  2020-09-02 20:16                                 ` DJ Delorie
  1 sibling, 2 replies; 39+ messages in thread
From: Joseph Myers @ 2020-09-01 17:26 UTC (permalink / raw)
  To: DJ Delorie; +Cc: Martin Liška, schwab, fw, libc-alpha

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.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-09-01 17:26                               ` Joseph Myers
@ 2020-09-02 13:19                                 ` Martin Liška
  2020-09-02 13:34                                   ` Adhemerval Zanella
                                                     ` (2 more replies)
  2020-09-02 20:16                                 ` DJ Delorie
  1 sibling, 3 replies; 39+ messages in thread
From: Martin Liška @ 2020-09-02 13:19 UTC (permalink / raw)
  To: Joseph Myers, DJ Delorie; +Cc: schwab, fw, libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]

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

[-- Attachment #2: 0001-mallinfo2-add-missing-bits.patch --]
[-- Type: text/x-patch, Size: 4102 bytes --]

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.
---
 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++)
@@ -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 <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


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-09-02 13:19                                 ` Martin Liška
@ 2020-09-02 13:34                                   ` Adhemerval Zanella
  2020-09-02 14:00                                   ` Carlos O'Donell
  2020-09-02 16:11                                   ` DJ Delorie
  2 siblings, 0 replies; 39+ messages in thread
From: Adhemerval Zanella @ 2020-09-02 13:34 UTC (permalink / raw)
  To: Martin Liška, Joseph Myers, DJ Delorie; +Cc: libc-alpha, fw, schwab



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

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-09-02 13:19                                 ` Martin Liška
  2020-09-02 13:34                                   ` Adhemerval Zanella
@ 2020-09-02 14:00                                   ` Carlos O'Donell
  2020-09-02 16:11                                   ` DJ Delorie
  2 siblings, 0 replies; 39+ messages in thread
From: Carlos O'Donell @ 2020-09-02 14:00 UTC (permalink / raw)
  To: Martin Liška, Joseph Myers, DJ Delorie; +Cc: libc-alpha, fw, schwab

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 <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.
> ---
>  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++)
> @@ -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 <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 ();

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.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-09-02 13:19                                 ` Martin Liška
  2020-09-02 13:34                                   ` Adhemerval Zanella
  2020-09-02 14:00                                   ` Carlos O'Donell
@ 2020-09-02 16:11                                   ` DJ Delorie
  2020-09-21  8:49                                     ` Martin Liška
  2 siblings, 1 reply; 39+ messages in thread
From: DJ Delorie @ 2020-09-02 16:11 UTC (permalink / raw)
  To: Martin Liška; +Cc: joseph, schwab, fw, libc-alpha

Martin Li¡ka <mliska@suse.cz> writes:
> Thank you for the hints Joseph. There's patch that survives regression tests.

As others have noted, getting this right is more complicated that you'd
think.  I'm in the middle of debugging the ABI list changes and will
likely have to refactor the mallinfo2 code to get it right, so don't
worry about this one, I'll take care of it ;-)


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-09-01 17:26                               ` Joseph Myers
  2020-09-02 13:19                                 ` Martin Liška
@ 2020-09-02 20:16                                 ` DJ Delorie
  2020-09-02 20:24                                   ` Florian Weimer
  2020-09-02 20:25                                   ` [PATCH] " Joseph Myers
  1 sibling, 2 replies; 39+ messages in thread
From: DJ Delorie @ 2020-09-02 20:16 UTC (permalink / raw)
  To: Joseph Myers; +Cc: mliska, schwab, fw, libc-alpha

Joseph Myers <joseph@codesourcery.com> writes:
> There are several key pieces missing from the mallinfo2 commit.

How's this?  The mallinfo ABI included __libc_mallinfo but I see no
reason to export a __libc_mallinfo2, which meant factoring out the code
that __libc_mallinfo was calling (else you get abi/plt test failures).

From 84e49946aa58e30b3cd676b5847b49527792a9ff Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Tue, 1 Sep 2020 16:17:25 -0400
Subject: Update mallinfo2 ABI, and test

This patch adds the ABI-related bits to reflect the new mallinfo2
function, and adds a test case to verify basic functionality.

diff --git a/NEWS b/NEWS
index 06e43e0453..b0c720daaa 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ Version 2.33
 
 Major new features:
 
+* The mallinfo2() function is added to report statistics as per
+  mallinfo(), but with larger field widths to accurately report values
+  that are larger than fit in an integer.
 
 * Support for the RISC-V ISA running on Linux has been expanded to run on
   32-bit hardware.  This is supported for the following ISA and ABI pairs:
@@ -22,7 +25,8 @@ Major new features:
 
 Deprecated and removed features, and other changes affecting compatibility:
 
-  [Add deprecations, removals and changes affecting compatibility here]
+* The mallinfo function is marked deprecated.  Callers should call
+  mallinfo2 instead.
 
 Changes to build and runtime requirements:
 
diff --git a/malloc/Makefile b/malloc/Makefile
index e22cbde22d..09ae63bee5 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -35,7 +35,7 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
 	 tst-interpose-thread \
 	 tst-alloc_buffer \
 	 tst-malloc-tcache-leak \
-	 tst-malloc_info \
+	 tst-malloc_info tst-mallinfo2 \
 	 tst-malloc-too-large \
 	 tst-malloc-stats-cancellation \
 	 tst-tcfree1 tst-tcfree2 tst-tcfree3 \
diff --git a/malloc/Versions b/malloc/Versions
index 2357cff3da..a0d991bdb7 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;
@@ -92,5 +95,8 @@ libc {
     __libc_alloc_buffer_copy_bytes;
     __libc_alloc_buffer_copy_string;
     __libc_alloc_buffer_create_failure;
+
+    # Internal name for mallinfo2
+    __libc_mallinfo2;
   }
 }
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 560fee2c31..e52d3594ec 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4975,9 +4975,8 @@ int_mallinfo (mstate av, struct mallinfo2 *m)
     }
 }
 
-
-struct mallinfo2
-__libc_mallinfo2 (void)
+static struct mallinfo2
+__libc_mallinfo2_common (void)
 {
   struct mallinfo2 m;
   mstate ar_ptr;
@@ -5000,11 +4999,17 @@ __libc_mallinfo2 (void)
   return m;
 }
 
+struct mallinfo2
+__libc_mallinfo2 (void)
+{
+  return __libc_mallinfo2_common ();
+}
+
 struct mallinfo
 __libc_mallinfo (void)
 {
   struct mallinfo m;
-  struct mallinfo2 m2 = __libc_mallinfo2 ();
+  struct mallinfo2 m2 = __libc_mallinfo2_common ();
 
   m.arena = m2.arena;
   m.ordblks = m2.ordblks;
diff --git a/malloc/tst-mallinfo2.c b/malloc/tst-mallinfo2.c
new file mode 100644
index 0000000000..c98c814c74
--- /dev/null
+++ b/malloc/tst-mallinfo2.c
@@ -0,0 +1,83 @@
+/* Smoke test for mallinfo2
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* Test that mallinfo2 is properly exported and basically works.  */
+
+#include <array_length.h>
+#include <malloc.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+/* This is not specifically needed for the test, but (1) does
+   something to the data so gcc doesn't optimize it away, and (2) may
+   help when developing future tests.  */
+static void
+print_mi (const char *msg, struct mallinfo2 *m)
+{
+  printf("\n%s...\n", msg);
+#define P(f) printf("%s: %ld\n", #f, (long) m->f);
+  P(arena);
+  P(ordblks);
+  P(smblks);
+  P(hblks);
+  P(hblkhd);
+  P(usmblks);
+  P(fsmblks);
+  P(uordblks);
+  P(fordblks);
+  P(keepcost);
+}
+
+/* We do this to force the call to malloc to not be optimized
+   away.  */
+volatile void *ptr;
+
+static int
+do_test (void)
+{
+  struct mallinfo2 mi1, mi2;
+  int i;
+  size_t total = 0;
+
+  /* This is the key difference between mallinfo() and mallinfo2().
+     It may be a false positive if int and size_t are the same
+     size.  */
+  TEST_VERIFY (sizeof (mi1.arena) == sizeof (size_t));
+
+  mi1 = mallinfo2 ();
+  print_mi ("before", &mi1);
+
+  /* Allocations that are meaningful-sized but not so large as to be
+     mmapped, so that they're all accounted for in the field we test
+     below.  */
+  for (i=1; i<20; i++)
+    {
+      ptr = malloc (160 * i);
+      total += 16 * i;
+    }
+
+  mi2 = mallinfo2 ();
+  print_mi ("after", &mi2);
+
+  /* Check at least something changed.  */
+  TEST_VERIFY (mi2.uordblks > mi1.uordblks + total);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 72537218ba..109838775c 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2191,6 +2191,7 @@ GLIBC_2.32 thrd_current F
 GLIBC_2.32 thrd_equal F
 GLIBC_2.32 thrd_sleep F
 GLIBC_2.32 thrd_yield F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 6cd61988b4..bc375ecb8d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2160,3 +2160,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 8edb5deea1..f8f50f87b0 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2242,6 +2242,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index df13f49e15..146ca85cc8 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -1920,3 +1920,4 @@ GLIBC_2.32 wprintf F
 GLIBC_2.32 write F
 GLIBC_2.32 writev F
 GLIBC_2.32 wscanf F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 7f4a146d22..48b2240b88 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -144,6 +144,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index a83cc81958..1d5c482c89 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -141,6 +141,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 32887b1c58..a93d48f7ea 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2104,3 +2104,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index baf425072b..7e265ef570 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2063,6 +2063,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 8b0242a9b1..d80285427a 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2229,6 +2229,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index b6ba86dbe9..6619fe4b31 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2095,6 +2095,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index e1f7e19de9..56b651998c 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -145,6 +145,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
 GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 2d726097ca..ad200c9f63 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2175,6 +2175,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 7c78649e03..f91a744ce2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2155,3 +2155,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index da2194b498..c5e86ddb4d 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2152,3 +2152,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 9fa655b3a5..f71c242463 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2146,6 +2146,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 3f6da71769..7854bdc5fc 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2144,6 +2144,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index de990933cf..f590577194 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2152,6 +2152,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 754491f209..8518b7fe2f 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2146,6 +2146,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 36a875115c..1d6bc7018d 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2193,3 +2193,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 6de9bed51d..2925850690 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2202,6 +2202,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 5c8c58974c..3c816ec48f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2235,6 +2235,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index 92114806ac..376057d86d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2065,6 +2065,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index b01fdcfae1..e69191b82a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2355,3 +2355,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index 3bea073169..2aad26a91c 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -1168,6 +1168,7 @@ GLIBC_2.33 lutimes F
 GLIBC_2.33 madvise F
 GLIBC_2.33 makecontext F
 GLIBC_2.33 mallinfo F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.33 malloc F
 GLIBC_2.33 malloc_info F
 GLIBC_2.33 malloc_stats F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 45cbeb1d98..04bc7b1e6f 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2122,3 +2122,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index d0752dba6c..2940f787ae 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2200,6 +2200,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index af5f14d1c6..e9d2023b8c 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2101,6 +2101,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 038ce27174..d98ef4f519 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2070,6 +2070,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 182970a708..8c8507ec14 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2067,6 +2067,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index a2521c3ee3..b4274d4fa4 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2191,6 +2191,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index d8188903f9..a683b0af97 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2118,6 +2118,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 1a96103c68..c360212e8d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2076,6 +2076,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 35745a75b6..e6d064cac7 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2173,3 +2173,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  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-02 20:25                                   ` [PATCH] " Joseph Myers
  1 sibling, 1 reply; 39+ messages in thread
From: Florian Weimer @ 2020-09-02 20:24 UTC (permalink / raw)
  To: DJ Delorie; +Cc: Joseph Myers, mliska, schwab, libc-alpha

* DJ Delorie:

> diff --git a/malloc/Versions b/malloc/Versions
> index 2357cff3da..a0d991bdb7 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;
> @@ -92,5 +95,8 @@ libc {
>      __libc_alloc_buffer_copy_bytes;
>      __libc_alloc_buffer_copy_string;
>      __libc_alloc_buffer_create_failure;
> +
> +    # Internal name for mallinfo2
> +    __libc_mallinfo2;
>    }
>  }

I don't think this is needed, and neither is the new static _common
function.

The usual way of solving this case (internal interface in libc.so.6
using a public interface interface not in ISO C) goes like this:

Come up with an internal name (__libc_mallinfo2 is fine).

Add an declaration (often with __typeof) and libc_hidden_proto to the
wrapper header under include/.

Use the internal name to define the function, followed by
libc_hidden_def.  Together with libc_hidden_proto, this ensures PLT
avoidance for internal calls.

Add a weak_alias for the public name.  This makes sure that
applications can define their own function of the public name and
still use symbols from the same file (malloc in this case), without
getting multiple definitions.

Add the Versions entry under GLIBC_PRIVATE if there are internal users
in other DSOs (quoted above, not applicable in this case).

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-09-02 20:16                                 ` DJ Delorie
  2020-09-02 20:24                                   ` Florian Weimer
@ 2020-09-02 20:25                                   ` Joseph Myers
  1 sibling, 0 replies; 39+ messages in thread
From: Joseph Myers @ 2020-09-02 20:25 UTC (permalink / raw)
  To: DJ Delorie; +Cc: schwab, fw, libc-alpha

On Wed, 2 Sep 2020, DJ Delorie via Libc-alpha wrote:

> Joseph Myers <joseph@codesourcery.com> writes:
> > There are several key pieces missing from the mallinfo2 commit.
> 
> How's this?  The mallinfo ABI included __libc_mallinfo but I see no
> reason to export a __libc_mallinfo2, which meant factoring out the code
> that __libc_mallinfo was calling (else you get abi/plt test failures).

This includes the pieces I'd expect (I haven't tried to review the 
substance of the patch).

>  Major new features:
>  
> +* The mallinfo2() function is added to report statistics as per
> +  mallinfo(), but with larger field widths to accurately report values
> +  that are larger than fit in an integer.

We don't use () after a function name just to indicate that it's a 
function, only to indicate a call with no arguments (see the GNU Coding 
Standards).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH/v2] Use size_t for mallinfo fields.
  2020-09-02 20:24                                   ` Florian Weimer
@ 2020-09-02 21:04                                     ` DJ Delorie
  2020-09-03 11:17                                       ` Adhemerval Zanella
  0 siblings, 1 reply; 39+ messages in thread
From: DJ Delorie @ 2020-09-02 21:04 UTC (permalink / raw)
  To: Florian Weimer; +Cc: joseph, mliska, schwab, libc-alpha

Florian Weimer <fw@deneb.enyo.de> writes:
>> +    # Internal name for mallinfo2
>> +    __libc_mallinfo2;

Oops, this was a leftover from a previous test.  Removed.

> Add an declaration (often with __typeof) and libc_hidden_proto to the
> wrapper header under include/.

Ah, we already do that in malloc.c.  Copied :-)

Joseph S. Myers writes:
> We don't use () after a function name just to indicate that it's a 
> function, only to indicate a call with no arguments (see the GNU Coding 
> Standards).

Fixed.

From fd60b9e42e89d5e5044d92fc18b6e7e5fc4fbf25 Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Tue, 1 Sep 2020 16:17:25 -0400
Subject: Update mallinfo2 ABI, and test

This patch adds the ABI-related bits to reflect the new mallinfo2
function, and adds a test case to verify basic functionality.

diff --git a/NEWS b/NEWS
index 06e43e0453..99a5ab0cd5 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ Version 2.33
 
 Major new features:
 
+* The mallinfo2 function is added to report statistics as per mallinfo,
+  but with larger field widths to accurately report values that are
+  larger than fit in an integer.
 
 * Support for the RISC-V ISA running on Linux has been expanded to run on
   32-bit hardware.  This is supported for the following ISA and ABI pairs:
@@ -22,7 +25,8 @@ Major new features:
 
 Deprecated and removed features, and other changes affecting compatibility:
 
-  [Add deprecations, removals and changes affecting compatibility here]
+* The mallinfo function is marked deprecated.  Callers should call
+  mallinfo2 instead.
 
 Changes to build and runtime requirements:
 
diff --git a/malloc/Makefile b/malloc/Makefile
index e22cbde22d..09ae63bee5 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -35,7 +35,7 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
 	 tst-interpose-thread \
 	 tst-alloc_buffer \
 	 tst-malloc-tcache-leak \
-	 tst-malloc_info \
+	 tst-malloc_info tst-mallinfo2 \
 	 tst-malloc-too-large \
 	 tst-malloc-stats-cancellation \
 	 tst-tcfree1 tst-tcfree2 tst-tcfree3 \
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/malloc.c b/malloc/malloc.c
index 560fee2c31..63f6a10bca 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -639,6 +639,7 @@ libc_hidden_proto (__libc_mallopt)
   thus be inaccurate.
 */
 struct mallinfo2 __libc_mallinfo2(void);
+libc_hidden_proto (__libc_mallinfo2)
 
 struct mallinfo __libc_mallinfo(void);
 
@@ -4975,7 +4976,6 @@ int_mallinfo (mstate av, struct mallinfo2 *m)
     }
 }
 
-
 struct mallinfo2
 __libc_mallinfo2 (void)
 {
@@ -4999,6 +4999,7 @@ __libc_mallinfo2 (void)
 
   return m;
 }
+libc_hidden_def (__libc_mallinfo2)
 
 struct mallinfo
 __libc_mallinfo (void)
diff --git a/malloc/tst-mallinfo2.c b/malloc/tst-mallinfo2.c
new file mode 100644
index 0000000000..c98c814c74
--- /dev/null
+++ b/malloc/tst-mallinfo2.c
@@ -0,0 +1,83 @@
+/* Smoke test for mallinfo2
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* Test that mallinfo2 is properly exported and basically works.  */
+
+#include <array_length.h>
+#include <malloc.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+/* This is not specifically needed for the test, but (1) does
+   something to the data so gcc doesn't optimize it away, and (2) may
+   help when developing future tests.  */
+static void
+print_mi (const char *msg, struct mallinfo2 *m)
+{
+  printf("\n%s...\n", msg);
+#define P(f) printf("%s: %ld\n", #f, (long) m->f);
+  P(arena);
+  P(ordblks);
+  P(smblks);
+  P(hblks);
+  P(hblkhd);
+  P(usmblks);
+  P(fsmblks);
+  P(uordblks);
+  P(fordblks);
+  P(keepcost);
+}
+
+/* We do this to force the call to malloc to not be optimized
+   away.  */
+volatile void *ptr;
+
+static int
+do_test (void)
+{
+  struct mallinfo2 mi1, mi2;
+  int i;
+  size_t total = 0;
+
+  /* This is the key difference between mallinfo() and mallinfo2().
+     It may be a false positive if int and size_t are the same
+     size.  */
+  TEST_VERIFY (sizeof (mi1.arena) == sizeof (size_t));
+
+  mi1 = mallinfo2 ();
+  print_mi ("before", &mi1);
+
+  /* Allocations that are meaningful-sized but not so large as to be
+     mmapped, so that they're all accounted for in the field we test
+     below.  */
+  for (i=1; i<20; i++)
+    {
+      ptr = malloc (160 * i);
+      total += 16 * i;
+    }
+
+  mi2 = mallinfo2 ();
+  print_mi ("after", &mi2);
+
+  /* Check at least something changed.  */
+  TEST_VERIFY (mi2.uordblks > mi1.uordblks + total);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 72537218ba..109838775c 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2191,6 +2191,7 @@ GLIBC_2.32 thrd_current F
 GLIBC_2.32 thrd_equal F
 GLIBC_2.32 thrd_sleep F
 GLIBC_2.32 thrd_yield F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 6cd61988b4..bc375ecb8d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2160,3 +2160,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 8edb5deea1..f8f50f87b0 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2242,6 +2242,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index df13f49e15..146ca85cc8 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -1920,3 +1920,4 @@ GLIBC_2.32 wprintf F
 GLIBC_2.32 write F
 GLIBC_2.32 writev F
 GLIBC_2.32 wscanf F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 7f4a146d22..48b2240b88 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -144,6 +144,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index a83cc81958..1d5c482c89 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -141,6 +141,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 32887b1c58..a93d48f7ea 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2104,3 +2104,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index baf425072b..7e265ef570 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2063,6 +2063,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 8b0242a9b1..d80285427a 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2229,6 +2229,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index b6ba86dbe9..6619fe4b31 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2095,6 +2095,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index e1f7e19de9..56b651998c 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -145,6 +145,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
 GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 2d726097ca..ad200c9f63 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2175,6 +2175,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 7c78649e03..f91a744ce2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2155,3 +2155,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index da2194b498..c5e86ddb4d 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2152,3 +2152,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 9fa655b3a5..f71c242463 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2146,6 +2146,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 3f6da71769..7854bdc5fc 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2144,6 +2144,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index de990933cf..f590577194 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2152,6 +2152,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 754491f209..8518b7fe2f 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2146,6 +2146,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 36a875115c..1d6bc7018d 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2193,3 +2193,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 6de9bed51d..2925850690 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2202,6 +2202,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 5c8c58974c..3c816ec48f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2235,6 +2235,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index 92114806ac..376057d86d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2065,6 +2065,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index b01fdcfae1..e69191b82a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2355,3 +2355,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index 3bea073169..2aad26a91c 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -1168,6 +1168,7 @@ GLIBC_2.33 lutimes F
 GLIBC_2.33 madvise F
 GLIBC_2.33 makecontext F
 GLIBC_2.33 mallinfo F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.33 malloc F
 GLIBC_2.33 malloc_info F
 GLIBC_2.33 malloc_stats F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 45cbeb1d98..04bc7b1e6f 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2122,3 +2122,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index d0752dba6c..2940f787ae 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2200,6 +2200,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index af5f14d1c6..e9d2023b8c 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2101,6 +2101,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 038ce27174..d98ef4f519 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2070,6 +2070,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 182970a708..8c8507ec14 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2067,6 +2067,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index a2521c3ee3..b4274d4fa4 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2191,6 +2191,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index d8188903f9..a683b0af97 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2118,6 +2118,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 1a96103c68..c360212e8d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2076,6 +2076,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 35745a75b6..e6d064cac7 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2173,3 +2173,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH/v2] Use size_t for mallinfo fields.
  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
  0 siblings, 2 replies; 39+ messages in thread
From: Adhemerval Zanella @ 2020-09-03 11:17 UTC (permalink / raw)
  To: libc-alpha, DJ Delorie



On 02/09/2020 18:04, DJ Delorie via Libc-alpha wrote:
> Florian Weimer <fw@deneb.enyo.de> writes:
>>> +    # Internal name for mallinfo2
>>> +    __libc_mallinfo2;
> 
> Oops, this was a leftover from a previous test.  Removed.
> 
>> Add an declaration (often with __typeof) and libc_hidden_proto to the
>> wrapper header under include/.
> 
> Ah, we already do that in malloc.c.  Copied :-)
> 
> Joseph S. Myers writes:
>> We don't use () after a function name just to indicate that it's a 
>> function, only to indicate a call with no arguments (see the GNU Coding 
>> Standards).
> 
> Fixed.
> 
> From fd60b9e42e89d5e5044d92fc18b6e7e5fc4fbf25 Mon Sep 17 00:00:00 2001
> From: DJ Delorie <dj@redhat.com>
> Date: Tue, 1 Sep 2020 16:17:25 -0400
> Subject: Update mallinfo2 ABI, and test
> 
> This patch adds the ABI-related bits to reflect the new mallinfo2
> function, and adds a test case to verify basic functionality.
> 

Patch LGTM with some nits below.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> diff --git a/NEWS b/NEWS
> index 06e43e0453..99a5ab0cd5 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -9,6 +9,9 @@ Version 2.33
>  
>  Major new features:
>  
> +* The mallinfo2 function is added to report statistics as per mallinfo,
> +  but with larger field widths to accurately report values that are
> +  larger than fit in an integer.
>  
>  * Support for the RISC-V ISA running on Linux has been expanded to run on
>    32-bit hardware.  This is supported for the following ISA and ABI pairs:
> @@ -22,7 +25,8 @@ Major new features:
>  
>  Deprecated and removed features, and other changes affecting compatibility:
>  
> -  [Add deprecations, removals and changes affecting compatibility here]
> +* The mallinfo function is marked deprecated.  Callers should call
> +  mallinfo2 instead.
>  
>  Changes to build and runtime requirements:
>  
> diff --git a/malloc/Makefile b/malloc/Makefile
> index e22cbde22d..09ae63bee5 100644
> --- a/malloc/Makefile
> +++ b/malloc/Makefile
> @@ -35,7 +35,7 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
>  	 tst-interpose-thread \
>  	 tst-alloc_buffer \
>  	 tst-malloc-tcache-leak \
> -	 tst-malloc_info \
> +	 tst-malloc_info tst-mallinfo2 \
>  	 tst-malloc-too-large \
>  	 tst-malloc-stats-cancellation \
>  	 tst-tcfree1 tst-tcfree2 tst-tcfree3 \
> 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/malloc.c b/malloc/malloc.c
> index 560fee2c31..63f6a10bca 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -639,6 +639,7 @@ libc_hidden_proto (__libc_mallopt)
>    thus be inaccurate.
>  */
>  struct mallinfo2 __libc_mallinfo2(void);
> +libc_hidden_proto (__libc_mallinfo2)
>  
>  struct mallinfo __libc_mallinfo(void);
>  
> @@ -4975,7 +4976,6 @@ int_mallinfo (mstate av, struct mallinfo2 *m)
>      }
>  }
>  
> -

Gratuitous change.

>  struct mallinfo2
>  __libc_mallinfo2 (void)
>  {
> @@ -4999,6 +4999,7 @@ __libc_mallinfo2 (void)
>  
>    return m;
>  }
> +libc_hidden_def (__libc_mallinfo2)
>  
>  struct mallinfo
>  __libc_mallinfo (void)
> diff --git a/malloc/tst-mallinfo2.c b/malloc/tst-mallinfo2.c
> new file mode 100644
> index 0000000000..c98c814c74
> --- /dev/null
> +++ b/malloc/tst-mallinfo2.c
> @@ -0,0 +1,83 @@
> +/* Smoke test for mallinfo2
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +/* Test that mallinfo2 is properly exported and basically works.  */
> +
> +#include <array_length.h>
> +#include <malloc.h>
> +#include <stdlib.h>
> +#include <support/check.h>
> +
> +/* This is not specifically needed for the test, but (1) does
> +   something to the data so gcc doesn't optimize it away, and (2) may
> +   help when developing future tests.  */
> +static void
> +print_mi (const char *msg, struct mallinfo2 *m)
> +{
> +  printf("\n%s...\n", msg);
> +#define P(f) printf("%s: %ld\n", #f, (long) m->f);

Maybe use '%zu' here?

> +  P(arena);
> +  P(ordblks);
> +  P(smblks);
> +  P(hblks);
> +  P(hblkhd);
> +  P(usmblks);
> +  P(fsmblks);
> +  P(uordblks);
> +  P(fordblks);
> +  P(keepcost);
> +}
> +
> +/* We do this to force the call to malloc to not be optimized
> +   away.  */
> +volatile void *ptr;
> +
> +static int
> +do_test (void)
> +{
> +  struct mallinfo2 mi1, mi2;
> +  int i;
> +  size_t total = 0;
> +
> +  /* This is the key difference between mallinfo() and mallinfo2().
> +     It may be a false positive if int and size_t are the same
> +     size.  */
> +  TEST_VERIFY (sizeof (mi1.arena) == sizeof (size_t));

Maybe TEST_COMPARE?

> +
> +  mi1 = mallinfo2 ();
> +  print_mi ("before", &mi1);
> +
> +  /* Allocations that are meaningful-sized but not so large as to be
> +     mmapped, so that they're all accounted for in the field we test
> +     below.  */
> +  for (i=1; i<20; i++)

Space after '=' and '<'.

> +    {
> +      ptr = malloc (160 * i);
> +      total += 16 * i;
> +    }
> +
> +  mi2 = mallinfo2 ();
> +  print_mi ("after", &mi2);
> +
> +  /* Check at least something changed.  */
> +  TEST_VERIFY (mi2.uordblks > mi1.uordblks + total);
> +
> +  return 0;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
> index 72537218ba..109838775c 100644
> --- a/sysdeps/mach/hurd/i386/libc.abilist
> +++ b/sysdeps/mach/hurd/i386/libc.abilist
> @@ -2191,6 +2191,7 @@ GLIBC_2.32 thrd_current F
>  GLIBC_2.32 thrd_equal F
>  GLIBC_2.32 thrd_sleep F
>  GLIBC_2.32 thrd_yield F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> index 6cd61988b4..bc375ecb8d 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> @@ -2160,3 +2160,4 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> index 8edb5deea1..f8f50f87b0 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> @@ -2242,6 +2242,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
> index df13f49e15..146ca85cc8 100644
> --- a/sysdeps/unix/sysv/linux/arc/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
> @@ -1920,3 +1920,4 @@ GLIBC_2.32 wprintf F
>  GLIBC_2.32 write F
>  GLIBC_2.32 writev F
>  GLIBC_2.32 wscanf F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> index 7f4a146d22..48b2240b88 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -144,6 +144,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _Exit F
>  GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
>  GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> index a83cc81958..1d5c482c89 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -141,6 +141,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _Exit F
>  GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
>  GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
> index 32887b1c58..a93d48f7ea 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2104,3 +2104,4 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> index baf425072b..7e265ef570 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2063,6 +2063,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
> index 8b0242a9b1..d80285427a 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2229,6 +2229,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> index b6ba86dbe9..6619fe4b31 100644
> --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> @@ -2095,6 +2095,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> index e1f7e19de9..56b651998c 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> @@ -145,6 +145,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _Exit F
>  GLIBC_2.4 _IO_2_1_stderr_ D 0x98
>  GLIBC_2.4 _IO_2_1_stdin_ D 0x98
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> index 2d726097ca..ad200c9f63 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2175,6 +2175,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> index 7c78649e03..f91a744ce2 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2155,3 +2155,4 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> index da2194b498..c5e86ddb4d 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2152,3 +2152,4 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> index 9fa655b3a5..f71c242463 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2146,6 +2146,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> index 3f6da71769..7854bdc5fc 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2144,6 +2144,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> index de990933cf..f590577194 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2152,6 +2152,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> index 754491f209..8518b7fe2f 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> @@ -2146,6 +2146,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> index 36a875115c..1d6bc7018d 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> @@ -2193,3 +2193,4 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> index 6de9bed51d..2925850690 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -2202,6 +2202,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> index 5c8c58974c..3c816ec48f 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -2235,6 +2235,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> index 92114806ac..376057d86d 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> @@ -2065,6 +2065,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> index b01fdcfae1..e69191b82a 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> @@ -2355,3 +2355,4 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> index 3bea073169..2aad26a91c 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> @@ -1168,6 +1168,7 @@ GLIBC_2.33 lutimes F
>  GLIBC_2.33 madvise F
>  GLIBC_2.33 makecontext F
>  GLIBC_2.33 mallinfo F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.33 malloc F
>  GLIBC_2.33 malloc_info F
>  GLIBC_2.33 malloc_stats F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> index 45cbeb1d98..04bc7b1e6f 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> @@ -2122,3 +2122,4 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> index d0752dba6c..2940f787ae 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -2200,6 +2200,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> index af5f14d1c6..e9d2023b8c 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> @@ -2101,6 +2101,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> index 038ce27174..d98ef4f519 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2070,6 +2070,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> index 182970a708..8c8507ec14 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2067,6 +2067,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> index a2521c3ee3..b4274d4fa4 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -2191,6 +2191,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 _IO_fprintf F
>  GLIBC_2.4 _IO_printf F
>  GLIBC_2.4 _IO_sprintf F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> index d8188903f9..a683b0af97 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> @@ -2118,6 +2118,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> index 1a96103c68..c360212e8d 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> @@ -2076,6 +2076,7 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
>  GLIBC_2.4 __confstr_chk F
>  GLIBC_2.4 __fgets_chk F
>  GLIBC_2.4 __fgets_unlocked_chk F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> index 35745a75b6..e6d064cac7 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> @@ -2173,3 +2173,4 @@ GLIBC_2.32 sigabbrev_np F
>  GLIBC_2.32 sigdescr_np F
>  GLIBC_2.32 strerrordesc_np F
>  GLIBC_2.32 strerrorname_np F
> +GLIBC_2.33 mallinfo2 F
> 

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH/v2] Use size_t for mallinfo fields.
  2020-09-03 11:17                                       ` Adhemerval Zanella
@ 2020-09-03 21:33                                         ` DJ Delorie
  2020-09-17 23:02                                         ` DJ Delorie
  1 sibling, 0 replies; 39+ messages in thread
From: DJ Delorie @ 2020-09-03 21:33 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> Patch LGTM with some nits below.
>
> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

Thanks!  I'll fix the nits as suggested while waiting for other
reviewers.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH/v2] Use size_t for mallinfo fields.
  2020-09-03 11:17                                       ` Adhemerval Zanella
  2020-09-03 21:33                                         ` DJ Delorie
@ 2020-09-17 23:02                                         ` DJ Delorie
  1 sibling, 0 replies; 39+ messages in thread
From: DJ Delorie @ 2020-09-17 23:02 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha


Thanks, committed as follows...

From cdf645427d176197b82f44308a5e131d69fb53ad Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Tue, 1 Sep 2020 16:17:25 -0400
Subject: Update mallinfo2 ABI, and test

This patch adds the ABI-related bits to reflect the new mallinfo2
function, and adds a test case to verify basic functionality.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

diff --git a/NEWS b/NEWS
index 878221639b..fc8dd15439 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,10 @@ Version 2.33
 
 Major new features:
 
+* The mallinfo2 function is added to report statistics as per mallinfo,
+  but with larger field widths to accurately report values that are
+  larger than fit in an integer.
+
 * Add <sys/platform/x86.h> to provide query macros for x86 CPU features.
 
 * Support for the RISC-V ISA running on Linux has been expanded to run on
@@ -23,7 +27,8 @@ Major new features:
 
 Deprecated and removed features, and other changes affecting compatibility:
 
-  [Add deprecations, removals and changes affecting compatibility here]
+* The mallinfo function is marked deprecated.  Callers should call
+  mallinfo2 instead.
 
 Changes to build and runtime requirements:
 
diff --git a/malloc/Makefile b/malloc/Makefile
index e22cbde22d..09ae63bee5 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -35,7 +35,7 @@ tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
 	 tst-interpose-thread \
 	 tst-alloc_buffer \
 	 tst-malloc-tcache-leak \
-	 tst-malloc_info \
+	 tst-malloc_info tst-mallinfo2 \
 	 tst-malloc-too-large \
 	 tst-malloc-stats-cancellation \
 	 tst-tcfree1 tst-tcfree2 tst-tcfree3 \
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/malloc.c b/malloc/malloc.c
index 560fee2c31..cd9933b4e5 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -639,6 +639,7 @@ libc_hidden_proto (__libc_mallopt)
   thus be inaccurate.
 */
 struct mallinfo2 __libc_mallinfo2(void);
+libc_hidden_proto (__libc_mallinfo2)
 
 struct mallinfo __libc_mallinfo(void);
 
@@ -4999,6 +5000,7 @@ __libc_mallinfo2 (void)
 
   return m;
 }
+libc_hidden_def (__libc_mallinfo2)
 
 struct mallinfo
 __libc_mallinfo (void)
diff --git a/malloc/tst-mallinfo2.c b/malloc/tst-mallinfo2.c
new file mode 100644
index 0000000000..39a70d7df2
--- /dev/null
+++ b/malloc/tst-mallinfo2.c
@@ -0,0 +1,83 @@
+/* Smoke test for mallinfo2
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* Test that mallinfo2 is properly exported and basically works.  */
+
+#include <array_length.h>
+#include <malloc.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+/* This is not specifically needed for the test, but (1) does
+   something to the data so gcc doesn't optimize it away, and (2) may
+   help when developing future tests.  */
+static void
+print_mi (const char *msg, struct mallinfo2 *m)
+{
+  printf("\n%s...\n", msg);
+#define P(f) printf("%s: %zu\n", #f, m->f);
+  P(arena);
+  P(ordblks);
+  P(smblks);
+  P(hblks);
+  P(hblkhd);
+  P(usmblks);
+  P(fsmblks);
+  P(uordblks);
+  P(fordblks);
+  P(keepcost);
+}
+
+/* We do this to force the call to malloc to not be optimized
+   away.  */
+volatile void *ptr;
+
+static int
+do_test (void)
+{
+  struct mallinfo2 mi1, mi2;
+  int i;
+  size_t total = 0;
+
+  /* This is the key difference between mallinfo() and mallinfo2().
+     It may be a false positive if int and size_t are the same
+     size.  */
+  TEST_COMPARE (sizeof (mi1.arena), sizeof (size_t));
+
+  mi1 = mallinfo2 ();
+  print_mi ("before", &mi1);
+
+  /* Allocations that are meaningful-sized but not so large as to be
+     mmapped, so that they're all accounted for in the field we test
+     below.  */
+  for (i = 1; i < 20; ++i)
+    {
+      ptr = malloc (160 * i);
+      total += 16 * i;
+    }
+
+  mi2 = mallinfo2 ();
+  print_mi ("after", &mi2);
+
+  /* Check at least something changed.  */
+  TEST_VERIFY (mi2.uordblks > mi1.uordblks + total);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 72537218ba..109838775c 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2191,6 +2191,7 @@ GLIBC_2.32 thrd_current F
 GLIBC_2.32 thrd_equal F
 GLIBC_2.32 thrd_sleep F
 GLIBC_2.32 thrd_yield F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 6cd61988b4..bc375ecb8d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2160,3 +2160,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 8edb5deea1..f8f50f87b0 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2242,6 +2242,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index df13f49e15..146ca85cc8 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -1920,3 +1920,4 @@ GLIBC_2.32 wprintf F
 GLIBC_2.32 write F
 GLIBC_2.32 writev F
 GLIBC_2.32 wscanf F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 7f4a146d22..48b2240b88 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -144,6 +144,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index a83cc81958..1d5c482c89 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -141,6 +141,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 32887b1c58..a93d48f7ea 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2104,3 +2104,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index baf425072b..7e265ef570 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2063,6 +2063,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 8b0242a9b1..d80285427a 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2229,6 +2229,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index b6ba86dbe9..6619fe4b31 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2095,6 +2095,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index e1f7e19de9..56b651998c 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -145,6 +145,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
 GLIBC_2.4 _IO_2_1_stdin_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 2d726097ca..ad200c9f63 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2175,6 +2175,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 7c78649e03..f91a744ce2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2155,3 +2155,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index da2194b498..c5e86ddb4d 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2152,3 +2152,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 9fa655b3a5..f71c242463 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2146,6 +2146,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 3f6da71769..7854bdc5fc 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2144,6 +2144,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index de990933cf..f590577194 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2152,6 +2152,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 754491f209..8518b7fe2f 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2146,6 +2146,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 36a875115c..1d6bc7018d 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2193,3 +2193,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 6de9bed51d..2925850690 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2202,6 +2202,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 5c8c58974c..3c816ec48f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2235,6 +2235,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index 92114806ac..376057d86d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2065,6 +2065,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index b01fdcfae1..e69191b82a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2355,3 +2355,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index 3bea073169..2aad26a91c 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -1168,6 +1168,7 @@ GLIBC_2.33 lutimes F
 GLIBC_2.33 madvise F
 GLIBC_2.33 makecontext F
 GLIBC_2.33 mallinfo F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.33 malloc F
 GLIBC_2.33 malloc_info F
 GLIBC_2.33 malloc_stats F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 45cbeb1d98..04bc7b1e6f 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2122,3 +2122,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index d0752dba6c..2940f787ae 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2200,6 +2200,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index af5f14d1c6..e9d2023b8c 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2101,6 +2101,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 038ce27174..d98ef4f519 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2070,6 +2070,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 182970a708..8c8507ec14 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2067,6 +2067,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index a2521c3ee3..b4274d4fa4 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2191,6 +2191,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 _IO_fprintf F
 GLIBC_2.4 _IO_printf F
 GLIBC_2.4 _IO_sprintf F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index d8188903f9..a683b0af97 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2118,6 +2118,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 1a96103c68..c360212e8d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2076,6 +2076,7 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 35745a75b6..e6d064cac7 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2173,3 +2173,4 @@ GLIBC_2.32 sigabbrev_np F
 GLIBC_2.32 sigdescr_np F
 GLIBC_2.32 strerrordesc_np F
 GLIBC_2.32 strerrorname_np F
+GLIBC_2.33 mallinfo2 F


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] Use size_t for mallinfo fields.
  2020-09-02 16:11                                   ` DJ Delorie
@ 2020-09-21  8:49                                     ` Martin Liška
  0 siblings, 0 replies; 39+ messages in thread
From: Martin Liška @ 2020-09-21  8:49 UTC (permalink / raw)
  To: DJ Delorie; +Cc: joseph, schwab, fw, libc-alpha

On 9/2/20 6:11 PM, DJ Delorie wrote:
> As others have noted, getting this right is more complicated that you'd
> think.  I'm in the middle of debugging the ABI list changes and will
> likely have to refactor the mallinfo2 code to get it right, so don't
> worry about this one, I'll take care of it;-)

Thank you for it DJ!

Martin

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2020-09-21  8:49 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 12:00 [PATCH] Use size_t for mallinfo fields 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
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

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).