Re: [PATCH v2] kbuild: Add inline-account tool

From: Andi Kleen
Date: Mon Nov 20 2023 - 15:08:59 EST


>
> > + sym_sizes = [syms[x + 1] - syms[x] for x, _ in enumerate(syms[:-1])]
> > + sym_total = sum(sym_sizes)
>
>
> This is equivalent to
>
> sym_total = syms[-1] - syms[0]
>
> isn't it?

No it's not when there are gaps in the symbols, which always happens in
the kernel. The previous version used the range but that led to inbalances.

> def get_ranges(syms, threads):
>
> ranges = []
> prev = syms[0]
> i = 1
>
> while threads > 0:
>
> boundary = prev + 1 + (syms[-1] - prev - 1) // threads
>
> while syms[i] < boundary:
> i += 1


Note the boundary is not the address, but the sum of symbol sizes


-Andi