From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A3803D79F9 for ; Fri, 10 Jul 2026 13:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783690761; cv=none; b=GVDsBJxZtTTRKQCqAfWtskWhkdEYxY2rL4t4L/DmAkwvZe82D3VT28lVzHTErxVNTcRe4VwUx2wRi1J9OL2SexsSp6j6XVd/OU1RCjeprxHMahZDALrxpCqhWJrSz8nPn9mbnqbxnP1QlP+ej8SQ2tWO+ZmyL0lScnbGz3a4J1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783690761; c=relaxed/simple; bh=p1eN2YnJU0T3NtzLDy05+4j8o9XkFS+BWazxY9VhVNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GHuSSw03LLmbU0/a4wz78AmSWLLrgVvA5O0R9f1j2wIBMuYR4ci/j0d4fvWbByjYduQnl83CdDCrDa25YdS8RdqT3ekrtHW/4JgH+OqRDu05FRKJSyEuUlgQ+ZxMAiHrSR6SGT0GvwmK822IMxuWSRsWTSBHzFuPkhA51QHRLFE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cMfgE8z5; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cMfgE8z5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783690756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QBhUuuWEY5XUhiDDiEMlkCH4SNpqEr/S3VTq8D5/oAo=; b=cMfgE8z5dJUyBeKXd8dZ+NirtPwdn2aQi43PBxaSQtwIvthMSJQRhE7ADgjrjVdPGQD5yn /2f38SSSSgyrLJxd9lQlckFVxh0tnyA1S3nleOSSYicO8R0Kk9hOw9H+KaZ8qzhyLJIuj2 rwjjgbb4G8rXXVskWiYkJ0nnt0EnaV8= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-CMIhjx5lMhirr3mMFmSCPQ-1; Fri, 10 Jul 2026 09:39:15 -0400 X-MC-Unique: CMIhjx5lMhirr3mMFmSCPQ-1 X-Mimecast-MFC-AGG-ID: CMIhjx5lMhirr3mMFmSCPQ_1783690754 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 29F16180025F; Fri, 10 Jul 2026 13:39:14 +0000 (UTC) Received: from wcosta-defaultstring.rmtbr.csb (unknown [10.22.88.130]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 18802195608E; Fri, 10 Jul 2026 13:39:11 +0000 (UTC) From: Wander Lairson Costa To: williams@redhat.com, jkacur@redhat.com, linux-rt-users@vger.kernel.org Cc: juri.lelli@redhat.com, luffyluo@tencent.com, davidlt@rivosinc.com, Wander Lairson Costa Subject: [PATCH 09/11] tests: start stalld before starvation_gen in all tests Date: Fri, 10 Jul 2026 10:38:08 -0300 Message-ID: <20260710133810.72398-10-wander@redhat.com> In-Reply-To: <20260710133810.72398-1-wander@redhat.com> References: <20260710133810.72398-1-wander@redhat.com> Precedence: bulk X-Mailing-List: linux-rt-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 The test sections previously started starvation_gen before stalld, based on a belief that stalld's idle detection could miss tasks appearing after it began scanning. Source analysis showed this concern was unfounded -- stalld re-scans continuously and will detect starvation regardless of when the starved tasks appear. Meanwhile, the old ordering introduced intermittent failures: starvation_gen could finish and exit before stalld had a chance to scan, causing timeouts in assert_starvation_detected and wait_for_boost_detected. Reorder all 15 test sections across test_fifo_boosting.sh, test_fifo_priority_starvation.sh, test_starvation_detection.sh, test_starvation_threshold.sh, and test_log_only.sh so that start_stalld_with_log runs before start_starvation_gen. Remove stale comments about the old ordering rationale ("Create starvation FIRST", "avoid idle detection race"). Signed-off-by: Wander Lairson Costa --- tests/functional/test_fifo_boosting.sh | 22 +++++------ .../test_fifo_priority_starvation.sh | 38 ++++++++----------- tests/functional/test_log_only.sh | 10 ++--- tests/functional/test_starvation_detection.sh | 18 ++++----- tests/functional/test_starvation_threshold.sh | 23 +++++------ 5 files changed, 45 insertions(+), 66 deletions(-) diff --git a/tests/functional/test_fifo_boosting.sh b/tests/functional/test_fifo_boosting.sh index e489950..4d2841d 100755 --- a/tests/functional/test_fifo_boosting.sh +++ b/tests/functional/test_fifo_boosting.sh @@ -22,16 +22,14 @@ init_functional_test "SCHED_FIFO Boosting Mechanism" "test_fifo_boost" test_section "Test 1: FIFO Boost with -F Flag" threshold=5 -# Create starvation FIRST (before stalld starts) starvation_duration=$((threshold + 5)) -log "Creating starvation on CPU ${TEST_CPU} for ${starvation_duration}s" -start_starvation_gen -c ${TEST_CPU} -p 80 -n 2 -d ${starvation_duration} log "Starting stalld with -F flag to force SCHED_FIFO boosting" -# Note: -F requires non-single-threaded mode (aggressive mode) -# Use -g 1 for 1-second granularity to ensure timely detection start_stalld_with_log "${STALLD_LOG}" -f -v -g 1 -N -F -A -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} +log "Creating starvation on CPU ${TEST_CPU} for ${starvation_duration}s" +start_starvation_gen -c ${TEST_CPU} -p 80 -n 2 -d ${starvation_duration} + # Wait for boosting log "Waiting for boost detection..." assert_boost_detected "${STALLD_LOG}" "Boosting occurred with -F flag" @@ -48,14 +46,13 @@ test_section "Test 2: FIFO Priority Verification" threshold=5 rm -f "${STALLD_LOG}" -# Create starvation FIRST +log "Starting stalld with -F flag (FIFO boosting)" +start_stalld_with_log "${STALLD_LOG}" -f -v -g 1 -N -F -A -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} + log "Creating starvation on CPU ${TEST_CPU}" start_starvation_gen -c ${TEST_CPU} -p 80 -n 1 -d 10 tracked_pid=$(find_starved_child "${STARVE_PID}") -log "Starting stalld with -F flag (FIFO boosting)" -start_stalld_with_log "${STALLD_LOG}" -f -v -g 1 -N -F -A -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} - # Wait for boosting log "Waiting for boost detection..." wait_for_boost_detected "${STALLD_LOG}" @@ -101,13 +98,12 @@ log " Expected cycles: ~5" rm -f "${STALLD_LOG}" -# Create starvation FIRST -log "Creating starvation on CPU ${TEST_CPU}" -start_starvation_gen -c ${TEST_CPU} -p 80 -n 1 -d 12 - start_stalld_with_log "${STALLD_LOG}" -f -v -g 1 -N -F -A -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} \ -d ${boost_duration} -p ${boost_period} -r ${boost_runtime} +log "Creating starvation on CPU ${TEST_CPU}" +start_starvation_gen -c ${TEST_CPU} -p 80 -n 1 -d 12 + # Wait for boosting to start log "Waiting for boost detection..." wait_for_boost_detected "${STALLD_LOG}" diff --git a/tests/functional/test_fifo_priority_starvation.sh b/tests/functional/test_fifo_priority_starvation.sh index 028b825..86c6517 100755 --- a/tests/functional/test_fifo_priority_starvation.sh +++ b/tests/functional/test_fifo_priority_starvation.sh @@ -27,17 +27,16 @@ test_section "Test 1: Basic FIFO-on-FIFO Starvation Detection" log "Testing: FIFO:10 blocker starves FIFO:5 blockee" threshold=5 - -# Create starvation BEFORE starting stalld to avoid idle detection race starvation_duration=$((threshold + 5)) + +log "Starting stalld with ${threshold}s threshold (log-only mode)" +start_stalld_with_log "${STALLD_LOG}" -f -v -l -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} + log "Creating FIFO-on-FIFO starvation on CPU ${TEST_CPU} for ${starvation_duration}s" log " Blocker: SCHED_FIFO priority 10" log " Blockee: SCHED_FIFO priority 5" start_starvation_gen -c ${TEST_CPU} -p 10 -b 5 -n 2 -d ${starvation_duration} -log "Starting stalld with ${threshold}s threshold (log-only mode)" -start_stalld_with_log "${STALLD_LOG}" -f -v -l -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} - # Wait for starvation detection log "Waiting for starvation detection..." assert_starvation_detected "${STALLD_LOG}" "FIFO-on-FIFO starvation detected" @@ -57,6 +56,9 @@ rm -f "${STALLD_LOG}" threshold=5 boost_duration=3 +log "Starting stalld with boosting enabled" +start_stalld_with_log "${STALLD_LOG}" -f -v -N -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} -d ${boost_duration} + log "Creating FIFO-on-FIFO starvation on CPU ${TEST_CPU}" start_starvation_gen -c ${TEST_CPU} -p 10 -b 5 -n 1 -d 12 @@ -69,9 +71,6 @@ if [ -n "${blockee_pid}" ]; then log "Blockee task PID ${blockee_pid}, context switches before boost: ${ctxt_before}" fi -log "Starting stalld with boosting enabled" -start_stalld_with_log "${STALLD_LOG}" -f -v -N -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} -d ${boost_duration} - # Wait for detection and boosting wait_for_boost_detected "${STALLD_LOG}" sleep ${boost_duration} @@ -103,16 +102,15 @@ log "Verify duration accumulates correctly (task merging)" rm -f "${STALLD_LOG}" threshold=3 - -# Create long starvation to trigger multiple detection cycles starvation_duration=12 -log "Creating long FIFO-on-FIFO starvation for ${starvation_duration}s" -start_starvation_gen -c ${TEST_CPU} -p 10 -b 5 -n 2 -d ${starvation_duration} log "Starting stalld with ${threshold}s threshold (log-only mode)" log "Will monitor for multiple detection cycles to verify timestamp preservation" start_stalld_with_log "${STALLD_LOG}" -f -v -l -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} +log "Creating long FIFO-on-FIFO starvation for ${starvation_duration}s" +start_starvation_gen -c ${TEST_CPU} -p 10 -b 5 -n 2 -d ${starvation_duration} + # Wait for multiple detection cycles log "Waiting for first detection cycle..." wait_for_starvation_detected "${STALLD_LOG}" @@ -147,15 +145,14 @@ log "Testing edge case with only 1 priority difference" rm -f "${STALLD_LOG}" threshold=5 -# Test with very close priorities +log "Starting stalld with ${threshold}s threshold" +start_stalld_with_log "${STALLD_LOG}" -f -v -l -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} + log "Creating FIFO-on-FIFO starvation with close priorities" log " Blocker: SCHED_FIFO priority 6" log " Blockee: SCHED_FIFO priority 5" start_starvation_gen -c ${TEST_CPU} -p 6 -b 5 -n 1 -d $((threshold + 5)) -log "Starting stalld with ${threshold}s threshold" -start_stalld_with_log "${STALLD_LOG}" -f -v -l -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} - # Wait for starvation detection log "Waiting for starvation detection..." if wait_for_starvation_detected "${STALLD_LOG}"; then @@ -180,16 +177,13 @@ log "Ensure stalld boosts the blockee (FIFO:5), not the blocker (FIFO:10)" rm -f "${STALLD_LOG}" threshold=5 +log "Starting stalld with boosting enabled" +start_stalld_with_log "${STALLD_LOG}" -f -v -N -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} + log "Creating FIFO-on-FIFO starvation" start_starvation_gen -c ${TEST_CPU} -p 10 -b 5 -n 2 -d 12 -v - -# Extract blocker and blockee PIDs from starvation_gen output -# The output shows "Blocker TID: " and "Blockee N TID: " log "Starvation generator PID: ${STARVE_PID}" -log "Starting stalld with boosting enabled" -start_stalld_with_log "${STALLD_LOG}" -f -v -N -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} - # Wait for boosting log "Waiting for boost detection..." if wait_for_boost_detected "${STALLD_LOG}"; then diff --git a/tests/functional/test_log_only.sh b/tests/functional/test_log_only.sh index b38db70..cba7596 100755 --- a/tests/functional/test_log_only.sh +++ b/tests/functional/test_log_only.sh @@ -44,16 +44,12 @@ echo "Stalld will run on CPU ${STALLD_CPU}" LOG_FILE="/tmp/stalld_test_log_only_$$.log" CLEANUP_FILES+=("${LOG_FILE}") -echo "Creating starvation on CPU ${TEST_CPU} (will run for 10 seconds)" - -# Start starvation generator BEFORE stalld to ensure CPU is busy from the start -start_starvation_gen -c ${TEST_CPU} -p 10 -n 1 -d 10 -STARVGEN_PID=${STARVE_PID} - -# Start stalld in log-only mode with verbose output to capture logs echo "Starting stalld in log-only mode with 5 second threshold" start_stalld_with_log "${LOG_FILE}" -f -v -l -t 5 -c ${TEST_CPU} -a ${STALLD_CPU} +echo "Creating starvation on CPU ${TEST_CPU} (will run for 10 seconds)" +start_starvation_gen -c ${TEST_CPU} -p 10 -n 1 -d 10 +STARVGEN_PID=${STARVE_PID} echo "Starvation generator started (PID ${STARVGEN_PID})" echo "Waiting for starvation detection..." diff --git a/tests/functional/test_starvation_detection.sh b/tests/functional/test_starvation_detection.sh index 52031c5..9702f99 100755 --- a/tests/functional/test_starvation_detection.sh +++ b/tests/functional/test_starvation_detection.sh @@ -24,15 +24,14 @@ NUM_CPUS=$(get_num_cpus) test_section "Test 1: Basic Starvation Detection" threshold=5 - -# Create starvation BEFORE starting stalld to avoid idle detection race starvation_duration=$((threshold + 5)) -log "Creating starvation on CPU ${TEST_CPU} for ${starvation_duration}s" -start_starvation_gen -c ${TEST_CPU} -p 80 -n 2 -d ${starvation_duration} log "Starting stalld with ${threshold}s threshold (log-only mode)" start_stalld_with_log "${STALLD_LOG}" -f -v -N -l -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} +log "Creating starvation on CPU ${TEST_CPU} for ${starvation_duration}s" +start_starvation_gen -c ${TEST_CPU} -p 80 -n 2 -d ${starvation_duration} + # Wait for starvation detection log "Waiting for starvation detection..." assert_starvation_detected "${STALLD_LOG}" "Starvation detected" @@ -50,13 +49,12 @@ test_section "Test 2: Context Switch Count Tracking" rm -f "${STALLD_LOG}" threshold=5 -# Create starvation -log "Creating starvation on CPU ${TEST_CPU}" -start_starvation_gen -c ${TEST_CPU} -p 80 -n 1 -d 10 - log "Starting stalld with ${threshold}s threshold (log-only mode)" start_stalld_with_log "${STALLD_LOG}" -f -v -N -l -t $threshold -c ${TEST_CPU} -a ${STALLD_CPU} +log "Creating starvation on CPU ${TEST_CPU}" +start_starvation_gen -c ${TEST_CPU} -p 80 -n 1 -d 10 + # Wait for starvation detection log "Waiting for starvation detection..." wait_for_starvation_detected "${STALLD_LOG}" @@ -116,6 +114,8 @@ else rm -f "${STALLD_LOG}" threshold=5 + start_stalld_with_log "${STALLD_LOG}" -f -v -N -l -t $threshold -c ${CPU0},${CPU1} -a ${STALLD_CPU_MULTI} + # Create starvation on CPU0 log "Creating starvation on CPU ${CPU0}" start_starvation_gen -c ${CPU0} -p 80 -n 1 -d 12 @@ -126,8 +126,6 @@ else start_starvation_gen -c ${CPU1} -p 80 -n 1 -d 12 STARVE_PID1=${STARVE_PID} - start_stalld_with_log "${STALLD_LOG}" -f -v -N -l -t $threshold -c ${CPU0},${CPU1} -a ${STALLD_CPU_MULTI} - # Wait for starvation detection on both CPUs log "Waiting for starvation detection on CPU ${CPU0}..." assert_starvation_detected "${STALLD_LOG}" "Starvation detected on CPU ${CPU0}" "30" "${CPU0}" diff --git a/tests/functional/test_starvation_threshold.sh b/tests/functional/test_starvation_threshold.sh index b372a87..bb4a862 100755 --- a/tests/functional/test_starvation_threshold.sh +++ b/tests/functional/test_starvation_threshold.sh @@ -25,16 +25,14 @@ init_functional_test "Starvation Threshold Option (-t)" "test_threshold" test_section "Test 1: Custom threshold of 5 seconds" threshold=5 - -# Create starvation BEFORE starting stalld (avoid detecting kworker tasks) starvation_duration=10 -log "Creating starvation on CPU ${TEST_CPU} for ${starvation_duration}s" -start_starvation_gen -c "${TEST_CPU}" -p 80 -n 2 -d ${starvation_duration} log "Starting stalld with ${threshold}s threshold" -# Use -i to ignore kernel workers that may starve before our test tasks start_stalld_with_log "${STALLD_LOG}" -f -v -N -M -g 1 -i "ksoftirqd,kworker" -c "${TEST_CPU}" -a "${STALLD_CPU}" -t ${threshold} +log "Creating starvation on CPU ${TEST_CPU} for ${starvation_duration}s" +start_starvation_gen -c "${TEST_CPU}" -p 80 -n 2 -d ${starvation_duration} + # Wait for starvation detection log "Waiting for detection (threshold: ${threshold}s)" @@ -51,15 +49,14 @@ test_section "Test 2: No detection before threshold" threshold=10 rm -f "${STALLD_LOG}" -# Create starvation BEFORE starting stalld (avoid detecting kworker tasks) -# Create starvation that will last 6 seconds (less than threshold) starvation_duration=6 -log "Creating short starvation (${starvation_duration}s) with threshold of ${threshold}s" -start_starvation_gen -c "${TEST_CPU}" -p 80 -n 2 -d ${starvation_duration} log "Starting stalld with ${threshold}s threshold" start_stalld_with_log "${STALLD_LOG}" -f -v -N -M -g 1 -c "${TEST_CPU}" -a "${STALLD_CPU}" -t ${threshold} +log "Creating short starvation (${starvation_duration}s) with threshold of ${threshold}s" +start_starvation_gen -c "${TEST_CPU}" -p 80 -n 2 -d ${starvation_duration} + # Wait for starvation generator to fully complete wait "${STARVE_PID}" 2>/dev/null || true @@ -82,16 +79,14 @@ test_section "Test 3: Shorter threshold (3 seconds)" threshold=3 rm -f "${STALLD_LOG}" -# Create starvation BEFORE starting stalld (avoid detecting kworker tasks) -# Create starvation for 8 seconds starvation_duration=8 -log "Creating starvation for ${starvation_duration}s with threshold of ${threshold}s" -start_starvation_gen -c "${TEST_CPU}" -p 80 -n 2 -d ${starvation_duration} log "Starting stalld with ${threshold}s threshold" -# Use -i to ignore kernel workers that may starve before our test tasks start_stalld_with_log "${STALLD_LOG}" -f -v -N -M -g 1 -i "ksoftirqd,kworker" -c "${TEST_CPU}" -a "${STALLD_CPU}" -t ${threshold} +log "Creating starvation for ${starvation_duration}s with threshold of ${threshold}s" +start_starvation_gen -c "${TEST_CPU}" -p 80 -n 2 -d ${starvation_duration} + # Wait for starvation detection log "Waiting for detection (threshold: ${threshold}s)" -- 2.55.0