From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by mail.toke.dk (Postfix) with ESMTPS id C96919F75AE for ; Wed, 22 Mar 2023 20:00:42 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=LXpsDxg2 Received: by mail-pl1-x636.google.com with SMTP id ja10so20163399plb.5 for ; Wed, 22 Mar 2023 12:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679511640; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TPw82u/EjYlcJdkmo1criCAcJTkt8OjlZmqtDmpev+Y=; b=LXpsDxg24mECGDgep6nvpz2DEltVZE0ISwM+WcIPJ1q5Rt+7eJiqvPkEvWORKM+hWO H7M+g/sPLdKmHcczC65vIQgiqlJaFcO9Ns5RD+YVhU2NC3D2MjGrbaHhA24Skc/MlPbo s18xo6tkWmD5vHFzUHp9rlB42XKRsUKJb4W1RruD3v9UeUOw2PcMamLlp0AKaY446uO0 mJ3xqDD2aiE5AvpQU8DznF15fBXA+LKX2wthnnFbSkOJOlcb11MWEMxfLN1bf/4EO3D/ G6EZoNpGMk9jbBlP3DXZ8ifsZQeTgHOdUTwXO9GArz1LJBxJOMNq0S2eflA/nby03cY/ tRow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679511640; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TPw82u/EjYlcJdkmo1criCAcJTkt8OjlZmqtDmpev+Y=; b=nfsWBOvxl4rIqos9gZDfVwgBMbaYtXNr7jgcS5M2dRHVWVx6LNuW48BUTe6NXUA0It zLcJBumU2OP5hSeZJqEn/zDTSdwuLTbYiFWffXYX10ip2cNA/oNk2wocIcd8lDsm5GEK 7H2WITWW5PWeUQwBiFGX2auXuczZMBxaGfp+0udpCoMnh68AzBNtN69vwP7XRq4+X5fP 365WZQVT1D/ojvk2Qo5QdCSbZNGJY8HQYGZwGXDQsJXyZbWtFmsGZ1oOBRQ07U4UJWJv OjJGeeKdJBAfDYyE0VbFiSbXKKBc4prXw8qaSdnUC9561qHKIcEpyA0QagJWaHS3vGPy 8lcw== X-Gm-Message-State: AO0yUKUYpkqIDNMrOJTyv5H8IDl5Z1uwtkNyvrC3GkEXtGbFxF6LmnNf JS1T4xyZHM9k3FahnbdwiQ8schEeE0bpTySRNsOktw== X-Google-Smtp-Source: AK7set+hMDqiJnRnl+PIVoRNKWPVSBo6QIL0bDWogooZje/Gc+I/wzyla2g7mCUY9FBrk2Dbxr75BPu01CHVYNjlXZs= X-Received: by 2002:a17:90a:f28d:b0:23d:424d:400f with SMTP id fs13-20020a17090af28d00b0023d424d400fmr1429526pjb.9.1679511639636; Wed, 22 Mar 2023 12:00:39 -0700 (PDT) MIME-Version: 1.0 References: <167940634187.2718137.10209374282891218398.stgit@firesoul> <167940643669.2718137.4624187727245854475.stgit@firesoul> <080640fc-5835-26f1-2b20-ff079bd59182@redhat.com> In-Reply-To: From: Stanislav Fomichev Date: Wed, 22 Mar 2023 12:00:28 -0700 Message-ID: To: Alexei Starovoitov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HNH6BVYXDEY2ZSCNCXD4CBM36JDIG3TT X-Message-ID-Hash: HNH6BVYXDEY2ZSCNCXD4CBM36JDIG3TT X-MailFrom: sdf@google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jesper Dangaard Brouer , Jesper Dangaard Brouer , bpf , Network Development , Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Alexander Lobakin , Larysa Zaremba , xdp-hints@xdp-project.net, anthony.l.nguyen@intel.com, "Song, Yoong Siang" , "Ong, Boon Leong" , intel-wired-lan , Paolo Abeni , Jesse Brandeburg , Jakub Kicinski , Eric Dumazet , John Fastabend , Jesper Dangaard Brouer , "David S. Miller" X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next V2 3/6] selftests/bpf: xdp_hw_metadata RX hash return code info List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, Mar 22, 2023 at 9:07=E2=80=AFAM Alexei Starovoitov wrote: > > On Wed, Mar 22, 2023 at 9:05=E2=80=AFAM Jesper Dangaard Brouer > wrote: > > > > > > > > On 21/03/2023 19.47, Stanislav Fomichev wrote: > > > On Tue, Mar 21, 2023 at 6:47=E2=80=AFAM Jesper Dangaard Brouer > > > wrote: > > >> > > >> When driver developers add XDP-hints kfuncs for RX hash it is > > >> practical to print the return code in bpf_printk trace pipe log. > > >> > > >> Print hash value as a hex value, both AF_XDP userspace and bpf_prog, > > >> as this makes it easier to spot poor quality hashes. > > >> > > >> Signed-off-by: Jesper Dangaard Brouer > > >> --- > > >> .../testing/selftests/bpf/progs/xdp_hw_metadata.c | 9 ++++++--= - > > >> tools/testing/selftests/bpf/xdp_hw_metadata.c | 5 ++++- > > >> 2 files changed, 10 insertions(+), 4 deletions(-) > > >> > > >> diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/t= ools/testing/selftests/bpf/progs/xdp_hw_metadata.c > > >> index 40c17adbf483..ce07010e4d48 100644 > > >> --- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > > >> +++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c > > >> @@ -77,10 +77,13 @@ int rx(struct xdp_md *ctx) > > >> meta->rx_timestamp =3D 0; /* Used by AF_XDP as not = avail signal */ > > >> } > > >> > > >> - if (!bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash)) > > >> - bpf_printk("populated rx_hash with %u", meta->rx_has= h); > > >> - else > > >> + ret =3D bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash); > > >> + if (ret >=3D 0) { > > >> + bpf_printk("populated rx_hash with 0x%08X", meta->rx= _hash); > > >> + } else { > > >> + bpf_printk("rx_hash not-avail errno:%d", ret); > > >> meta->rx_hash =3D 0; /* Used by AF_XDP as not avail= signal */ > > >> + } > > >> > > >> return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS= ); > > >> } > > >> diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/t= esting/selftests/bpf/xdp_hw_metadata.c > > >> index 400bfe19abfe..f3ec07ccdc95 100644 > > >> --- a/tools/testing/selftests/bpf/xdp_hw_metadata.c > > >> +++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c > > >> @@ -3,6 +3,9 @@ > > >> /* Reference program for verifying XDP metadata on real HW. Functi= onal test > > >> * only, doesn't test the performance. > > >> * > > >> + * BPF-prog bpf_printk info outout can be access via > > >> + * /sys/kernel/debug/tracing/trace_pipe > > > > > > s/outout/output/ > > > > > > > Fixed in V3 > > > > > But let's maybe drop it? If you want to make it more usable, let's > > > have a separate patch to enable tracing and periodically dump it to > > > the console instead (as previously discussed). > > > > Cat'ing /sys/kernel/debug/tracing/trace_pipe work for me regardless of > > setting in > > /sys/kernel/debug/tracing/events/bpf_trace/bpf_trace_printk/enable > > > > We likely need a followup patch that adds a BPF config switch that can > > disable bpf_printk calls, because this adds overhead and thus affects > > the timestamps. > > No. This is by design. > Do not use bpf_printk* in production. But that's not for the production? xdp_hw_metadata is a small tool to verify that the metadata being dumped is correct (during the development). We have a proper (less verbose) selftest in {progs,prog_tests}/xdp_metadata.c (over veth). This xdp_hw_metadata was supposed to be used for running it against the real hardware, so having as much debugging at hand as possible seems helpful? (at least it was helpful to me when playing with mlx4)