On Sun, Jan 12, 2014 at 8:22 AM, Daniel Borkmann [off-list ref] wrote:
+static void packet_inc_pending(struct packet_ring_buffer *rb)
+{
+ this_cpu_inc(*rb->pending_refcnt);
+}
+
+static void packet_dec_pending(struct packet_ring_buffer *rb)
+{
+ this_cpu_dec(*rb->pending_refcnt);
+}
+
+static int packet_read_pending(const struct packet_ring_buffer *rb)
+{
+ int i, refcnt = 0;
+
+ /* We don't use pending refcount in rx_ring. */
+ if (rb->pending_refcnt == NULL)
+ return 0;
+
+ for_each_possible_cpu(i)
+ refcnt += *per_cpu_ptr(rb->pending_refcnt, i);
+
+ return refcnt;
+}
How is this supposed to work? Since there is no lock,
you can't read accurate refcnt. Take a look at lib/percpu_counter.c.
I guess for some reason you don't care the accuracy?
Then at least you need to comment in the code.
Thanks.