All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: acme@kernel.org
Cc: ihor.solodrai@pm.me, eddyz87@gmail.com, dwarves@vger.kernel.org,
	Alan Maguire <alan.maguire@oracle.com>
Subject: [PATCH dwarves] btf_encoder: use ELF_C_READ_MMAP
Date: Mon, 14 Oct 2024 11:31:42 +0100	[thread overview]
Message-ID: <20241014103142.2280044-1-alan.maguire@oracle.com> (raw)

This reduces peak memory utilization during BTF vmlinux encoding,
replacing ELF section-sized malloc()s with mmap()s.

For -j1 peak memory resident set size drops from

        Maximum resident set size (kbytes): 1069220

...to:

        Maximum resident set size (kbytes): 701888

...with this patch.

For -j8, peak memory resident set size drops from

        Maximum resident set size (kbytes): 1121172

...to:

        Maximum resident set size (kbytes): 963516

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
 btf_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/btf_encoder.c b/btf_encoder.c
index 5954238..9599faf 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -1879,7 +1879,7 @@ static int btf_encoder__tag_kfuncs(struct btf_encoder *encoder)
 		goto out;
 	}
 
-	elf = elf_begin(fd, ELF_C_READ, NULL);
+	elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
 	if (elf == NULL) {
 		elf_error("Cannot update ELF file");
 		goto out;
-- 
2.43.5


             reply	other threads:[~2024-10-14 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 10:31 Alan Maguire [this message]
2024-10-14 16:21 ` [PATCH dwarves] btf_encoder: use ELF_C_READ_MMAP Ihor Solodrai
2024-10-18 12:59 ` Arnaldo Carvalho de Melo

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=20241014103142.2280044-1-alan.maguire@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=acme@kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@pm.me \
    /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.