fs/inode: add dynamic FD backtrace threshold control#18767
Open
xiaoqizhan wants to merge 1 commit intoapache:masterfrom
Open
fs/inode: add dynamic FD backtrace threshold control#18767xiaoqizhan wants to merge 1 commit intoapache:masterfrom
xiaoqizhan wants to merge 1 commit intoapache:masterfrom
Conversation
When CONFIG_FS_BACKTRACE is enabled, collecting a stack trace for every new file descriptor adds avoidable overhead to tasks that use only a small number of FDs. Add a dynamic threshold option so backtrace capture is enabled only after the per-task FD count reaches the configured limit. Signed-off-by: zhanxiaoqi <zhanxiaoqi@bytedance.com>
acassis
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When CONFIG_FS_BACKTRACE is enabled, collecting a stack trace for every new file descriptor adds avoidable overhead to tasks that use only a small number of FDs.
Add a dynamic threshold option so backtrace capture is enabled only after the per-task FD count reaches the configured limit.
Note: Please adhere to Contributing Guidelines.
Summary
This patch introduces a dynamic backtrace threshold control mechanism for file descriptors.
performance overhead on tasks that only allocate a small number of file descriptors and never exceed typical limits or experience FD leaks.
open file descriptors per task (
fl_open_count) and only begins filling the backtrace array (f_backtrace) once the per-task file descriptor count reaches a configurable threshold(
CONFIG_FS_BACKTRACE_DEFAULT_THRESHOLD).resource leaks when they actually occur.
Impact
Testing
Host Machine: Ubuntu Linux (x86_64)
Target: Verified on generic simulators and local boards (e.g.
sim:nsh)fdlist).
5. Tested
fdlist_copy(task creation) to ensure backtrace thresholds and states are correctly propagated/initialized for child tasks.