Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2867178pxu; Mon, 14 Dec 2020 12:49:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPJUTonL4Z1GXJtbeWsTq+JhXHD5J77JYOMbMlT0rnMAnGIg9lZkIJ27nQlQ9uGWBrVb2n X-Received: by 2002:a17:906:2850:: with SMTP id s16mr23560286ejc.276.1607978992048; Mon, 14 Dec 2020 12:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607978992; cv=none; d=google.com; s=arc-20160816; b=pqhrzPXHsm3gTxHjIQMvAzU0YL6PCWd1183kS+aXJmk4zRAtZLcmIgrv9f73VOSaJG 0XsLs6rDHUoGjjWIOyMhHFOK4BOhyzmusAKaAZX/s/LPJvlUY10kiNVC1CEa0HsU/lmn IHQGFekRvCXOzIpMqzHQOaXQ70hoZ4KgLjew3d6deZKCk5NjOZd8QO14sMN7CVx2lu+Y gBoXqFtENlzRW0NSLj3e9wmxbcfw1YFgbwwBzK8dtsuGD6WYzvUUClnIO+b6ZcC6TvDb hBwfBXd1vJFLcTo1KjEIcFKBbMvmsO2rRweps/J+sUVBJWOpfN24G7/3xXNaIJI8WBku 5h4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=dXMvoV9JwSr4GE4gr0pcy6PKhjqxeMba8JUk9sLJKg0=; b=NAt/EwKe+pfAiaNF9Hd9RnRRyuGlZ61BB68Et5JukJCBi7lzcK8XKKXPeaOshT7iIe Zd5ms2e1IF1ZwYXoIYN/45C3IGUHWcZha8omQyOnAs/C2m1TX1VrS2hS1+rRTc5z0DpJ zMN+lMeeIJWfOX0MxOJk2/kAD5ZU5nBV/uNTW2uj3zBk+UpT/0u7fRFGZE5IWq7iAjYi QbMyxDQ2kQs7Fl/+cGHf7/dH9Rbrsf+KqGI82bwtcPyMdoHMO1B29ZYH3b3eceEKJL1b nYLEhqFwnMykhwpD9Y6MaEkRNe/x84oI/RRaP4imVS5KDcVAJdKEf0H1TGu67QNXBP0g 8nLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si11636864eds.170.2020.12.14.12.49.28; Mon, 14 Dec 2020 12:49:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503431AbgLNUqw (ORCPT + 99 others); Mon, 14 Dec 2020 15:46:52 -0500 Received: from www62.your-server.de ([213.133.104.62]:33924 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503422AbgLNUqw (ORCPT ); Mon, 14 Dec 2020 15:46:52 -0500 Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1koujS-0008m6-GC; Mon, 14 Dec 2020 21:46:10 +0100 Received: from [85.7.101.30] (helo=pc-9.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1koujS-000Por-9g; Mon, 14 Dec 2020 21:46:10 +0100 Subject: Re: [PATCH bpf-next v2] libbpf: Expose libbpf ringbufer epoll_fd To: Brendan Jackman , bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , KP Singh , Florent Revest , linux-kernel@vger.kernel.org References: <20201214113812.305274-1-jackmanb@google.com> From: Daniel Borkmann Message-ID: Date: Mon, 14 Dec 2020 21:46:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20201214113812.305274-1-jackmanb@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.4/26017/Mon Dec 14 15:33:39 2020) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/14/20 12:38 PM, Brendan Jackman wrote: > This provides a convenient perf ringbuf -> libbpf ringbuf migration > path for users of external polling systems. It is analogous to > perf_buffer__epoll_fd. > > Signed-off-by: Brendan Jackman > --- > Difference from v1: Added entry to libbpf.map. > > tools/lib/bpf/libbpf.h | 1 + > tools/lib/bpf/libbpf.map | 1 + > tools/lib/bpf/ringbuf.c | 6 ++++++ > 3 files changed, 8 insertions(+) > > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h > index 6909ee81113a..cde07f64771e 100644 > --- a/tools/lib/bpf/libbpf.h > +++ b/tools/lib/bpf/libbpf.h > @@ -536,6 +536,7 @@ LIBBPF_API int ring_buffer__add(struct ring_buffer *rb, int map_fd, > ring_buffer_sample_fn sample_cb, void *ctx); > LIBBPF_API int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms); > LIBBPF_API int ring_buffer__consume(struct ring_buffer *rb); > +LIBBPF_API int ring_buffer__epoll_fd(struct ring_buffer *rb); > > /* Perf buffer APIs */ > struct perf_buffer; > diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map > index 7c4126542e2b..7be850271be6 100644 > --- a/tools/lib/bpf/libbpf.map > +++ b/tools/lib/bpf/libbpf.map > @@ -348,4 +348,5 @@ LIBBPF_0.3.0 { > btf__new_split; > xsk_setup_xdp_prog; > xsk_socket__update_xskmap; > + ring_buffer__epoll_fd; Fyi, this had a whitespace issue, Andrii fixed it up while applying. > } LIBBPF_0.2.0; > diff --git a/tools/lib/bpf/ringbuf.c b/tools/lib/bpf/ringbuf.c > index 5c6522c89af1..45a36648b403 100644 > --- a/tools/lib/bpf/ringbuf.c > +++ b/tools/lib/bpf/ringbuf.c > @@ -282,3 +282,9 @@ int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms) > } > return cnt < 0 ? -errno : res; > } > + > +/* Get an fd that can be used to sleep until data is available in the ring(s) */ > +int ring_buffer__epoll_fd(struct ring_buffer *rb) > +{ > + return rb->epoll_fd; > +} > > base-commit: b4fe9fec51ef48011f11c2da4099f0b530449c92 > -- > 2.29.2.576.ga3fc446d84-goog >