Merge branch 'fix/freertos_scheduling_time_test' into 'master'

fix(freertos): Updated threshold for scheduling time test for esp32p4

Closes IDF-8981 and IDF-8090

See merge request espressif/esp-idf!29812
This commit is contained in:
Sudeep Mohanty
2024-03-25 19:22:33 +08:00
7 changed files with 31 additions and 25 deletions

View File

@@ -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:

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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