Skip to content

Commit 1e07fd4

Browse files
XDP: skip run-lifecycle hooks for XDP_KERNEL* internal runs
XDP plugins that submit their own ELF (e.g. aie_halt/ve2, aie_nop_util, and future plugin configurations) create an xrt::run with the kernel name "XDP_KERNEL:{IPUV1CNN}". The run-lifecycle XDP hooks (run_constructor / run_start / run_wait) would then attempt to instrument these internal runs through whatever plugin currently registers the callbacks (today aie_dtrace), which is incorrect and order-dependent on plugin load. Add a tiny file-local is_xdp_internal_kernel() helper that does a prefix match on the (already colon-stripped) kernel name, and skip the dispatch at the top of each of the three top-level xrt_core::xdp run dispatchers. The check runs first so any future XDP plugin consumer added below the config gate inherits the same skip rule. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c63dac0 commit 1e07fd4

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/runtime_src/core/common/xdp/profile.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <cstring>
1515
#include <functional>
1616
#include <sstream>
17+
#include <string_view>
1718
#include <cstdlib>
1819

1920
#ifdef _WIN32
@@ -949,9 +950,24 @@ finish_flush_device(void* handle)
949950
#endif
950951
}
951952

953+
// XDP plugins that submit their own ELF name the xrt::ext::kernel
954+
// "XDP_KERNEL" or "XDP_KERNEL_<suffix>" so the run-lifecycle hooks
955+
// can skip self-instrumentation of those internal runs.
956+
static bool
957+
is_xdp_internal_kernel(const xrt::run_impl* run_impl)
958+
{
959+
xrt_kernel_data data{};
960+
xrt_core::kernel_int::get_xdp_kernel_data(run_impl, &data);
961+
constexpr std::string_view prefix{"XDP_KERNEL"};
962+
return data.name.compare(0, prefix.size(), prefix.data(), prefix.size()) == 0;
963+
}
964+
952965
void
953966
run_constructor(xrt::run_impl* run_impl)
954967
{
968+
if (is_xdp_internal_kernel(run_impl))
969+
return;
970+
955971
if (!xrt_core::config::get_aie_dtrace())
956972
return;
957973

@@ -961,6 +977,9 @@ run_constructor(xrt::run_impl* run_impl)
961977
void
962978
run_start(const xrt::run_impl* run_impl)
963979
{
980+
if (is_xdp_internal_kernel(run_impl))
981+
return;
982+
964983
if (!xrt_core::config::get_aie_dtrace())
965984
return;
966985

@@ -970,6 +989,9 @@ run_start(const xrt::run_impl* run_impl)
970989
void
971990
run_wait(const xrt::run_impl* run_impl)
972991
{
992+
if (is_xdp_internal_kernel(run_impl))
993+
return;
994+
973995
if (!xrt_core::config::get_aie_dtrace())
974996
return;
975997

0 commit comments

Comments
 (0)