mbox series

[bpf-next,v4,0/3] Add kernel symbol for struct_ops trampoline

Message ID 20241112145849.3436772-1-xukuohai@huaweicloud.com (mailing list archive)
Headers show
Series Add kernel symbol for struct_ops trampoline | expand

Message

Xu Kuohai Nov. 12, 2024, 2:58 p.m. UTC
Add kernel symbol for struct_ops trampoline.

Without kernel symbol for struct_ops trampoline, the unwinder may
produce unexpected stacktraces. For example, the x86 ORC and FP
unwinder stops stacktrace on a struct_ops trampoline address since
there is no kernel symbol for the address.

v4:
- Add a separate cleanup patch to remove unused member rcu from
  bpf_struct_ops_map (patch 1)
- Use funcs_cnt instead of btf_type_vlen(vt) for links memory
  calculation in .map_mem_usage (patch 2)
- Include ksyms[] memory in map_mem_usage (patch 3)
- Various fixes in patch 3 (Thanks to Martin)

v3: https://lore.kernel.org/bpf/20241111121641.2679885-1-xukuohai@huaweicloud.com/
- Add a separate cleanup patch to replace links_cnt with funcs_cnt
- Allocate ksyms on-demand in update_elem() to stay with the links
  allocation way
- Set ksym name to prog__<struct_ops_name>_<member_name>

v2: https://lore.kernel.org/bpf/20241101111948.1570547-1-xukuohai@huaweicloud.com/
- Refine the commit message for clarity and fix a test bot warning

v1: https://lore.kernel.org/bpf/20241030111533.907289-1-xukuohai@huaweicloud.com/

Xu Kuohai (3):
  bpf: Remove unused member rcu from bpf_struct_ops_map
  bpf: Use function pointers count as struct_ops links count
  bpf: Add kernel symbol for struct_ops trampoline

 include/linux/bpf.h         |   3 +-
 kernel/bpf/bpf_struct_ops.c | 115 ++++++++++++++++++++++++++++++++----
 kernel/bpf/dispatcher.c     |   3 +-
 kernel/bpf/trampoline.c     |   9 ++-
 4 files changed, 114 insertions(+), 16 deletions(-)

Comments

Martin KaFai Lau Nov. 13, 2024, 12:59 a.m. UTC | #1
On 11/12/24 6:58 AM, Xu Kuohai wrote:
> Add kernel symbol for struct_ops trampoline.
> 
> Without kernel symbol for struct_ops trampoline, the unwinder may
> produce unexpected stacktraces. For example, the x86 ORC and FP
> unwinder stops stacktrace on a struct_ops trampoline address since
> there is no kernel symbol for the address.

Reviewed-by: Martin KaFai Lau <martin.lau@kernel.org>
patchwork-bot+netdevbpf@kernel.org Nov. 13, 2024, 1:20 a.m. UTC | #2
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue, 12 Nov 2024 22:58:46 +0800 you wrote:
> Add kernel symbol for struct_ops trampoline.
> 
> Without kernel symbol for struct_ops trampoline, the unwinder may
> produce unexpected stacktraces. For example, the x86 ORC and FP
> unwinder stops stacktrace on a struct_ops trampoline address since
> there is no kernel symbol for the address.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v4,1/3] bpf: Remove unused member rcu from bpf_struct_ops_map
    https://git.kernel.org/bpf/bpf-next/c/bd9d9b48eb18
  - [bpf-next,v4,2/3] bpf: Use function pointers count as struct_ops links count
    https://git.kernel.org/bpf/bpf-next/c/821a3fa32bbe
  - [bpf-next,v4,3/3] bpf: Add kernel symbol for struct_ops trampoline
    https://git.kernel.org/bpf/bpf-next/c/7c8ce4ffb684

You are awesome, thank you!