Re: [PATCH 1/1 v3 bpf-next] bpf: increment and use correct thread iterator
From: Andrii Nakryiko <hidden>
Date: 2020-12-12 00:47:33
Also in:
bpf
On Fri, Dec 11, 2020 at 3:01 PM Jonathan Lemon [off-list ref] wrote:
On Fri, Dec 11, 2020 at 12:23:34PM -0800, Andrii Nakryiko wrote:quoted
quoted
@@ -164,7 +164,7 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info) curr_files = get_files_struct(curr_task); if (!curr_files) { put_task_struct(curr_task); - curr_tid = ++(info->tid); + curr_tid = curr_tid + 1;Yonghong might know definitively, but it seems like we need to update info->tid here as well: info->tid = curr_tid; If the search eventually yields no task, then info->tid will stay at some potentially much smaller value, and we'll keep re-searching tasks from the same TID on each subsequent read (if user keeps reading the file). So corner case, but good to have covered.That applies earlier as well: curr_task = task_seq_get_next(ns, &curr_tid, true); if (!curr_task) { info->task = NULL; info->files = NULL; return NULL; }
True, info->tid = curr_tid + 1; seems to be needed here?
The logic seems to be "if task == NULL, then return NULL and stop". Is the seq_iterator allowed to continue/restart if seq_next returns NULL?
I don't think we allow seeking, so no restarts. But nothing will prevent the user to keep calling read() after it returns 0 byte, so yes, continuation is possible.
-- Jonathan