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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 21, 2023 at 5:08 AM Andi Kleen <ak@xxxxxxxxxxxxxxx> wrote:
>
> >
> > > +    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.



I do not understand because there is nothing to handle gaps
in your code.


get_syms() appends only 'pc' into the list.


Then,

  sym_sizes = [syms[x + 1] - syms[x] for x, _ in enumerate(syms[:-1])]


computes each symbol size by:

   (address of the next symbol) - (address of the current symbol).


So, your code is equivalent to:

   sym_total = syms[-1] - syms[0]










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

--
Best Regards
Masahiro Yamada





[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux