fs/inode: add optional manual FD backtrace control via task group flag

When CONFIG_FS_BACKTRACE is enabled, collecting a stack trace for every
new file descriptor adds overhead to fast path operations like open(),
dup(), and socket().

This patch adds a new configuration option CONFIG_FS_BACKTRACE_DEFAULT.
When enabled (default behavior), the GROUP_FLAG_FD_BACKTRACE flag is
automatically set during group allocation, causing backtrace to be
captured for all tasks globally, preserving the original diagnostic
capability.

When disabled, backtrace capture is zero-cost by default and must be
explicitly enabled per task group using GROUP_FLAG_FD_BACKTRACE.

Signed-off-by: zhanxiaoqi <zhanxiaoqi@bytedance.com>
This commit is contained in:
zhanxiaoqi 2026-04-23 11:48:54 +08:00 committed by Alin Jerpelea
parent 62b71c3b30
commit 786b315947
4 changed files with 32 additions and 6 deletions

View file

@ -163,6 +163,12 @@ int group_allocate(FAR struct tcb_s *tcb, uint8_t ttype)
sq_init(&group->tg_members);
#endif
#ifdef CONFIG_FS_BACKTRACE_DEFAULT
/* Enable FD backtrace for the group by default */
group->tg_flags |= GROUP_FLAG_FD_BACKTRACE;
#endif
/* Attach the group to the TCB */
tcb->group = group;