From 19dedede53cb3fa6f5a5eb41d2f33d6e214dc79b Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Sat, 1 Nov 2025 14:05:50 +0530 Subject: [PATCH] Implement BPF_GET_SMP_PROCESSOR_ID helper --- pythonbpf/helper/bpf_helper_handler.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pythonbpf/helper/bpf_helper_handler.py b/pythonbpf/helper/bpf_helper_handler.py index e231db9..230d4a8 100644 --- a/pythonbpf/helper/bpf_helper_handler.py +++ b/pythonbpf/helper/bpf_helper_handler.py @@ -514,6 +514,29 @@ def bpf_probe_read_emitter( return result, ir.IntType(64) +@HelperHandlerRegistry.register("smp_processor_id") +def bpf_get_smp_processor_id_emitter( + call, + map_ptr, + module, + builder, + func, + local_sym_tab=None, + struct_sym_tab=None, + map_sym_tab=None, +): + """ + Emit LLVM IR for bpf_get_smp_processor_id helper function call. + """ + helper_id = ir.Constant(ir.IntType(64), BPFHelperID.BPF_GET_SMP_PROCESSOR_ID.value) + fn_type = ir.FunctionType(ir.IntType(32), [], var_arg=False) + fn_ptr_type = ir.PointerType(fn_type) + fn_ptr = builder.inttoptr(helper_id, fn_ptr_type) + result = builder.call(fn_ptr, [], tail=False) + logger.info("Emitted bpf_get_smp_processor_id call") + return result, ir.IntType(32) + + def handle_helper_call( call, module,