Re: [PATCH bpf-next v8 1/4] bpf: add btf pointer to struct bpf_ctx_arg_aux.

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

 



On 2/8/24 6:37 PM, thinker.li@xxxxxxxxx wrote:
From: Kui-Feng Lee <thinker.li@xxxxxxxxx>

Enable the providers to use types defined in a module instead of in the
kernel (btf_vmlinux).

Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx>
---
  include/linux/bpf.h | 1 +
  kernel/bpf/btf.c    | 2 +-
  2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 1ebbee1d648e..9a2ee9456989 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1416,6 +1416,7 @@ struct bpf_ctx_arg_aux {
  	u32 offset;
  	enum bpf_reg_type reg_type;
  	u32 btf_id;
+	struct btf *btf;

It will leave a 4 bytes hole. Not a big deal considering the sizeof won't change regardless but still would be nice to avoid it.

Moving "struct btf *btf" to the top will need code churns in all the existing bpf_iter_* because they do not use the ".offset = " and ".reg_type = " style to initialize. I am going to move this pointer addition before the "u32 btf_id;" instead. No need to resend.

  };
struct btf_mod_pair {
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 8e06d29961f1..7c6c9fefdbd6 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6266,7 +6266,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,
  			}
info->reg_type = ctx_arg_info->reg_type;
-			info->btf = btf_vmlinux;
+			info->btf = ctx_arg_info->btf ? ctx_arg_info->btf : btf_vmlinux;
  			info->btf_id = ctx_arg_info->btf_id;
  			return true;
  		}





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux