Re: [PATCH v4 bpf-next 4/6] bpf: udp: Avoid socket skips and repeats during iteration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
+	}
  }





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux