diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2022-08-30 13:48:18 +0200 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2022-08-30 13:56:16 +0200 |
commit | b553bf6fa817a38474f48816fc520d178cb48229 (patch) | |
tree | 74f867c80edb2dded2d3f94676ec576b56c842f7 | |
parent | 8370d117d7ef8a472c95315a3cd085696c90b3be (diff) | |
download | lvm2-b553bf6fa817a38474f48816fc520d178cb48229.tar.gz |
mm: use mallinfo2 when available
Switch to mallinfo2() from a deprecated mallinfo() glibc call
since struct size members where to small for 64b CPUs.
-rw-r--r-- | WHATS_NEW | 1 | ||||
-rw-r--r-- | lib/mm/memlock.c | 13 |
2 files changed, 11 insertions, 3 deletions
@@ -1,5 +1,6 @@ Version 2.03.17 - =============================== + Switch to use mallinfo2 and use it only with glibc. Error out in lvm shell if using a cmd argument not supported in the shell. Fix lvm shell's lastlog command to report previous pre-command failures. Extend VDO and VDOPOOL without flushing and locking fs. diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c index 4a202866a..ad69f6474 100644 --- a/lib/mm/memlock.c +++ b/lib/mm/memlock.c @@ -167,7 +167,8 @@ static void _allocate_memory(void) */ void *stack_mem; struct rlimit limit; - int i, area = 0, missing = _size_malloc_tmp, max_areas = 32, hblks; + int i, area = 0, missing = _size_malloc_tmp, max_areas = 32; + size_t hblks; char *areas[max_areas]; /* Check if we could preallocate requested stack */ @@ -180,6 +181,12 @@ static void _allocate_memory(void) } /* FIXME else warn user setting got ignored */ +#ifdef HAVE_MALLINFO2 + /* Prefer mallinfo2 call when avaialble with newer glibc */ +#define MALLINFO mallinfo2 +#else +#define MALLINFO mallinfo +#endif /* * When a brk() fails due to fragmented address space (which sometimes * happens when we try to grab 8M or so), glibc will make a new @@ -191,13 +198,13 @@ static void _allocate_memory(void) * memory on free(), this is good enough for our purposes. */ while (missing > 0) { - struct mallinfo inf = mallinfo(); + struct MALLINFO inf = MALLINFO(); hblks = inf.hblks; if ((areas[area] = malloc(_size_malloc_tmp))) _touch_memory(areas[area], _size_malloc_tmp); - inf = mallinfo(); + inf = MALLINFO(); if (hblks < inf.hblks) { /* malloc cheated and used mmap, even though we told it |