From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (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 8EE7A42FCB5 for ; Tue, 11 Aug 2026 14:14:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786457645; cv=none; b=AbW8ZJSYK+aMcSaQJWrTS4snPf9jjE07sB41VgUS78BlD9up+Obo0Y1s2NYe25miQ+oROXVzFHYvkM43Svwq8WF5x1JA/f/BMac5gxlZKKAsr7JBy+DrzZJ1AXOZWNdXsCo2qRJEr7QpUvCWZ2pSfRHPoMPve6173jyOA5I1PRw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786457645; c=relaxed/simple; bh=JotZ2xau8mAN2tR4U7+23HdeiUKQKBxFHUJQFHYwxwQ=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=bpn9DLprFzDOoT1hPocEkSKYPV3Q1OCjcIBrjV4AfgQWaswzsGlxp+5RhPyfWXvOih5Rws5E6e18oMNAdpvaAn9lg/FoHRE/RFYo5+pnimVhkJighKBC/cPh7pSE8hx/KSiftKZSx3hC0ZFgrGkUmeRdpz0DPfBKhFkvEZG7G4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--michalblk.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ExDS8DFf; arc=none smtp.client-ip=209.85.218.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--michalblk.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ExDS8DFf" Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-c15c6a68406so212077866b.3 for ; Tue, 11 Aug 2026 07:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786457642; x=1787062442; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=R1OJbwEkT9wgwkVybNm7HK0Xy2ztcCHJVSG06MAs0zA=; b=ExDS8DFfb5sj0mN+ysVB4PEx2EbHXY0M5U6E/g2mx1FF1NyjU7CAdyktD6RNQUNHsi a9qq7GXTaJiujRLvlPRC+/JJb1V8KNUCr0Od6JtkFvZVUBuBjRI+N34NPH9jlC2no+Ej Vb6LSDscCf9xTKZZ2DTKOCwJtVSQCJB3WJUDFb0dn0JIfVFMLVoraggvhG2rlOmzz02D 6J2LI02laHBjeuKX60RxsG4tfNWqYPmrmziXJDPcyosV858YatNrvRWT13BttTdYRhDS S9q2LTrGi78jD2qUSyLkjEmaqYuFe55JJ+B5ILUCO6mJqCILBl9Ifw9VIdV7aKWvCuug SBhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786457642; x=1787062442; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=R1OJbwEkT9wgwkVybNm7HK0Xy2ztcCHJVSG06MAs0zA=; b=LwNjDZJX0YRPloTYxMI7FGv0qKRX8OLGu1Mddc6JGz3MoFDPMeja7VlLWKq8nlpS7a WPtSqS6iTZ+nm5IUDl2PdGSNDJd47xsfmLHgLFaYg0FIRYEgPK3gDAMWZXQE75f33p36 MvS8boZgUjBfegfwymdSfy6iPA18GGrLrjDHGItvYfGBXnjv8+mgjvMbfG3ump+VTKwd bX2cXbEGwUBZSDxjzINdctwwHXw4R8FzcgCR2QL5/3VGvV4aDg1CgSLLTIyaZN5bXThc /p1Zi7Ngp6YPtygBpTtsMFnf1FsR1mUtBpWSsU/HMoItohzBy7M/rjLG8Nk9AOFiWBkx ULjA== X-Forwarded-Encrypted: i=1; AHgh+Rq03QAO9Fx1CtDtHyD1VUkncwH+GGKsZqx+QM9jIGGq3r8Fn2lXY63iSWSxDA+uKVD3wruzttPmYMONZzE=@vger.kernel.org X-Gm-Message-State: AOJu0YxG2K0u3Gpu5E4OVFmauHTEk7hLDA1KqhxLa9Cjx/7GElLqeqRj I+XN2wM1Fx+d71VkwO3dgC74XjSWDprGWdAf4s/diLU/p4xmjrn3LkZQE87bv1kSVWt8q2N3jUp PMrJtNAGYfLHL2KxG4Q== X-Received: from ejed9.prod.google.com ([2002:a17:906:1749:b0:c12:718d:1964]) (user=michalblk job=prod-delivery.src-stubby-dispatcher) by 2002:a17:906:f59b:b0:c20:295d:6574 with SMTP id a640c23a62f3a-c20e605337bmr193175366b.12.1786457641579; Tue, 11 Aug 2026 07:14:01 -0700 (PDT) Date: Tue, 11 Aug 2026 14:13:58 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.679.g6767b8d81c-goog Message-ID: <20260811141358.2767765-1-michalblk@google.com> Subject: [PATCH] selftests/sched_ext: Fix flaky ddsp failure tests on busy systems From: Michal Blaszczyk To: Tejun Heo , David Vernet , Andrea Righi , Changwoo Min Cc: Michal Blaszczyk , sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" The ddsp_vtimelocal_fail and ddsp_bogus_dsq_fail tests skip calling scx_bpf_dsq_insert_vtime() if scx_bpf_pick_idle_cpu() fails to find an idle CPU (returns -1). On loaded systems, this results in the tests skipping the very assertions they are meant to verify. Eliminate this flakiness by falling back to prev_cpu if no idle CPU is found, ensuring the illegal dispatch operations are unconditionally attempted and tested. Fixes: a5db7817af78 ("sched_ext: Add selftests") Signed-off-by: Michal Blaszczyk --- .../sched_ext/ddsp_bogus_dsq_fail.bpf.c | 20 +++++++++---------- .../sched_ext/ddsp_vtimelocal_fail.bpf.c | 13 ++++++------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c b/tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c index 6f4c3f5a1c5d..7ef9de7b27eb 100644 --- a/tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c +++ b/tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.bpf.c @@ -14,18 +14,16 @@ s32 BPF_STRUCT_OPS(ddsp_bogus_dsq_fail_select_cpu, struct task_struct *p, s32 prev_cpu, u64 wake_flags) { s32 cpu = scx_bpf_pick_idle_cpu(p->cpus_ptr, 0); + if (cpu < 0) + cpu = prev_cpu; - if (cpu >= 0) { - /* - * If we dispatch to a bogus DSQ that will fall back to the - * builtin global DSQ, we fail gracefully. - */ - scx_bpf_dsq_insert_vtime(p, 0xcafef00d, SCX_SLICE_DFL, - p->scx.dsq_vtime, 0); - return cpu; - } - - return prev_cpu; + /* + * If we dispatch to a bogus DSQ that will fall back to the + * builtin global DSQ, we fail gracefully. + */ + scx_bpf_dsq_insert_vtime(p, 0xcafef00d, SCX_SLICE_DFL, + p->scx.dsq_vtime, 0); + return cpu; } void BPF_STRUCT_OPS(ddsp_bogus_dsq_fail_exit, struct scx_exit_info *ei) diff --git a/tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c b/tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c index e4a55027778f..82dca4cdc0a6 100644 --- a/tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c +++ b/tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.bpf.c @@ -14,15 +14,14 @@ s32 BPF_STRUCT_OPS(ddsp_vtimelocal_fail_select_cpu, struct task_struct *p, s32 prev_cpu, u64 wake_flags) { s32 cpu = scx_bpf_pick_idle_cpu(p->cpus_ptr, 0); + if (cpu < 0) + cpu = prev_cpu; - if (cpu >= 0) { - /* Shouldn't be allowed to vtime dispatch to a builtin DSQ. */ - scx_bpf_dsq_insert_vtime(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, - p->scx.dsq_vtime, 0); - return cpu; - } + /* Shouldn't be allowed to vtime dispatch to a builtin DSQ. */ + scx_bpf_dsq_insert_vtime(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, + p->scx.dsq_vtime, 0); - return prev_cpu; + return cpu; } void BPF_STRUCT_OPS(ddsp_vtimelocal_fail_exit, struct scx_exit_info *ei) -- 2.55.0.679.g6767b8d81c-goog