Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp689787pxu; Fri, 11 Dec 2020 11:48:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcniH+VydhBnM0t9yOZXISzgqrI2hqQnuQVcdCJJQTEULrq46g5RvSjiEP4UK14C8sx9gQ X-Received: by 2002:a17:907:9d0:: with SMTP id bx16mr13033932ejc.426.1607716110017; Fri, 11 Dec 2020 11:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607716110; cv=none; d=google.com; s=arc-20160816; b=H9tcbxtPmlWCsY1FFtSEpWM4TugxhtY4EjD5MFTRRqWV3H8m3rYEOLxXDR91yltxcY rjlCrdjYQOLWQkvj+xJw2bA2XzR9H+vpLKGL08EE/qJhvHwVeTFCUTLx4eKoYH4q6ei4 A1Jrm+F+ie/7dss0DrdIN+1Ev6w2k4eKd30nQjCTTRHLPMS8s0MzL+cSFVWgaM+MgzsM hlhBPHYd0EE/9sfcM3ce/767QvUlD4Efl99R2xipG1BKD/ey6RX0QSA3lYBEDI4cgVWy 102SmopbKq3cjK9lO3spT2WbYJ9U1ekemMquYNXsOHRx+iGBTkGMTkCCRN2jsck1b3OV 1opw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yRGKqHf4iwEt3TjWcP3Q5MjQ/uQIJtJpPWbQ5Zk+e3U=; b=c1kbdgp1lgSK1w66vfpOlOuv3Ktd8UytSVv11y3oR7R36GxMNcuEMVdrzfwf/bcIv6 WWDeyXyjSvsxjOgBTHMylu6XZXqPTKdUVrHtF8k4SyJpSn5BxKT2A0MskLg4FugGorXo UuknlMC4C+omlMPh5zlG0j8r83SKILfF18ZbPsKYKFu6gJxWXLhAe8A25ysfb57VEmuF TL03WNzUXHO1IzQkQc9U7NTY62OAXswKuskE9uPb1wZ5be77uLkWYARXsOGufY4nr8Tr nS8SjprCgv80dRovFnFEhQT171p2G7kcW98OTk4H9TYYGdbTJX8txa7/r77AjNmz0usk kbFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JFqOGf6S; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u19si6243411edo.433.2020.12.11.11.48.06; Fri, 11 Dec 2020 11:48:30 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JFqOGf6S; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391120AbgLKTpr (ORCPT + 99 others); Fri, 11 Dec 2020 14:45:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728090AbgLKTpd (ORCPT ); Fri, 11 Dec 2020 14:45:33 -0500 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF0FCC0613CF; Fri, 11 Dec 2020 11:44:52 -0800 (PST) Received: by mail-yb1-xb41.google.com with SMTP id o144so8583949ybc.0; Fri, 11 Dec 2020 11:44:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yRGKqHf4iwEt3TjWcP3Q5MjQ/uQIJtJpPWbQ5Zk+e3U=; b=JFqOGf6SQscn2ezlxm00wlKE1LUC8Ho53aY0g5ius2ClR0F+x67cL4JIXSPxFnqmIs I6PG9C97V2v6613KjntyK5gpTGJ/il1VtQ4uPEIcLGlK7rtiqHYTt/33jfSMzCgzprtq WPX6VN3OblFtiMk/LzKFpcXEmuzb0tEcyin0R8i6rGN+X60uSBPjXYTg8Bx1kwGEU1rT FndOT82FdgZjF575WQc8qBjGk2iI2eUWIQ3+H1bFiVAb7OOwCYYMb8m6rv7ZqgrEOz/u m8xKAeQlKZkFtBTLEG49bC7JRUbahhpcq3EWatA3k+gwASizOir+ZIuIhsaHtYtBzpi6 tfhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yRGKqHf4iwEt3TjWcP3Q5MjQ/uQIJtJpPWbQ5Zk+e3U=; b=lxwuh40E2DFWTQhE0ax+XqqGw8M2mA1gOg14XQLZbJSHH6PjNPSeNcbSoYGWGVp0mV UcJkXirEHtZEDd2gzN5ntEYNLRWHzL5geBHUfK/smuLPeV/nUk/iXsvzhAFGWagN0d5J LMWV4zxdPZzVI+qszR8dFqapFX2iJQ/tRllBEV9VndUhsSySjC/7tcqSL/EcjC+6Q4ZF o6vv/x4HK9/j8q2weB6HvanudS0/fJ6lnJo2QYXdiEt+BGpV2GoeobnTwfVvhMGN6cfU KIMNto4Q9YHAaJDMGAt1H85vKaP3AsUBPXT7Ib09NxePjNvK5ISyjxwWJl3TaYe8ypTC k04g== X-Gm-Message-State: AOAM530sqSAvyonkq0mxNFpofpIw7MzBAg9ClMdH+8AlFi9Fmx/k2l9Y ZteP2/fzrWc97jTQt8Wcclzyb0FMMAsVFFAi504= X-Received: by 2002:a25:c089:: with SMTP id c131mr20240415ybf.510.1607715892173; Fri, 11 Dec 2020 11:44:52 -0800 (PST) MIME-Version: 1.0 References: <20201211172409.1918341-1-jackmanb@google.com> In-Reply-To: <20201211172409.1918341-1-jackmanb@google.com> From: Andrii Nakryiko Date: Fri, 11 Dec 2020 11:44:41 -0800 Message-ID: Subject: Re: [PATCH bpf-next] libbpf: Expose libbpf ringbufer epoll_fd To: Brendan Jackman Cc: bpf , Alexei Starovoitov , Daniel Borkmann , KP Singh , Florent Revest , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 11, 2020 at 10:58 AM Brendan Jackman wrote: > > This allows the user to do their own manual polling in more > complicated setups. > > Signed-off-by: Brendan Jackman > --- perf_buffer has it, so it's good for consistency. In practice, though, I'd expect anyone who needs more complicated polling to use ring buf's map FD directly on their instance of epoll. Doesn't that work for you? Regardless, though, you need to add the API into libbpf.map file first. > tools/lib/bpf/libbpf.h | 1 + > tools/lib/bpf/ringbuf.c | 6 ++++++ > 2 files changed, 7 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/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 >