Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp159478lqn; Thu, 11 Apr 2024 18:14:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWM5S1yYtwThbQe2aHDqsp7u9y+1fksOg5eKOwEnnP0t23jNBqhnS1eBtHsObUSP/DU4IexCGK/rqor5x3DCtguPRqgXlgXCjfunvbsnQ== X-Google-Smtp-Source: AGHT+IHrqHpXvxBiFiZIt/GWQ8MKNRZCACb1jDxJg0Skq1/KGpjmHNXcwKnTzX/a4b4yQGmrZYmj X-Received: by 2002:a05:6808:9a7:b0:3c5:e97b:a32 with SMTP id e7-20020a05680809a700b003c5e97b0a32mr1346769oig.29.1712884494024; Thu, 11 Apr 2024 18:14:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712884494; cv=pass; d=google.com; s=arc-20160816; b=HgGrYt/y/7wsJS6Cmn27bEqdGI0Hzsw0AIFSRGJ3nJA1IgEGnyBb9zopNvtRp70NWI RO9iQMkopHngDwSETKCnnsrFhdoVI2Uhno/g2eAmy+V2ryytuwDENqkVnRqHcghAuGlQ +zpF817Ubv9RoCOyEnQ6M6GyHC9jTZCZpUsRuu68w8ge8rBDXq2d41jUDlfSD6egbpVk 9ddzTWHgHN+i1rMbZ+rHRk3Q+335+bNASX2SrotBJ9a+06+2TK8Y0Se4nnc8Qt856T7C Fsym01YUJxATRdSETPy2R8evvKTdiI4TtfSuhk1AHA6sureGtEp2ncRCBgK/CsA5uktr ZLhg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=X33cbovPiEfTGdBBISnr1h/yfgzXYiMloxhJKyuAgEA=; fh=OzkuaHOU+biX0xyf7/ISWr5er9UttACQ2sx5gaXCrdg=; b=YQnwmYrrqEtctheGnSP1LOtrUfnUg+Ev1J0v2GiRzd/w6GuqsDWJODtRdVSRJhyNJA HQ52FlaI8Kr8ppZXhhGtxDIuWDPVvXXqInfdJVsuVLCBMw5tlr2SlGuYCy/oh2/nTNYX 7e6NJtlzNLbWnWf/7Ip4wCP4ss7imw5oBV/i9Lk1WiMW3k4kPT/g5HxF32yvXCOvntyo p5HiG4XJcGJavVAizOkTszUi7llL2qVqJmwMQ87HVO2QO2q/kVHm7VvF/BoZ+Wt+3x4v 4oXmyEWsFWVEpvchvg8uOCUO12uq5pBiLi0R5q167Rbws1nPARbZXs5BpKde8Ho/8HHz r+WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sBSbOsbh; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-141764-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141764-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y12-20020a05622a120c00b00434e869a8cesi2678123qtx.674.2024.04.11.18.14.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 18:14:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141764-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sBSbOsbh; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-141764-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141764-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A77861C210D7 for ; Fri, 12 Apr 2024 01:14:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E10E6525D; Fri, 12 Apr 2024 01:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="sBSbOsbh" Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5272133D1 for ; Fri, 12 Apr 2024 01:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712884486; cv=none; b=T0BaY9u7g5/xZnvhPJ+V9GlP/AWjn1qx+VE1qoD8ttkdGRWm9p0ZAvtIucCSHaxnsmTd4HTK1Dl5/ECmv7fBG3CWsCetWKCMye3Ay65XbZgqn2JAhA1gs97CnbuYnT9UcB8jW23eJgjTahE5uRGWeCo5QCddOTD2IdE+RTYwQp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712884486; c=relaxed/simple; bh=e6+AYuksM/OkdD9KeQZdNWHeNxAHypqErI5Qn8MY/Wc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=b2Xd5x4frkVh+r4q/XL5Il4R2Z7xzcFgT05zwGQ/RCgyq0/9XPyqit2uX/rImkAS6/Qs2RcGhqHjzIeXJzLpQFEYVLHlFvhzxXm6bhjwYNsx9PcaBfQBKf1v7B+wWeZaeGBf8omIoN4QsSyrTTRVuZ2RHjSUGrgxErqIs7qleFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=sBSbOsbh; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712884482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X33cbovPiEfTGdBBISnr1h/yfgzXYiMloxhJKyuAgEA=; b=sBSbOsbh6k4hKzZ2xR90un+SIdTm4jYFsZv4PE+/Pzkh3SBcCsyJRL+49sY9o+3kYpkQOY rl9eYQisrhV+7huBD/oHaWThlgOAozgySpOYtdZsb1cTr6Uvsovl4VUwlDcaXGc7laDNjQ h8TFOMGFvcwn68Omajr3lJx3B7qR8go= Date: Thu, 11 Apr 2024 18:14:35 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: Incorrect BPF stats accounting for fentry on arm64 Content-Language: en-GB To: Ivan Babrou , bpf Cc: kernel-team , Xu Kuohai , linux-kernel , linux-arm-kernel@lists.infradead.org References: X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 4/11/24 11:09 AM, Ivan Babrou wrote: > Hello, > > We're seeing incorrect data for bpf runtime stats on arm64. Here's an example: > > $ sudo bpftool prog show id 693110 > 693110: tracing name __tcp_retransmit_skb tag e37be2fbe8be4726 gpl > run_time_ns 2493581964213176 run_cnt 1133532 recursion_misses 1 > loaded_at 2024-04-10T22:33:09+0000 uid 62727 > xlated 312B jited 344B memlock 4096B map_ids 8550445,8550441 > btf_id 8726522 > pids prometheus-ebpf(2224907) > > According to bpftool, this program reported 66555800ns of runtime at > one point and then it jumped to 2493581675247416ns just 53s later when > we looked at it again. This is happening only on arm64 nodes in our > fleet on both v6.1.82 and v6.6.25. > > We have two services that are involved: > > * ebpf_exporter attaches bpf programs to the kernel and exports > prometheus metrics and opentelementry traces driven by its probes > * bpf_stats_exporter runs bpftool every 53s to capture bpf runtime metrics > > The problematic fentry is attached to __tcp_retransmit_skb, but an > identical one is also attached to tcp_send_loss_probe, which does not > exhibit the same issue: > > SEC("fentry/__tcp_retransmit_skb") > int BPF_PROG(__tcp_retransmit_skb, struct sock *sk) > { > return handle_sk((struct pt_regs *) ctx, sk, sk_kind_tcp_retransmit_skb); > } > > SEC("fentry/tcp_send_loss_probe") > int BPF_PROG(tcp_send_loss_probe, struct sock *sk) > { > return handle_sk((struct pt_regs *) ctx, sk, sk_kind_tcp_send_loss_probe); > } > > In handle_sk we do a map lookup and an optional ringbuf push. There is > no sleeping (I don't think it's even allowed on v6.1). It's > interesting that it only happens for the retransmit, but not for the > loss probe. > > The issue manifests some time after we restart ebpf_exporter and > reattach the probes. It doesn't happen immediately, as we need to > capture metrics 53s apart to produce a visible spike in metrics. > > There is no corresponding spike in execution count, only in execution time. > > It doesn't happen deterministically. Some ebpf_exporter restarts show > it, some don't. > > It doesn't keep happening after ebpf_exporter restart. It happens once > and that's it. > > Maybe recursion_misses plays a role here? We see none for > tcp_send_loss_probe. We do see some for inet_sk_error_report > tracepoint, but it doesn't spike like __tcp_retransmit_skb does. > > The biggest smoking gun is that it only happens on arm64. I am not an expert for arm64. But you or somebody could check and compare arm64 and x86 jit trampoline codes to see whether anything is suspicious. > > I'm happy to try out patches to figure this one out. >