From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796328190; b=sdy45ewFTErRO0z8XFEugzn4AX9hUC2uAh4xp1B9Vu51lfc4Cl22VRqZfGGrTWFUAnwv FDbmaixvP13I0O6AXLtJ10TimyoDKxv2cCLDR13wlA7Kh8yn3Ldo2L/7Dfw0GMadWANd8 rXHSmX955iyepCiEEJZYviOa4mqnBXmm5EACiXW/8wyY0tn/YF/UJAZ2G8kH9ZPLWe0+u dP0WYhYO0+uddSFJsOzkeeSRDWfgcuvZXIFt0PrQb+nYifcucZSK4xismeVrUMNLtyu2f ZlwR2RVlLp06IDzpoDJZ8M20LIAiEvJxxWHsbygXBtouir/oTBLxXOb2qR+Y28eJS3g== 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=sajGvyoVgpaDqX5d5bcnH62odAh2KPoGDbnvtAtgV+n7xDWTdoYputePvLgT5d/DgIeK b5b9yLhH+2v8rdxTsidOdOIQIuFqazAcDvkUYnqQKowY+EUtCZMA3yjQBhDAcA9U313Xg MorQcEpFuZ5hkdwmk7sdQO4pi/n/iSBr0UjV+xpz9l3L35T14pgRmd+esIaiaHHovcSEb Te2nJA5o4C/LVrhYvjRl7RljzRJLJxwEy3piVMwpkVLBnk/wWOMz0QBBeBvw6MJl4k3u/ nlo9sqwhpgJNlJGHmco2vvwOYESMbo4x5WpwV2wXa2kAvYf6z9raN6ZQpDIRnNmA3VQ== 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.182 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 CDB6C606A322 for ; Thu, 3 Dec 2026 20:03:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CDB6C606A322 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-f182.google.com with SMTP id 41be03b00d2f7-ce104b9bc90so162989a12.2 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=ljGF9GqLgk21QguE7Ah3m9QTw0gHnlVyGIv1D8OmmpW7TDp6hb0bzCD9GkehKADWH4 fT4yqnrxbcSIWlODLlgiCy8vYtsLty+r/NfyuexsRTl9kS20JHUkBe5C1Ldp3FK0/0up SwHEZzqn3vAsERhuP0iojtxXUIaIpLEWN/M731MJIZNdd/cTgE4RWIp2NEuGFWbL8B2T lvhGmHdxAfzi3BpDXQj4L5FlQ9oVgjscFeqr0scgaxlJWfVij9LnslwvnBPkN8h8Drry bykClaHxfVxmGNDlY4F8J9SlUIS7s8kwC3BV2iEpsboNIi8Ray+9pRw/+h1qpxKjKHgt nmOA== X-Forwarded-Encrypted: i=1; AL+hErHrcq2N4UGKXuyWJnp8HOA0UkO8KN34GKCiohGkjxRqOpvmXc/FKDz1iMV/CEar+asZ+j4=@vger.kernel.org X-Gm-Message-State: APuU4Z/J9ujPZpJeDNxuqPdwGDgPaAVENygW8o1I+WeZy2dZFLLHay56 xknvrBKjnlgt0nLP94LuHsmTTdaN7YY8GmKDRohvqiHOQQQyXGc4UOpR0c9MbQ== X-Gm-Gg: AZFdTZcbtPRIfcqL+iP/qPmhH+kmw754xEiTvAM8JRN1F22JiXssvB8MY+DZgBVA3kb askucKN2f+M+CYk6l25jVC8A+ofYXAJXGy7E4d2w+TarMPM+17e/kDRfi4YAuHm0ChrT3tyrHfj EnuFUDZTlGtxEk5wUuW2Vmwiu9kkdZWJRNmu+lvdIBr53FyYdYvGgdn5SXdB0QmyAoD7g45vUrt asS4e25BBFCCHRb/sKkFHWfmByJCO8tBYiWzWqIjoV6MLc+nFLc9xEb6Y2ZUADMkR5Xfhbm+YVG GNUl5lN0DTtwdL4fon8WYoQqNbgSGiQbd1eHMsm0RI3RVIEo/mOpagDEcsdQrAXsgEZk+dZLCZV ZIQopsQEI6arwRalL7z3BQEwZzXQA55BK2iwa+7IAKFJm+Vzl5D07HeLeOaoibvg4x623exgQGG FEWCgP5EhT4miLLhud7WxxQ/k87RXK67auPS0ZnOD6dVBXAb7DHdQHmzh85xOnf7lbqGykwj4Z1 1Mkqr3ZcJ6DSJTJjRBJbfmApqCMPYcD6iKakV5E8fPvo7HlYgDjgARRviVV5yiC1HgHT7MaxiE8 jUznG6RQHQjNGCQZ90ogwGUOSXJVWPwZdkswb8ahODnCjq4fGlFYCUihnGhrqPNGlkkaVWW24TV Xwdolhfh+w6cL74mc8fx59QLVrwwuXsvwrB8= 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: bpf@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/