Lines Matching refs:seq
44 static void bpf_iter_inc_seq_num(struct seq_file *seq) in bpf_iter_inc_seq_num() argument
48 iter_priv = container_of(seq->private, struct bpf_iter_priv_data, in bpf_iter_inc_seq_num()
53 static void bpf_iter_dec_seq_num(struct seq_file *seq) in bpf_iter_dec_seq_num() argument
57 iter_priv = container_of(seq->private, struct bpf_iter_priv_data, in bpf_iter_dec_seq_num()
62 static void bpf_iter_done_stop(struct seq_file *seq) in bpf_iter_done_stop() argument
66 iter_priv = container_of(seq->private, struct bpf_iter_priv_data, in bpf_iter_done_stop()
76 static bool bpf_iter_support_resched(struct seq_file *seq) in bpf_iter_support_resched() argument
80 iter_priv = container_of(seq->private, struct bpf_iter_priv_data, in bpf_iter_support_resched()
97 struct seq_file *seq = file->private_data; in bpf_seq_read() local
103 mutex_lock(&seq->lock); in bpf_seq_read()
105 if (!seq->buf) { in bpf_seq_read()
106 seq->size = PAGE_SIZE << 3; in bpf_seq_read()
107 seq->buf = kvmalloc(seq->size, GFP_KERNEL); in bpf_seq_read()
108 if (!seq->buf) { in bpf_seq_read()
114 if (seq->count) { in bpf_seq_read()
115 n = min(seq->count, size); in bpf_seq_read()
116 err = copy_to_user(buf, seq->buf + seq->from, n); in bpf_seq_read()
121 seq->count -= n; in bpf_seq_read()
122 seq->from += n; in bpf_seq_read()
127 seq->from = 0; in bpf_seq_read()
128 p = seq->op->start(seq, &seq->index); in bpf_seq_read()
133 seq->op->stop(seq, p); in bpf_seq_read()
134 seq->count = 0; in bpf_seq_read()
138 err = seq->op->show(seq, p); in bpf_seq_read()
143 bpf_iter_dec_seq_num(seq); in bpf_seq_read()
144 seq->count = 0; in bpf_seq_read()
145 } else if (err < 0 || seq_has_overflowed(seq)) { in bpf_seq_read()
148 seq->op->stop(seq, p); in bpf_seq_read()
149 seq->count = 0; in bpf_seq_read()
153 can_resched = bpf_iter_support_resched(seq); in bpf_seq_read()
155 loff_t pos = seq->index; in bpf_seq_read()
158 offs = seq->count; in bpf_seq_read()
159 p = seq->op->next(seq, p, &seq->index); in bpf_seq_read()
160 if (pos == seq->index) { in bpf_seq_read()
163 seq->op->next); in bpf_seq_read()
164 seq->index++; in bpf_seq_read()
171 bpf_iter_inc_seq_num(seq); in bpf_seq_read()
173 if (seq->count >= size) in bpf_seq_read()
179 seq->op->stop(seq, p); in bpf_seq_read()
185 err = seq->op->show(seq, p); in bpf_seq_read()
187 bpf_iter_dec_seq_num(seq); in bpf_seq_read()
188 seq->count = offs; in bpf_seq_read()
189 } else if (err < 0 || seq_has_overflowed(seq)) { in bpf_seq_read()
190 seq->count = offs; in bpf_seq_read()
194 seq->op->stop(seq, p); in bpf_seq_read()
204 offs = seq->count; in bpf_seq_read()
206 seq->op->stop(seq, NULL); in bpf_seq_read()
211 seq->op->stop(seq, p); in bpf_seq_read()
213 if (!seq_has_overflowed(seq)) { in bpf_seq_read()
214 bpf_iter_done_stop(seq); in bpf_seq_read()
216 seq->count = offs; in bpf_seq_read()
224 n = min(seq->count, size); in bpf_seq_read()
225 err = copy_to_user(buf, seq->buf, n); in bpf_seq_read()
231 seq->count -= n; in bpf_seq_read()
232 seq->from = n; in bpf_seq_read()
238 mutex_unlock(&seq->lock); in bpf_seq_read()
266 struct seq_file *seq; in iter_release() local
268 seq = file->private_data; in iter_release()
269 if (!seq) in iter_release()
272 iter_priv = container_of(seq->private, struct bpf_iter_priv_data, in iter_release()
276 iter_priv->seq_info->fini_seq_private(seq->private); in iter_release()
279 seq->private = iter_priv; in iter_release()
439 struct seq_file *seq) in bpf_iter_link_show_fdinfo() argument
445 seq_printf(seq, in bpf_iter_link_show_fdinfo()
451 show_fdinfo(&iter_link->aux, seq); in bpf_iter_link_show_fdinfo()
598 struct seq_file *seq; in prepare_seq_file() local
623 seq = file->private_data; in prepare_seq_file()
624 seq->private = priv_data->target_private; in prepare_seq_file()
675 struct seq_file *seq; in bpf_iter_get_info() local
678 seq = meta->seq; in bpf_iter_get_info()
679 if (seq->file->f_op != &bpf_iter_fops) in bpf_iter_get_info()
682 seq_priv = seq->private; in bpf_iter_get_info()