bpf: remove unnecessary loop in task_file_seq_get_next()
Subsystems (3)
PATCH 1/1 bpf: remove unnecessary loop in task_file_seq_get_next()
After commit 0ede61d8589c ("file: convert to SLAB_TYPESAFE_BY_RCU") this loop always iterates exactly one time. Delete the for statement and pull the code in a tab.
--- kernel/bpf/task_iter.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
kernel/bpf/task_iter.c +3 -6
@@ -261,6 +261,7 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info)u32 saved_tid = info->tid;struct task_struct *curr_task;unsigned int curr_fd = info->fd; +struct file *f;/* If this function returns a non-NULL file object, * it held a reference to the task/file.
@@ -286,12 +287,8 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info) }rcu_read_lock (); -for (;; curr_fd++) { -struct file *f; - f =task_lookup_next_fdget_rcu (curr_task, &curr_fd); -if (!f) -break ; - + f =task_lookup_next_fdget_rcu (curr_task, &curr_fd); +if (f) {/* set info->fd */ info->fd = curr_fd;rcu_read_unlock ();
Signature · 1 line
2.43.0
Quoted 5 lines · Dan Carpenter
After commit
0ede61d8589c("file: convert toSLAB_TYPESAFE_BY_RCU") this loop always iterates exactly one time. Delete the for statement and pull the code in a tab.Signed-off-by Dan Carpenter <[email protected]>
lgtm
jirka
Quoted 34 lines
--- kernel/bpf/task_iter.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)kernel/bpf/task_iter.c +3
-6@@ -261,6 +261,7 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info)u32 saved_tid = info->tid;struct task_struct *curr_task;unsigned int curr_fd = info->fd; +struct file *f;/* If this function returns a non-NULL file object, * it held a reference to the task/file. @@ -286,12 +287,8 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info) }rcu_read_lock (); -for (;; curr_fd++) { -struct file *f; - f =task_lookup_next_fdget_rcu (curr_task, &curr_fd); -if (!f) -break ; - + f =task_lookup_next_fdget_rcu (curr_task, &curr_fd); +if (f) {/* set info->fd */ info->fd = curr_fd;rcu_read_unlock ();Signature · 1 line
2.43.0
Quoted 6 lines · Dan Carpenter
After commit
0ede61d8589c("file: convert toSLAB_TYPESAFE_BY_RCU") this loop always iterates exactly one time. Delete the for statement and pull the code in a tab.Signed-off-by Dan Carpenter <[email protected]>---
Quoted 5 lines · Dan Carpenter
After commit
0ede61d8589c("file: convert toSLAB_TYPESAFE_BY_RCU") this loop always iterates exactly one time. Delete the for statement and pull the code in a tab.Signed-off-by Dan Carpenter <[email protected]>
LGTM. Thanks for the cleanup.
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 8 lines · On Thu, 4 Jul 2024 10:19:19 -0500 you wrote:
After commit
0ede61d8589c("file: convert toSLAB_TYPESAFE_BY_RCU") this loop always iterates exactly one time. Delete the for statement and pull the code in a tab.Signed-off-by Dan Carpenter <[email protected]>--- kernel/bpf/task_iter.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Here is the summary with links:
- [bpf-next] bpf: remove unnecessary loop in task_file_seq_get_next()
https://git.kernel.org/bpf/bpf-next/c/bc239eb271e5
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html