[PATCH 6.18 139/614] bpf: Refactor stack map trace depth calculation into helper function