From 33dec4175aae6b97e50728b2da2beda6c1ea5f3d Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Fri, 22 Mar 2024 14:32:18 +0100 Subject: [PATCH 1/3] fix(freertos): Updated threshold for scheduling time test for esp32p4 This commit increases the pass threshold for the scheduling time test on esp32p4. --- components/idf_test/include/esp32p4/idf_performance_target.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/idf_test/include/esp32p4/idf_performance_target.h b/components/idf_test/include/esp32p4/idf_performance_target.h index ae02683c52..c6c55fc01a 100644 --- a/components/idf_test/include/esp32p4/idf_performance_target.h +++ b/components/idf_test/include/esp32p4/idf_performance_target.h @@ -7,3 +7,6 @@ /* Spinlock performance on esp32p4 is slower. May need to adjust these values once IDF-7898 is fixed */ #define IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP 380 #define IDF_PERFORMANCE_MAX_FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE 135 + +/* Solicited yields (portYIELD() or taskYIELD()) take longer on esp32p4. TODO: IDF-2809 */ +#define IDF_PERFORMANCE_MAX_SCHEDULING_TIME 2900 From 68dbbf339d00672b442ed25d2da4852fb793bcce Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Tue, 13 Feb 2024 09:52:54 +0100 Subject: [PATCH 2/3] fix(freertos): Updated unstable FreeRTOS unit tests This commit fixes some flaky FreeRTOS unit tests. --- .../test_apps/freertos/kernel/tasks/test_yielding.c | 10 +++++----- .../performance/test_freertos_scheduling_time.c | 13 ++++++++----- .../test_apps/freertos/port/test_spinlocks.c | 12 +++++++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/components/freertos/test_apps/freertos/kernel/tasks/test_yielding.c b/components/freertos/test_apps/freertos/kernel/tasks/test_yielding.c index 6052a0157c..6da218976f 100644 --- a/components/freertos/test_apps/freertos/kernel/tasks/test_yielding.c +++ b/components/freertos/test_apps/freertos/kernel/tasks/test_yielding.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -75,7 +75,7 @@ static void yield_task2(void *arg) /* Wait for the other task to run for the test to begin */ while (!task_sequence_ready) { - taskYIELD(); + vTaskDelay(10); }; /* Store task_id in the sequence array */ @@ -272,7 +272,7 @@ static void test_critical_task2(void *arg) /* Wait for the other task to run for the test to begin */ while (!task_sequence_ready) { - taskYIELD(); + vTaskDelay(10); }; /* Store task_id in the sequence array */ @@ -474,7 +474,7 @@ static void other_core_task2(void *arg) /* Wait for the other task to run for the test to begin */ while (!task_sequence_ready) { - taskYIELD(); + vTaskDelay(10); }; /* Store task_id in the sequence array */ @@ -594,7 +594,7 @@ static void other_core_critical_task2(void *arg) /* Wait for the other task to run for the test to begin */ while (!task_sequence_ready) { - taskYIELD(); + vTaskDelay(10); }; /* Store task_id in the sequence array */ diff --git a/components/freertos/test_apps/freertos/performance/test_freertos_scheduling_time.c b/components/freertos/test_apps/freertos/performance/test_freertos_scheduling_time.c index d0f4e3361b..1d7e5efe93 100644 --- a/components/freertos/test_apps/freertos/performance/test_freertos_scheduling_time.c +++ b/components/freertos/test_apps/freertos/performance/test_freertos_scheduling_time.c @@ -31,7 +31,7 @@ static void test_task_1(void *arg) for (;;) { context->before_sched = esp_cpu_get_cycle_count(); - vPortYield(); + taskYIELD(); } vTaskDelete(NULL); @@ -44,11 +44,11 @@ static void test_task_2(void *arg) vTaskPrioritySet(NULL, CONFIG_UNITY_FREERTOS_PRIORITY + 1); vTaskPrioritySet(context->t1_handle, CONFIG_UNITY_FREERTOS_PRIORITY + 1); - vPortYield(); + taskYIELD(); for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) { accumulator += (esp_cpu_get_cycle_count() - context->before_sched); - vPortYield(); + taskYIELD(); } context->cycles_to_sched = accumulator / NUMBER_OF_ITERATIONS; @@ -65,8 +65,8 @@ TEST_CASE("scheduling time test", "[freertos]") TEST_ASSERT(context.end_sema != NULL); #if !CONFIG_FREERTOS_UNICORE - xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, 1, &context.t1_handle, 1); - xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, 1, NULL, 1); + xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle, 1); + xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL, 1); #else xTaskCreatePinnedToCore(test_task_1, "test1", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle, 0); xTaskCreatePinnedToCore(test_task_2, "test2", 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL, 0); @@ -75,4 +75,7 @@ TEST_CASE("scheduling time test", "[freertos]") BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY); TEST_ASSERT_EQUAL_HEX32(pdTRUE, result); TEST_PERFORMANCE_LESS_THAN(SCHEDULING_TIME, "%"PRIu32" cycles", context.cycles_to_sched); + + /* Cleanup */ + vSemaphoreDelete(context.end_sema); } diff --git a/components/freertos/test_apps/freertos/port/test_spinlocks.c b/components/freertos/test_apps/freertos/port/test_spinlocks.c index e26887a88e..ab2a3e53eb 100644 --- a/components/freertos/test_apps/freertos/port/test_spinlocks.c +++ b/components/freertos/test_apps/freertos/port/test_spinlocks.c @@ -49,7 +49,7 @@ TEST_CASE("portMUX spinlocks (no contention)", "[freertos]") } BENCHMARK_END("no contention lock"); -#ifdef CONFIG_FREERTOS_UNICORE +#if CONFIG_FREERTOS_UNICORE TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS)); #else #if CONFIG_SPIRAM @@ -76,6 +76,16 @@ TEST_CASE("portMUX recursive locks (no contention)", "[freertos]") } } BENCHMARK_END("no contention recursive"); + +#if CONFIG_FREERTOS_UNICORE + TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS)); +#else +#if CONFIG_SPIRAM + TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_PSRAM, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS)); +#else + TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP, "%"PRIu32" cycles/op", ((end - start) / REPEAT_OPS)); +#endif +#endif } #if CONFIG_FREERTOS_NUMBER_OF_CORES == 2 From c6efc57e6e2d080203fad1adc3fe388cb4625ae0 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 12 Feb 2024 10:56:10 +0100 Subject: [PATCH 3/3] fix(freertos): Re-enabled FreeRTOS unit tests for esp32p4 This commit reenables the FreeRTOS unit tests to be run during CI pipelines for esp32p4. --- components/freertos/test_apps/.build-test-rules.yml | 4 ---- .../freertos/test_apps/freertos/pytest_freertos.py | 12 ++++-------- .../test_apps/freertos/sdkconfig.ci.single_core | 2 -- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/components/freertos/test_apps/.build-test-rules.yml b/components/freertos/test_apps/.build-test-rules.yml index 70737f731f..bf8ffe8b5b 100644 --- a/components/freertos/test_apps/.build-test-rules.yml +++ b/components/freertos/test_apps/.build-test-rules.yml @@ -5,10 +5,6 @@ components/freertos/test_apps/freertos: - if: CONFIG_NAME == "smp" and IDF_TARGET == "esp32p4" temporary: true reason: target(s) not supported yet - disable_test: - - if: IDF_TARGET == "esp32p4" - temporary: true - reason: test not pass, should be re-enable # IDF-8981 components/freertos/test_apps/orig_inc_path: enable: diff --git a/components/freertos/test_apps/freertos/pytest_freertos.py b/components/freertos/test_apps/freertos/pytest_freertos.py index 488595c171..6baa6ba781 100644 --- a/components/freertos/test_apps/freertos/pytest_freertos.py +++ b/components/freertos/test_apps/freertos/pytest_freertos.py @@ -1,16 +1,14 @@ # SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 - import pytest from pytest_embedded import Dut -# TODO: IDF-8981 CONFIGS = [ - pytest.param('default', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32h2', 'esp32p4'], reason='test failed')]), - pytest.param('freertos_options', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32h2', 'esp32p4'], reason='test failed')]), + pytest.param('default', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32h2'], reason='test failed')]), + pytest.param('freertos_options', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32h2'], reason='test failed')]), pytest.param('psram', marks=[pytest.mark.esp32]), - pytest.param('release', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='test failed')]), - pytest.param('single_core', marks=[pytest.mark.esp32]), + pytest.param('release', marks=[pytest.mark.supported_targets]), + pytest.param('single_core', marks=[pytest.mark.esp32, pytest.mark.esp32p4]), pytest.param('smp', marks=[pytest.mark.supported_targets, pytest.mark.temp_skip_ci(targets=['esp32h2', 'esp32p4'], reason='test failed/TBD IDF-8113')]), ] @@ -21,7 +19,6 @@ def test_freertos(dut: Dut) -> None: dut.run_all_single_board_cases() -@pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='esp32p4 support TBD') # IDF-8981 @pytest.mark.supported_targets @pytest.mark.generic @pytest.mark.parametrize('config', ['freertos_options'], indirect=True) @@ -33,7 +30,6 @@ def test_task_notify_too_high_index_fails(dut: Dut) -> None: dut.expect_exact('Rebooting...') -@pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='esp32p4 support TBD') # IDF-8981 @pytest.mark.supported_targets @pytest.mark.generic @pytest.mark.parametrize('config', ['freertos_options'], indirect=True) diff --git a/components/freertos/test_apps/freertos/sdkconfig.ci.single_core b/components/freertos/test_apps/freertos/sdkconfig.ci.single_core index 69b5e1abdc..a5489aae1b 100644 --- a/components/freertos/test_apps/freertos/sdkconfig.ci.single_core +++ b/components/freertos/test_apps/freertos/sdkconfig.ci.single_core @@ -1,4 +1,2 @@ # Test configuration for using FreeRTOS with under single core on a multicore target. Only tested on the ESP32 - -CONFIG_IDF_TARGET="esp32" CONFIG_FREERTOS_UNICORE=y