On 4/19/25 8:58 AM, Jordan Rife wrote:
static void bpf_iter_udp_put_batch(struct bpf_udp_iter_state *iter) { - while (iter->cur_sk < iter->end_sk) - sock_put(iter->batch[iter->cur_sk++].sock); + union bpf_udp_iter_batch_item *item; + unsigned int cur_sk = iter->cur_sk; + __u64 cookie; + + /* Remember the cookies of the sockets we haven't seen yet, so we can + * pick up where we left off next time around. + */ + while (cur_sk < iter->end_sk) { + item = &iter->batch[cur_sk++]; + cookie = __sock_gen_cookie(item->sock);
This can be called in the start/stop which is preemptible. I suspect this should be sock_gen_cookie instead of __sock_gen_cookie. gen_cookie_next() is using this_cpu_ptr.
+ sock_put(item->sock); + item->cookie = cookie; + } }