Re: [PATCH v2 00/16] Address some perf memory/data size issues

From: Ian Rogers
Date: Tue May 30 2023 - 02:55:01 EST


On Mon, May 29, 2023 at 9:57 PM Andi Kleen <ak@xxxxxxxxxxxxxxx> wrote:
>
>
> FWIW I think the whole patchkit could be replaced with a one liner
> that disables THP for the BSS segment. I suspect that would be roughly
> equivalent for memory consumption because 4K pages that are never
> touched would never be allocated.
>
> -Andi

So, it is worth reading some of the comments on the code to see why a
wider clean up is worth it:
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/util/path.c?h=perf-tools#n7
"It's obviously not thread-safe. Sue me."
(a comment stemming back to the git origins of the code base)

BSS won't count toward file size, which the patches were primarily
going after - but checking the size numbers I have miscalculated from
reading size's output that I'm not familiar with. The numbers are
still improved, but I just see a 37kb saving, with 5kb more in
.rodata. Something but not much. .data.rel.ro is larger, which imo is
good, but those pages will still be dirtied so a mute point wrt file
size and memory overhead.

For huge pages I thought it was correct that things are aligned by max
page size which I thought on x86-64 was 2MB, so I tried:
EXTRA_LDFLAGS="-z max-page-size=4096"
but it made no difference to anything, and with:
EXTRA_CFLAGS="-Wl,-z,max-page-size=4096"
EXTRA_CXXFLAGS="-Wl,-z,max-page-size=4096"
file size just got worse.

Thanks,
Ian