From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796328190; b=3otKHgMspeHIX6dMz196Fuq5pdXD1HivcI/D8oNTcj/hP23IsR2nj+W2IfDdimhVUR2Z QVH5GyRnCfa85eWUl1SN9rqYdw1bALTfW1eZfMr+N0jdkaOFobGZbjV5/NtfRucBtpYMM tsW9/pWTfKpt81Bn0FV9mwwqcCFkij+lUcXfgnYmcjFTOE52UNcoRtnMNrBTO3NVyJkX5 2BtA35qBHVO6h1gu8j3D4Em20rr/qG+Gc7fs6pi8CXhqFry8Dtl08NLzvI8vuQwtwbxnn LB4aEDKeIJY9SL4Sb9xhl13fg0PqO0G4G+aYXsbY38+rJUC/zyRyi1AokYYHYWfYsdg== 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=X8GJu6/jNbomxfknGL8hHbFF4P7wPu59s+4bNNN90byPsqRNPRYVEmzvHT+cI31V1Kh1 EuYbkiEt0IQXn3/z7OkXK5CqXZMl+EDjl6QyDs+uYevYO4LiFBQh71B923DvJnwiUcZIr yfm6CDgkmdqr/M2uMEQn3RbyXPRwQUh8h0HvvAf7TeLzhi5nBxYCMjkMl9XUt/QiETT5b eWeekQd/DWisIbmDRkYiitlJoj52QE4oXlhhI9ev/sM/FU8KzE4XGG/gXAttHiMaxuW68 GpKonAp3iAQtAEXCY32gLxvpmlbwuc12Y6/pmeO131zSb/3FN9peCoB6uXxkWmnQNKw== 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.215.176 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 CFF9B606A32C for ; Thu, 3 Dec 2026 20:03:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CFF9B606A32C 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-pg1-f176.google.com with SMTP id 41be03b00d2f7-cc751eddf25so165379a12.3 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=hBrT/AZYkNTdfkViIHu1LRdI6JHfixUr6ol1wfIjm9KatJP4tPM4JLfck2mwAMN5rS PEn5/oZAbl2LfCpfIClM/1hgp04b/YbxvMo6zMSYDHQeI4vlFDBBBZrLF9em/hluWd4/ X74If8HGdgOCfNEApusnr1Pd58gjix9D3/Cgg9v8UQtrsLoQ6JpXETmpBHmmjhpY82Bs QhEP3QkuLsaBS2oVrv2q8VfA3zGyEqZ359PDs0TQQlPoWPem1Vyn6TaakqJItm9ZKY15 xh1UJBHeOcIPHmllafDaymZq/uxkdgrame7hQwsygwVgAhpOH+jdrYPyZfz/yDQ4Au2H sMZg== X-Forwarded-Encrypted: i=1; AL+hErGNlLXkTlz/aTo1yztCE8T1+tC68iN21wEIGb006m/PKgBlRSrrzPLtVYBFQlk91FpnP9aqqO49SEIPZC8=@vger.kernel.org X-Gm-Message-State: APuU4Z/RHgmoRnXlegJ8giDGZlMJlnseolGeRH9T4QDZNjIHgCdw9Z03 TFpbp/AeaJSLAKmRt4EkKnBPcqL+0cyMLcLTJzqPQBnM1GM7+YWhPxmy X-Gm-Gg: AZFdTZcbtHClHB2c5B8vtFmg39s+l6qubQ2THPAJIJdRhGJm2WhXuboj2lMuqhKxuTL k/xNVeumwN4KgeUkE6vSlLx3L/pswFxQm7YllaWGRKloQg/Pa5YLVeLKR4TljIwPm8tY89TWX+e nBb5hrrMQMaLK9I84oLXeY/BlAS09uX+Y74svGnGnuYlHaZ+F5Jr2WvT9WIn5obeKpHvsDrXQgI yna/1WPh/6se/Mv5qRsGjCgJfC1CBJeybPyQR9G6M/Dve4rqM1CN0lUh65HcxDAY8Kd6zKfrsCn tKupjNWbZVJTDkfly+K579p8t7foFQh6fr6Hntrg/2Gu1CABi3zOfO0Pf9YO45Db+mIwH+WBGxI kV64YcpEje2Cr/mVNdMCwZaUVZtjZcadF0eOo3Ac8xWOg9WDZf+11i+UH2NkWDgyw7HthtqAd8L wVwa9zLyvNNryqOKSlKRfdMycC5RRBL8ff+dRjbWNX3ex/CHmcwBSMKR2J5tXP7v6wW1ERJNF2R NZ19eDgkX2Mwoh+4T3DVxrhY7vh/uSHRimeB2crbAWwvE3WscBtj3lE03iomyFMgpzXnk3RrCCS AhCxelI+bDB/9E79hK+we8sc65hxVgmDbnFXdexkWVzGUR9Q1NiqSh7LlgXu63KPblpL4MpitkS wvbxxBW2YcVFIErwuQbIbF9MaNxhMY8i+wS8= 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-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/