1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-19 14:04:17 +03:00

mm: use mallinfo2 when available

Switch to mallinfo2() from a deprecated mallinfo() glibc call
since struct size members where to small for 64b CPUs.
This commit is contained in:
Zdenek Kabelac 2022-08-30 13:48:18 +02:00
parent 8370d117d7
commit b553bf6fa8
2 changed files with 11 additions and 3 deletions

View File

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

View File

@ -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