- if (caa_unlikely(!URCU_TLS(cached_procname)[0])) {
- lttng_ust_getprocname(URCU_TLS(cached_procname));
- URCU_TLS(cached_procname)[LTTNG_UST_PROCNAME_LEN - 1] = '\0';
+ int nesting = CMM_LOAD_SHARED(URCU_TLS(procname_nesting));
+
+ if (caa_unlikely(nesting >= PROCNAME_NESTING_MAX))
+ return "<unknown>";
+ if (caa_unlikely(!URCU_TLS(cached_procname)[nesting][0])) {
+ CMM_STORE_SHARED(URCU_TLS(procname_nesting), nesting + 1);
+ /* Increment nesting before updating cache. */
+ cmm_barrier();
+ lttng_ust_getprocname(URCU_TLS(cached_procname)[nesting]);
+ URCU_TLS(cached_procname)[nesting][LTTNG_UST_PROCNAME_LEN - 1] = '\0';
+ /* Decrement nesting after updating cache. */
+ cmm_barrier();
+ CMM_STORE_SHARED(URCU_TLS(procname_nesting), nesting);