From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DAB2C433F5 for ; Thu, 12 May 2022 09:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345467AbiELJN7 (ORCPT ); Thu, 12 May 2022 05:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242267AbiELJN6 (ORCPT ); Thu, 12 May 2022 05:13:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 880931BD70B for ; Thu, 12 May 2022 02:13:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 26A9F617D7 for ; Thu, 12 May 2022 09:13:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62F94C385B8; Thu, 12 May 2022 09:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652346836; bh=eanKwLGK/lGv6DwEKxEhaU3mHSj+HqQBOVEA1RHApnc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jbL8sassjBltUx6sorNuf3CG2lNL7JbTJ4t1IJgaHxyXJqA1Iu3ljEmkxzISclZdU h6GIyzaQWManG2qMr7zt3HRWz08tiBksqoz6Jkk+iOuPqEJ53fqwI233diWOyKZiUr 4fSYVWxfsGWIBT09Z/OdGS7unvo1CEmw3K8ToKlX86dnp4xh+wuWIBIb1eEvcp8XLZ Z+rI2BVRJwUt/4R11bSHKZsM/EpqMXVXLpH8/W5TmziKQVpuEuSlkqVlJOnwIWW8MI DEOKNE4cId7YuXac6+MzjEw7WFeSFRs4YM14hU500NnRnI8SA2lBsyK7vXV+MYHET6 2c8KFZSJ+gQIQ== Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 6014638E59F; Thu, 12 May 2022 11:13:53 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Michael Zimmermann Cc: Andrii Nakryiko , bpf Subject: Re: BPF maps don't work without CONFIG_TRACING/CONFIG_FTRACE In-Reply-To: References: <87czgji43i.fsf@toke.dk> X-Clacks-Overhead: GNU Terry Pratchett Date: Thu, 12 May 2022 11:13:53 +0200 Message-ID: <877d6ri04u.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Michael Zimmermann writes: > On Thu, May 12, 2022 at 9:48 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> >> Michael Zimmermann writes: >> >> > On Thu, May 12, 2022 at 5:21 AM Andrii Nakryiko >> > wrote: >> >> >> >> On Mon, May 9, 2022 at 10:12 PM Michael Zimmermann >> >> wrote: >> >> > >> >> > Thank you for your answer. >> >> > What I'm ultimately trying to do is: Use aya-rs to watch egress on a >> >> > network interface and notify userspace through a map (for certain I= Ps >> >> > only). >> >> > >> >> > In my actual use case, the userspace is supposed to do more complex >> >> > stuff but for testing I simply logged the receival of a message >> >> > through the BPF map on the console. And that is what I expect to >> >> > happen and which does happen as long as CONFIG_TRACING/CONFIG_FTRACE >> >> > are active. If not, I simply never receive any messages on any map. >> >> > >> >> > I've also tried this using an XDP program which sends a message eve= ry >> >> > time it sees a packet. And while the program seemed to be >> >> > working(since it did block certain traffic), I never saw any data in >> >> > the map when those configs were disabled. >> >> > >> >> > Also, I'm giving you two configs(tracing and ftrace) since the other >> >> > one seems to get y-selected automatically if one of them is active. >> >> >> >> Please don't top post, reply inline instead. >> > Sorry for that, GMail does that by default and even hides that it's >> > quoting at all. >> > >> >> >> >> I don't think we have enough to investigate here, even "receive any >> >> messages on any map" is so ambiguous that it's hard to even guess what >> >> you are really trying to do. BPF maps are not sending/receiving >> >> messages. So please provide some pieces of code and what you are doing >> >> to check. CONFIG_TRACING and CONFIG_FTRACE shouldn't have any effect >> >> on functioning of BPF maps, so it's most probably that you are doing >> >> something besides BPF map update/lookup, but you don't provide enough >> >> information to check anything. >> > >> > An aya project I tested where I don't receive any events: >> > https://github.com/aya-rs/book/tree/6b52a6fac5fa3e5a1165f98591b2eaff96= 92048a/examples/myapp-03 >> >> It's using a PERF_EVENT_ARRAY map to send events to userspace. This >> requires CONFIG_BPF_EVENTS to work, which depends on CONFIG_PERF_EVENTS. >> Not sure if this depends on CONFIG_TRACING specifically, but maybe you >> disabled PERF_EVENTS as well? > > PERF_EVENTS is enabled in both my working and my broken config. > But both directly and through others, BPF_EVENTS depends on FTRACE > (which then also selects TRACING). > > So is this some weird dependency chain or expected behavior? > If it's expected, are there alternatives to achieve similar > functionality or do I have to convince my distro to enable tracing > support? Andrii can probably answer for sure, but I *think* this is expected. There's the BPF_MAP_TYPE_RINGBUF which can be used as an alternative; not sure what the dependencies are for that, but from a cursory glance it looks like it doesn't depend on anything in TRACING... -Toke