tests: benchmark: Add power management to footprint
Add a build-only test to track footprint when enabling device power management. Signed-off-by: Keith Short <keithshort@google.com>
This commit is contained in:
parent
e8c7e026e7
commit
031ff08bc6
5 changed files with 87 additions and 1 deletions
|
@ -4,9 +4,10 @@ cmake_minimum_required(VERSION 3.20.0)
|
|||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(common_kernel_footprint)
|
||||
|
||||
FILE(GLOB app_sources src/[^u]*.c)
|
||||
FILE(GLOB app_sources src/[^up]*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
||||
target_sources_ifdef(CONFIG_USERSPACE app PRIVATE src/userspace.c)
|
||||
target_sources_ifdef(CONFIG_PM_DEVICE app PRIVATE src/pm_device.c)
|
||||
|
||||
target_include_directories(app PRIVATE
|
||||
${ZEPHYR_BASE}/kernel/include
|
||||
|
|
9
tests/benchmarks/footprints/prj_pm.conf
Normal file
9
tests/benchmarks/footprints/prj_pm.conf
Normal file
|
@ -0,0 +1,9 @@
|
|||
CONFIG_HEAP_MEM_POOL_SIZE=256
|
||||
CONFIG_MAIN_STACK_SIZE=2048
|
||||
CONFIG_MP_NUM_CPUS=1
|
||||
CONFIG_PM=y
|
||||
CONFIG_PM_DEVICE=y
|
||||
CONFIG_PM_DEVICE_RUNTIME=y
|
||||
CONFIG_THREAD_NAME=y
|
||||
CONFIG_LOG=y
|
||||
CONFIG_LOG_MODE_MINIMAL=y
|
|
@ -30,6 +30,7 @@ struct k_thread my_thread_0;
|
|||
extern void run_heap_malloc_free(void);
|
||||
extern void run_libc(void);
|
||||
extern void run_mutex(void);
|
||||
extern void run_pm_device(void);
|
||||
extern void run_semaphore(void);
|
||||
extern void run_thread_system(void);
|
||||
extern void run_timer(void);
|
||||
|
@ -63,6 +64,10 @@ void main(void)
|
|||
|
||||
run_workq();
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
run_pm_device();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
run_userspace();
|
||||
#endif
|
||||
|
|
67
tests/benchmarks/footprints/src/pm_device.c
Normal file
67
tests/benchmarks/footprints/src/pm_device.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Google, LLC
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Stub driver to measure the footprint impact of power management
|
||||
*
|
||||
*/
|
||||
#include <device.h>
|
||||
#include <pm/device.h>
|
||||
#include <pm/device_runtime.h>
|
||||
|
||||
#define DUMMY_PM_DRIVER_NAME "dummy_pm_driver"
|
||||
#define DUMMY_DRIVER_NAME "dummy_driver"
|
||||
|
||||
static int dummy_init(const struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_device_pm_ctrl(const struct device *dev,
|
||||
enum pm_device_action action)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Define a driver with and without power management enabled */
|
||||
DEVICE_DEFINE(dummy_pm_driver, DUMMY_PM_DRIVER_NAME, &dummy_init,
|
||||
dummy_device_pm_ctrl, NULL, NULL, APPLICATION,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL);
|
||||
|
||||
DEVICE_DEFINE(dummy_driver, DUMMY_DRIVER_NAME, &dummy_init,
|
||||
NULL, NULL, NULL, APPLICATION,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL);
|
||||
|
||||
void run_pm_device(void)
|
||||
{
|
||||
const struct device *dev;
|
||||
enum pm_device_state pm_state;
|
||||
|
||||
/* Get the PM state from a device with PM support */
|
||||
dev = device_get_binding(DUMMY_PM_DRIVER_NAME);
|
||||
if (pm_device_state_get(dev, &pm_state)) {
|
||||
printk("\n PM device get state failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pm_device_get(dev)) {
|
||||
printk("\n PM device runtime get failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pm_device_put(dev)) {
|
||||
printk("\n PM device runtime put failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the PM state from a device without PM support */
|
||||
dev = device_get_binding(DUMMY_DRIVER_NAME);
|
||||
if (pm_device_state_get(dev, &pm_state) != ENOSYS) {
|
||||
printk("\n PM device get state did not fail\n");
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,10 @@ tests:
|
|||
benchmark.kernel.footprints.default:
|
||||
tags: benchmark
|
||||
build_only: true
|
||||
benchmark.kernel.footprints.pm:
|
||||
tags: benchmark
|
||||
build_only: true
|
||||
extra_args: CONF_FILE=prj_pm.conf
|
||||
benchmark.kernel.footprints.userspace:
|
||||
filter: CONFIG_ARCH_HAS_USERSPACE
|
||||
extra_args: CONF_FILE=prj_userspace.conf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue