[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200522012147.shnwybm5my7dgy4v@ast-mbp.dhcp.thefacebook.com>
Date: Thu, 21 May 2020 18:21:47 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Andrii Nakryiko <andriin@...com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, ast@...com,
daniel@...earbox.net, andrii.nakryiko@...il.com,
kernel-team@...com, "Paul E . McKenney" <paulmck@...nel.org>,
Jonathan Lemon <jonathan.lemon@...il.com>
Subject: Re: [PATCH v2 bpf-next 6/7] bpf: add BPF ringbuf and perf buffer
benchmarks
On Sun, May 17, 2020 at 12:57:26PM -0700, Andrii Nakryiko wrote:
> +
> +static inline int roundup_len(__u32 len)
> +{
> + /* clear out top 2 bits */
> + len <<= 2;
> + len >>= 2;
> + /* add length prefix */
> + len += RINGBUF_META_LEN;
> + /* round up to 8 byte alignment */
> + return (len + 7) / 8 * 8;
> +}
the same round_up again?
> +
> +static void ringbuf_custom_process_ring(struct ringbuf_custom *r)
> +{
> + unsigned long cons_pos, prod_pos;
> + int *len_ptr, len;
> + bool got_new_data;
> +
> + cons_pos = smp_load_acquire(r->consumer_pos);
> + while (true) {
> + got_new_data = false;
> + prod_pos = smp_load_acquire(r->producer_pos);
> + while (cons_pos < prod_pos) {
> + len_ptr = r->data + (cons_pos & r->mask);
> + len = smp_load_acquire(len_ptr);
> +
> + /* sample not committed yet, bail out for now */
> + if (len & RINGBUF_BUSY_BIT)
> + return;
> +
> + got_new_data = true;
> + cons_pos += roundup_len(len);
> +
> + atomic_inc(&buf_hits.value);
> + }
> + if (got_new_data)
> + smp_store_release(r->consumer_pos, cons_pos);
> + else
> + break;
> + };
> +}
copy paste from libbpf? why?
Powered by blists - more mailing lists