Skip to content

Commit b4b2b9e

Browse files
committed
pm: Use fixed cpu id in single core case
When there are no multiple cores than fixing id to 0 saves few cycles. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent d2e57b7 commit b4b2b9e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

subsys/pm/pm.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static inline void pm_state_notify(bool entering_state)
6262
}
6363

6464
if (callback) {
65-
callback(z_cpus_pm_state[_current_cpu->id].state);
65+
callback(z_cpus_pm_state[CPU_ID].state);
6666
}
6767
}
6868
k_spin_unlock(&pm_notifier_lock, pm_notifier_key);
@@ -93,7 +93,7 @@ static inline int32_t ticks_expiring_sooner(int32_t ticks1, int32_t ticks2)
9393

9494
void pm_system_resume(void)
9595
{
96-
uint8_t id = _current_cpu->id;
96+
uint8_t id = CPU_ID;
9797

9898
/*
9999
* This notification is called from the ISR of the event
@@ -142,7 +142,7 @@ bool pm_state_force(uint8_t cpu, const struct pm_state_info *info)
142142

143143
bool pm_system_suspend(int32_t kernel_ticks)
144144
{
145-
uint8_t id = _current_cpu->id;
145+
uint8_t id = CPU_ID;
146146
k_spinlock_key_t key;
147147
int32_t ticks, events_ticks;
148148

subsys/pm/pm_stats.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ SYS_INIT(pm_stats_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
5353

5454
void pm_stats_start(void)
5555
{
56-
time_start[_current_cpu->id] = k_cycle_get_32();
56+
time_start[CPU_ID] = k_cycle_get_32();
5757
}
5858

5959
void pm_stats_stop(void)
6060
{
61-
time_stop[_current_cpu->id] = k_cycle_get_32();
61+
time_stop[CPU_ID] = k_cycle_get_32();
6262
}
6363

6464
void pm_stats_update(enum pm_state state)
6565
{
66-
uint8_t cpu = _current_cpu->id;
66+
uint8_t cpu = CPU_ID;
6767
uint32_t time_total = time_stop[cpu] - time_start[cpu];
6868

6969
STATS_INC(stats[cpu][state], state_count);

0 commit comments

Comments
 (0)