Re: [PATCH v2 46/53] objtool/klp: Rewrite symbol correlation algorithm

Song Liu <[email protected]>
Newsgroups org.kernel.vger.live-patching,org.kernel.vger.linux-kernel
Message-ID <CAPhsuW7Pmxt5MbNtmUWcpWxHBLhVK6TLocOmuEkJtHUBkmxueA@mail.gmail.com>
On Fri, May 1, 2026 at 5:09 AM Josh Poimboeuf <[email protected]> wrote:
>
> Rewrite the symbol correlation code, using a tiered list of
> deterministic strategies in a loop.  For duplicately named symbols, each
> tier applies a filter with the goal of finding a 1:1 deterministic
> correlation between the original and patched version of the symbol.
>
> The three matching strategies are:
>
>   find_twin(): A funnel of progressively tighter filters.  Candidates
>   with the same demangled name are counted at four levels: name, scope
>   (local-vs-global), file (strict file association), and checksum
>   (unchanged functions).  The widest level that yields a 1:1 match wins,
>   narrower levels are only tried when the wider level is ambiguous.
>
>   find_twin_suffixed(): Uses already-correlated LLVM symbol pairs to map
>   .llvm.<hash> suffixes from orig to patched.  Because all promoted
>   symbols from the same TU share the same hash, one correlated pair
>   seeds the mapping for the entire TU.
>
>   find_twin_positional(): Last resort, matches symbols by position among
>   same-named candidates, similar to livepatch sympos.  Used for data
>   objects like __quirk variables where no deterministic filter can
>   distinguish the candidates.
>
> Overall this works much better than the existing algorithm, particularly
> with LTO kernels.
>
> Signed-off-by: Josh Poimboeuf <[email protected]>

Acked-by: Song Liu <[email protected]>

Thanks for improving the correlation algorithm and adding detailed
comments about all these scenarios!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.