On Thu, Oct 29, 2020 at 10:36 AM Sunil Kumar Kori <sk...@marvell.com> wrote: > Yes but I am not able to understand that how tp->ctf_field will be populated > with latest memory > because RTE_PER_LCORE(ctf_field) is being free and re-allocated at runtime.
Initially, RTE_PER_LCORE(ctf_field) is NULL. Then registration for a trace point happens: __rte_trace_point_register() calls register_fn() which for each field in the trace point calls __rte_trace_point_emit_field(). Each call to __rte_trace_point_emit_field accumulates the previous ctf_field with the new field. rc = asprintf(&field, "%s %s %s;\n", RTE_PER_LCORE(ctf_field) != NULL ? RTE_PER_LCORE(ctf_field) : "", datatype, in); free(RTE_PER_LCORE(ctf_field)); RTE_PER_LCORE(ctf_field) = field; Here, RTE_PER_LCORE(ctf_field) is != NULL. Back to __rte_trace_point_register: /* Copy the accumulated fields description and clear it for the next * trace point. */ tp->ctf_field = RTE_PER_LCORE(ctf_field); Once stored, RTE_PER_LCORE(ctf_field) is cleared again for the next trace point registration. RTE_PER_LCORE(ctf_field) = NULL; -- David Marchand