From nobody Sun Feb 8 09:12:26 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4B852D9EF0 for ; Fri, 6 Feb 2026 04:19:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770351545; cv=none; b=VT2wIy/7cgz5KWv6TtUJsNYtOF2xDYL8mRGjAADueDCjYwRWGEqEX7jFfNpT11LiAG5iM0Gw2PYrS7UMO/l5fFATjKbO7cLJYN14ySR5Ky6oM/dz7zPfT4lrd9caAFzRGSJQBSfnwmfThxz2eXsUm2tJTbuAmAzxBJZpfMUWyDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770351545; c=relaxed/simple; bh=vvEVKjJCtQo4nmuo3z04CydsrpGhwrX7+I/UCM695oM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sm6KCRH0z1bSnVKNV2Bp6NdscWvsogPbnKB2R2ppj9qB7638tY4G11LwILkr8zAhmE3qErHBwGMKzrsmCANWVkPPTYvSmfeoiyP0rXhXhUSJADbYkgBFCtj9/PHYJYzVTG5WMGHul1FX0BzFw6A+yCShA+qPRr7y+LdQ4e4MhRo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WjqmhnW9; arc=none smtp.client-ip=209.85.214.177 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.b="WjqmhnW9" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2a9296b3926so13193715ad.1 for ; Thu, 05 Feb 2026 20:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770351545; x=1770956345; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=NtxdwbyBhJCjJN9Ud01S5+F/PCx615rL1edEy0Sb+qY=; b=WjqmhnW9rdcg+azO4UVKG/TUOShMyZ3cJbjhX+De0Qtrh9Sq2FiXmIrK7M3artDJJn wYVVz0D3Qlr6Hs3bdlBrAXg/M6Tz2jBBQAYF+w+9DUFkakbD9WdqTE1HkM5Z1/7JaC3q ZPY/UE2uTGmOA+YCxqNKKlgeyTTb3tnFl9eBt8wNN9rXA7fPL/oO2fC2+ziqAYnVjdvh YdwYFZCxKwS1oHKx0AAYVet86ejpXqPO9eM461SVH2d+DlbxA/8gzsD4nBj83KS9fOu+ iheuS24tMmwk3ZZ/sBa8lnlFPIAzdty5pbCRhwS5dFGbWu+9nLWId32Vyu0FLU8rr1Cv 382w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770351545; x=1770956345; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NtxdwbyBhJCjJN9Ud01S5+F/PCx615rL1edEy0Sb+qY=; b=bBQm4Fx2E3ZANROgpKTusgnh+5UpNkqXEZ0ded9KKnXpq8dsymYGClSXA12MEuuCbi hh8rZIfjp9h33T+iq8xG0YytLqfaZVBOSDYf6GMwhf88mMc+0fpu8GtR7Tul4+rsV5sf LZ6lyWt32jOsgq0z+/IhDC4WGgti0MSp98+FB/Iz5gLkkjR5M03NfHJfVb4S/IzvUJwr ygKRGHWi87Kk7xANWtqErJG1VvaNETYaY/JkIkdEjPLexS9X3cPP8/n52lMprowSA8U4 dVBa6hkEF1+r9yYESZNaX7fF8J2FHbDGh4bM/9927pNC1u+JeXhd3e1/7RcZjPX55Elu B3uA== X-Forwarded-Encrypted: i=1; AJvYcCXzWr7nqniXfsUQNSaUUXSPBx/w59xqWnmbodcvlYWhA/3FHpYiRAh4pFKRoMcfvoPGTm7oz8aR+CWt4LE=@vger.kernel.org X-Gm-Message-State: AOJu0Yyh344mbyJlsz8JqBZ5jWvvK8i1ufBWCpFwKNDceLr4feHEF5Br X6jkt1+8pVUivou06wdIDQTnL8d2BDf2cm879JGqSckeLLKbgRv5/2FD X-Gm-Gg: AZuq6aI9/g2gO/uybLLdChrMt7d5viTFyK1VKNo2yITEvFIg5giA2IeUv69YkoA1V2Y GiQYtGV5CiZfN6w80w8/0YgmcITqnJ3v1R6nc3qV+IHyr5lKsNLr0x6aiyT3u4nLNVhxfU2UWi9 ECyvfVvtuZWwo7LP7sbkrQ2b00XWuOFIj7asN0bieW0Tu7lQ/J5VXq0LC0HWr2pYg2cteYMZfsZ VUCC36+PJ6ILykICi+9na8vHbiAQS4IEeo39Lxj+Snf2BIKY561ojXK9DMN/RAh1FiCI7i/Q6IQ v9rV0vcJVlxSHkw3bxiURb5oEvpPC9R4zg5/vpA5J47wG2sN9pfSZ+FKOX6tLZOjPjQhGzxfZ7S WPtw1Z7YAHsDhLzXS7oglgHrOklgdA1Iet6rduvLXxkN9ffizseHzzVIE0hBa6j9v5Rr9GnAAMq aePjChGvGsPcmNyyK99DxWJBae5jSS+D2hhIHOu0vZkqB2QeBVLNFohUXmS3fr7nFdLD5BX0rs2 Q== X-Received: by 2002:a17:902:eccd:b0:295:86a1:5008 with SMTP id d9443c01a7336-2a951709bafmr16003355ad.38.1770351545074; Thu, 05 Feb 2026 20:19:05 -0800 (PST) Received: from mi-HP-ProDesk-680-G6-PCI-Microtower-PC.mioffice.cn ([43.224.245.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a951a6449asm9291985ad.3.2026.02.05.20.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Feb 2026 20:19:04 -0800 (PST) From: zhidao su X-Google-Original-From: zhidao su To: tj@kernel.org, void@manifault.com, arighi@nvidia.com, changwoo@igalia.com Cc: sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org, suzhidao@xiaomi.com Subject: [PATCH] tools/sched_ext: Improve BPF verifier arena detection workaround Date: Fri, 6 Feb 2026 12:18:08 +0800 Message-ID: <20260206041808.170926-1-suzhidao@xiaomi.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace bpf_printk() with volatile access in scx_sdt scheduler's BPF verifier workaround to eliminate console output while maintaining the required LD.IMM instruction generation for arena detection. This addresses the side effect issue of the previous hack while preserving the essential functionality needed by the BPF verifier. Signed-off-by: zhidao su --- tools/sched_ext/scx_sdt.bpf.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/sched_ext/scx_sdt.bpf.c b/tools/sched_ext/scx_sdt.bpf.c index 31b09958e8d5..13d3060c99ff 100644 --- a/tools/sched_ext/scx_sdt.bpf.c +++ b/tools/sched_ext/scx_sdt.bpf.c @@ -64,14 +64,10 @@ DEFINE_SDT_STAT(select_busy_cpu); static __u64 zero =3D 0; =20 /* - * XXX Hack to get the verifier to find the arena for sdt_exit_task. - * As of 6.12-rc5, The verifier associates arenas with programs by - * checking LD.IMM instruction operands for an arena and populating - * the program state with the first instance it finds. This requires - * accessing our global arena variable, but scx methods do not necessarily - * do so while still using pointers from that arena. Insert a bpf_printk - * statement that triggers at most once to generate an LD.IMM instruction - * to access the arena and help the verifier. + * Workaround to help BPF verifier track arena usage. + * The verifier needs to see an explicit reference to the arena variable + * to properly track arena memory usage. This generates the required + * LD.IMM instruction without producing unnecessary output. */ static volatile bool scx_arena_verify_once; =20 @@ -80,7 +76,11 @@ __hidden void scx_arena_subprog_init(void) if (scx_arena_verify_once) return; =20 - bpf_printk("%s: arena pointer %p", __func__, &arena); + /* + * Use volatile access to generate LD.IMM instruction without + * producing console output like bpf_printk does. + */ + (void)*(volatile void **)&arena; scx_arena_verify_once =3D true; } =20 --=20 2.43.0