[PATCH 6.17 117/507] bpf: Refactor stack map trace depth calculation into helper function