-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ll_schedule: add a DSP load tracker to ll_tasks_execute #4943
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,13 +38,19 @@ DECLARE_SOF_UUID("ll-schedule", ll_sched_uuid, 0x4f9c3ec7, 0x7b55, 0x400c, | |
|
||
DECLARE_TR_CTX(ll_tr, SOF_UUID(ll_sched_uuid), LOG_LEVEL_INFO); | ||
|
||
struct ll_dsp_load { | ||
unsigned int cycles_sum; | ||
unsigned int checks; | ||
}; | ||
|
||
/* one instance of data allocated per core */ | ||
struct ll_schedule_data { | ||
struct list_item tasks; /* list of ll tasks */ | ||
atomic_t num_tasks; /* number of ll tasks */ | ||
#if CONFIG_PERFORMANCE_COUNTERS | ||
struct perf_cnt_data pcd; | ||
#endif | ||
struct ll_dsp_load dsp_load; | ||
struct ll_schedule_domain *domain; /* scheduling domain */ | ||
}; | ||
|
||
|
@@ -113,13 +119,39 @@ static void schedule_ll_task_done(struct ll_schedule_data *sch, | |
atomic_read(&sch->domain->total_num_tasks)); | ||
} | ||
|
||
/* perf measurement windows size 2^x */ | ||
#define CHECKS_WINDOW_SIZE 10 | ||
|
||
static inline void dsp_load_check(struct ll_dsp_load *load, uint32_t cycles0, uint32_t cycles1) | ||
{ | ||
uint32_t diff, max; | ||
|
||
if (cycles1 > cycles0) | ||
diff = cycles1 - cycles0; | ||
else | ||
diff = UINT32_MAX - cycles0 + cycles1; | ||
|
||
load->cycles_sum += diff; | ||
|
||
if (++load->checks == 1 << CHECKS_WINDOW_SIZE) { | ||
load->cycles_sum >>= CHECKS_WINDOW_SIZE; | ||
max = clock_us_to_ticks(PLATFORM_DEFAULT_CLOCK, CONFIG_SYSTICK_PERIOD); | ||
tr_info(&ll_tr, "ll avg %u/%u", load->cycles_sum, max); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For automatic parsing, using blank as separator for numbers instead of "/" could be nicer? |
||
load->cycles_sum = 0; | ||
load->checks = 0; | ||
} | ||
} | ||
|
||
static void schedule_ll_tasks_execute(struct ll_schedule_data *sch) | ||
{ | ||
struct ll_schedule_domain *domain = sch->domain; | ||
uint32_t cycles0, cycles1; | ||
struct list_item *wlist; | ||
struct list_item *tlist; | ||
struct task *task; | ||
|
||
cycles0 = (uint32_t)platform_timer_get(timer_get()); | ||
|
||
/* check each task in the list for pending */ | ||
list_for_item_safe(wlist, tlist, &sch->tasks) { | ||
task = container_of(wlist, struct task, list); | ||
|
@@ -152,6 +184,9 @@ static void schedule_ll_tasks_execute(struct ll_schedule_data *sch) | |
|
||
spin_unlock(&domain->lock); | ||
} | ||
|
||
cycles1 = (uint32_t)platform_timer_get(timer_get()); | ||
dsp_load_check(&sch->dsp_load, cycles0, cycles1); | ||
} | ||
|
||
static void schedule_ll_client_reschedule(struct ll_schedule_data *sch) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be light-weight, but the above line performs run-time divisions and multiplications with constants, even if only every N runs. Since
clock_us_to_ticks()
is a real function, I don't think this will be pre-calculated and optimised away by the compiler. But since it's always the same calculation (as long as the clock frequency doesn't change), this should be calculated once and stored. To also take frequency calculation into account we can also store the frequency (index) that was used to calculate this, and if it changes - recalculate.But yes, this would also somehow have to account for imprecise XTOS ticks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only part doing the div/mult is the
clock_us_to_ticks()
and this will only happen once per second (and you are right, we could do this at init since it's all const), all the rest is shifts which are optimal on xtensa