From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796328190; b=uVIOLyQHbUkZhET8UHsXMza4URiV4UEGqMB7TClakPgbn7E+tnkjg4my+Yte0cnCnA6p zz7flqH+hEwnmUr5+C2p6OIYib1sgbo8nhw0kl3SkmKkH48ri+znUvUFSLT7fj9tk+ZHx 7xn8fI5PVs5Wbigr7OQJQLZdGshJNIW5BM9SyhBlnKEz1FETu1gZdlMVEuVuLLxY8s5cb gpsoal9myLHT3HwPWX1/UU/X4wBjFUxMNH2EE5JDBBz1g1wzb3Cw7RdQ+9K+J2ZQX9HWJ e8Nu5g26F0guhE120qp+hn0j/NB9btkqvWDJSrKeQd5owygeD44H3lzyVP1tyu+v2cA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796328190; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Content-Type:Date:Message-Id:To:Cc:Subject:From:In-Reply-To: References:Content-Transfer-Encoding:MIME-Version; bh=ZhhyIHeDNGhcm0WcBWovNvtSO0EObI/C9y1gadRE4pI=; b=WEWEqKBQGYrEO/plrV5ik9GO/4ll3fgBrGSf+xxODNoZL0fsYtg/3oE3VprES8oV8uNr F4rYX7kliegbeIIyO0mqQ4PKyzOaaFTuqQllir/MvMKL74l+uZQgmZBcUVfOWl2N0+onp RofkaE0q7kQnNeTwF+/hIR7ZQCUjbLIucLLPDHybfZMBUc3blnoguBS+CDXOyzokocX/T LDl/8JkoT/ZLYnkButSl7X23hi7JrPiOnahYN/CfLo+UfdsqB/4T7BgyrVk/YZc9KuU9z 3IZbRngbTKp3VjSttdYGONEbc67k3Ibsqvb/ybrALZqCNOxEPNOeBRSCD1Ymg2imaLw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rA08SshQ; arc=none smtp.remote-ip=209.85.210.170 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E75C3606A32D for ; Thu, 3 Dec 2026 20:03:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E75C3606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rA08SshQ Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8a052aff9e9so182072b3a.0 for ; Thu, 03 Dec 2026 12:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796328189; x=1796932989; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:references:in-reply-to:from :subject:cc:to:message-id:date:content-type:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZhhyIHeDNGhcm0WcBWovNvtSO0EObI/C9y1gadRE4pI=; b=rA08SshQJTVuHIDu8dPbD4gsyuKNtCSd7Zh4aq30N7nBByviJ6wvZQltdWE+T6wGWb eCIE7mHPOewTIXEwUTIAYBODxRdQi6kl5Y2X7cdKwGxo4Y+WrqlldJRMXiIw82HQWLZ0 W53RCSmVHWkzI7J5qjkdtZpbuZRUID7VukOw598HpYDVgMPvUCOtQod+43BIFTJPvkHK DDJPu5BhH8w7bLj3YUeKxAx264WBmH9uXHzgFCN9u6d8OHRe/j0jStxgAK81pl+FZBfw vC53qFtbC03HQ0DxFR9WMj3fVGVRgqt1MLHsLfOLb2okgAEJXCdFYKCugSCvdo82TdkI HeYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796328189; x=1796932989; h=mime-version:content-transfer-encoding:references:in-reply-to:from :subject:cc:to:message-id:date:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZhhyIHeDNGhcm0WcBWovNvtSO0EObI/C9y1gadRE4pI=; b=xmsTtdIO0XIaDF22ZrfPc1DSNxFpZJj1TMQRiM4KpPINIQhKhg7IXz0az/zriuoh3f p1xiwzz2a7m0ABgld0FkpzESKWTSOioCO0yyMHztlcbxsiflmf0qgwCwzGwNizF+SxG4 rA0ASYStw8O3+GtcIGUpFlsq25iUPPjmkWVMdM6etTnblgRSevPqGU+shI43WAW01Hr6 lfuzcQdZhyVCQmZqc9qWI/rnx2viE+28wiUID01ihcL92WrEIUfVNO6Ann8rhuRzsWG8 5I+WG23zhDN1BOef4ko4gf6eR61jg/+gOjeBG47qCj8MJz/NJN7fYssfBGMGd1xLxHKA +prw== X-Forwarded-Encrypted: i=1; AL+hErH74s2GAhSFwMsqsr+jofdsp8FhxDTP/KHD2sKS1orYUObdJVEfuFjFM/xqAbEAitpcVeEnaJctx4dBmauOrdRHeK4=@vger.kernel.org X-Gm-Message-State: APuU4Z9FMiOF7cWm5+K/1j04ELnu4GfxiSRbIM2o7MKLecPHCXlCkn/o 85cdL8Fe7a5Y3IFK36CTpzJqjgYGHMlFGqTjeilSSQxxdRNBXYmaDKY0 X-Gm-Gg: AZFdTZcc+kqX2g1QxjTX5nldoQxuJvG0Q3enDFMjwcnq6sHDlIvD3rsDlxYLLhXG2wC lNErQlpokxEe9c2RQ/UY/Ff7OHMUnazmLg1EgmSlQvn5mEbV+OWoNF3USpaEKRukDNM6gLvMAil ZpFnHClGf57UTWeCUzVm3ufPK1ybzY4//F8GkugNgedTD1lvhOwA7gK3c3DEH0Wf7FFuS2ugdsw wVcAU5gFJ5TWIcAf2mxTS++AH+g1R3FTPkES2h6l2sYc9R2DFfA+IbYDrO+gReJz9+xHNTdhJeJ etkxyZ5N6xh/vBC14dxh2xH5P7sMERpZsfCJp60UOKvHRtcQeXAYf0fJRx+eWM1I5bK6NBG1Z5y 1jvsDWP8s3WK/kIv9eT93SkHICHqnzjwCPVEjQaXJdsSX/kkpMsTAmbXnEYKXq3lpGyd5oJR5TZ gj3nqpfIEHwBB9dZZfPltlFV7mcBPn9xEGdPXztPp+KOlcnelj+lDRswEfuG8GShxRikfqVugvZ ci3iQIguQGwY+Az/Ox4ZN200agkkAfk9kTlYJ+yhrgt+aZ0LxSdtM8kiouQDiGpvqPIqDKIEfFk XWo4csWhHiIfWHIAQNPlT7UgMFYv2c+JHgE3VSZBrzsA/Sw2IDHPoWCK0q/zuJ5UVFABY6qjUeZ S/9Jy5tqGRPHMrTvnyNZshx70g49YJ9/QIYU= X-Received: by 2002:a17:90a:d2cf:b0:3b3:ffb2:6ae3 with SMTP id 98e67ed59e1d1-3b41c902f49mr46556822a91.32.1796328188705; Thu, 03 Dec 2026 12:03:08 -0800 (PST) Received: from localhost ([153.61.198.243]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5de143116sm37000a91.0.2026.12.03.12.03.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2026 12:03:08 -0800 (PST) Content-Type: text/plain; charset=UTF-8 Date: Thu, 03 Dec 2026 20:03:07 +0000 Message-Id: To: "Andrii Nakryiko" Cc: , , "Daniel Borkmann" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "John Fastabend" , "Emil Tsalapatis" , "Ihor Solodrai" , "Steven Rostedt" , "Masami Hiramatsu" , "Mathieu Desnoyers" , "JP Kobryn" , , Subject: Re: [PATCH bpf-next v3 0/4] bpf: Check recursion per task for preemptible programs From: "Alexei Starovoitov" In-Reply-To: References: <20261117-bpf-preempt-v2-r2-v3-0-586376ec3672@sentinelone.com> Content-Transfer-Encoding: 8bit X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Thu Dec 3, 2026 at 1:44 AM UTC, Alexei Starovoitov wrote: > On Wed Dec 2, 2026 at 5:29 PM UTC, Andrii Nakryiko wrote: > > > > slot = (old & 1) ? scratch_slot_get_slow(mask, old, depth) : zero; > > > > If I change "zero" above to actual "0", it causes 3x more verification > > instructions (which for the task switch handler gets me over 1mln), > > because verifier starts tracking zero const value as special branch > > everywhere, with eliding NULL check after map lookup, etc. zero global > > var mitigates that. > > Will check. I see the growth since 7.1. That line alone doesn't give me 3x and 1M together. Processed insns of wprof_task_switch in pull 170, -mcpu=v4, default rodata: clang 20 clang 24 kernel zero 0 zero 0 ---------------- ---- ---- ---- ---- 6.18 164K 166K 157K 159K 7.1 218K 259K 206K 248K 7.3 234K 320K 212K 294K 7.4-rc 159K 245K 137K 219K bpf-next 174K 242K 314K 511K bpf-next + [1] 93K 94K 112K 112K Which kernel, clang and options did you use? Did you change only this line? The elision is there since 6.14 and costs nothing up to 7.1. The growth has two causes. clang 20, each cause removed: kernel zero 0 no spill same ids both -------- ---- ---- -------- -------- ---- 7.1 218K 259K 218K 259K 218K 7.3 234K 320K 255K 292K 234K 7.4-rc 159K 245K 180K 217K 159K bpf-next 174K 242K 180K 243K 181K - Spill, since 7.1. With 0 clang keeps 'prev' in r3 instead of r6. One arm of task_id() spills it around bpf_get_smp_processor_id(). task_infos_emit() walks items[] with a pointer. Stack liveness takes that as a read of the whole frame. So the dead slot keeps the two arms apart. The value 0 plays no role here. - Ids, since 7.2. The NULL check keeps the id, see 06d518a5583f. An elided lookup has no id, so check_ids() fails. So the gain depends on register allocation. With SCRATCH_DEPTH 4 7.3 takes 290K with 'zero' and 243K with 0. Pls keep 'zero' for released kernels. Without the other 'zero' lines 11 wprof_ut_* progs hit 1M on 6.18 to 7.4-rc. bpf-next loads all 46 progs without 'zero'. wprof_task_switch is slow on bpf-next for two more reasons: - task_state() returns a value of one of two maps. Such states stay apart. - task_infos_emit() loads tis->items[i].task with a variable offset. Pass 0 gets a number and fails, so more passes follow. [1] fixes the liveness and the two maps. With it 0 and 'zero' cost the same, 135-185 ms instead of 250-750 ms. [1] https://lore.kernel.org/bpf/20261203195823.4058490-1-alexei.starovoitov@gmail.com/