All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - mm: use mallinfo2 when available
Date: Tue, 30 Aug 2022 11:57:44 +0000 (GMT)	[thread overview]
Message-ID: <20220830115744.8C8BB3854148@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b553bf6fa817a38474f48816fc520d178cb48229
Commit:        b553bf6fa817a38474f48816fc520d178cb48229
Parent:        8370d117d7ef8a472c95315a3cd085696c90b3be
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Tue Aug 30 13:48:18 2022 +0200
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Tue Aug 30 13:56:16 2022 +0200

mm: use mallinfo2 when available

Switch to mallinfo2() from a deprecated mallinfo() glibc call
since struct size members where to small for 64b CPUs.
---
 WHATS_NEW        |  1 +
 lib/mm/memlock.c | 13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/WHATS_NEW b/WHATS_NEW
index 9e7cd1f0c..293c034af 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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


                 reply	other threads:[~2022-08-30 11:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220830115744.8C8BB3854148@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.