Skip to content

cavs: budgeting for EDF tasks - #3268

Closed
jajanusz wants to merge 3 commits into
thesofproject:masterfrom
jajanusz:edf-budget-2
Closed

jajanusz wants to merge 3 commits into
thesofproject:masterfrom
jajanusz:edf-budget-2

Conversation

@jajanusz

@jajanusz jajanusz commented Aug 4, 2020

Copy link
Copy Markdown
Contributor

PLEASE test it on BYT this time.

2nd attempt to #3057
Reverted by #3245

@jajanusz jajanusz changed the title cavs: budgeting for EDF tasks [WIP] cavs: budgeting for EDF tasks Aug 4, 2020
@jajanusz

jajanusz commented Aug 4, 2020

Copy link
Copy Markdown
Contributor Author

@plbossart
You reverted wrong commits, scheduler changes are good, timer implementation is wrong ;)
Issue is caused by the fact that you use wallclock for everything and you break 'clocks' interface with it - cpu_timer_get should return cpu timer not exernal timer and I see that you have only one timer in use at all:

SHARED_DATA struct timer timer = {
	.id = TIMER3, /* external timer */
	.irq = IRQ_NUM_EXT_TIMER,
};

IDK what's there on BYT and if you want to actually add arch timers (if there are any) - who's responsible for BYT support?

@jajanusz

jajanusz commented Aug 4, 2020 •

Copy link
Copy Markdown
Contributor Author

IMO cpu_timer implementation in sof struct is broken - all non-cavs platforms return external timer instead of one in cpu.
Can I assume that all these platforms have internal timers and add something like that for BYT:

SHARED_DATA struct timer arch_timer = {
	.id = TIMER1, /* internal timer */
	.irq = IRQ_NUM_TIMER2,
};

@paulstelian97 @dbaluta
What about IMX*, can I use internal timers like the one above, and what ID/IRQ should they have?

@paulstelian97

Copy link
Copy Markdown
Collaborator

@paulstelian97 @dbaluta
What about IMX*, can I use internal timers like the one above, and what ID/IRQ should they have?

As far as I could remember, there is only one timer which is used for the timestamps in traces and for DMA trace flushing. It's already defined for this purpose. Need to check though.

@plbossart

Copy link
Copy Markdown
Member

@jajanusz see picture below there is again no trace on BYT/CHT. the successful test is a false positive, it's broken again.

Screenshot from 2020-08-04 09-57-09

@jajanusz

jajanusz commented Aug 4, 2020

Copy link
Copy Markdown
Contributor Author

@jajanusz see picture below there is again no trace on BYT/CHT. the successful test is a false positive, it's broken again.

Screenshot from 2020-08-04 09-57-09

Yea there are not traces, I know it, CI shows good, I just wrote that problem is not with scheduler, but with timers. All nonCAVS platform return external timer for call that should give internal timer (cpu timer), but I know nothing about BYT and I don't know if I should expect it to have it. Should we expect other platform to have it? It's in the core functionality, so either should be moved out of it (guarded with Kconfig etc) or supported correctly by all platforms.

@plbossart

plbossart commented Aug 4, 2020 •

Copy link
Copy Markdown
Member

Yea there are not traces, I know it, CI shows good, I just wrote that problem is not with scheduler, but with timers. All nonCAVS platform return external timer for call that should give internal timer (cpu timer), but I know nothing about BYT and I don't know if I should expect it to have it. Should we expect other platform to have it? It's in the core functionality, so either should be moved out of it (guarded with Kconfig etc) or supported correctly by all platforms.

@lgirdwood @keyonjie need you to chime in here, I don't think we can rely on internal timers on Baytrail, where the core can run at 6 or 7 different speeds, adjusted depending on load. It's different to cAVS platforms where the goal was run to completion and power-gate.

@plbossart

Copy link
Copy Markdown
Member

Yea there are not traces, I know it, CI shows good, I just wrote that problem is not with scheduler, but with timers. All nonCAVS platform return external timer for call that should give internal timer (cpu timer), but I know nothing about BYT and I don't know if I should expect it to have it. Should we expect other platform to have it? It's in the core functionality, so either should be moved out of it (guarded with Kconfig etc) or supported correctly by all platforms.

@jajanusz What I don't get is that the rest of the functionality seems unafffected, it's only the traces that are disabled? if indeed we used the wrong timer then shouldn't everything just go South? How does it impact the trace only?

@jajanusz

jajanusz commented Aug 5, 2020

Copy link
Copy Markdown
Contributor Author

Yea there are not traces, I know it, CI shows good, I just wrote that problem is not with scheduler, but with timers. All nonCAVS platform return external timer for call that should give internal timer (cpu timer), but I know nothing about BYT and I don't know if I should expect it to have it. Should we expect other platform to have it? It's in the core functionality, so either should be moved out of it (guarded with Kconfig etc) or supported correctly by all platforms.

@jajanusz What I don't get is that the rest of the functionality seems unafffected, it's only the traces that are disabled? if indeed we used the wrong timer then shouldn't everything just go South? How does it impact the trace only?

Because you return same timer in all calls (when there should be different timers) when I set timer handler for budgeting I overwrite probably some other handler that is already on wallclock. If we cannot rely on internal timers, then our god struct struct sof shouldn't have internal timer (or it should be guarded with #if CONFIG_HAVE_INTERNAL_TIMER).

@jajanusz

jajanusz commented Aug 5, 2020

Copy link
Copy Markdown
Contributor Author

Blocked by #3274

@jajanusz
jajanusz force-pushed the edf-budget-2 branch 2 times, most recently from bee1604 to dd9c573 Compare August 24, 2020 14:37
@jajanusz

Copy link
Copy Markdown
Contributor Author

Cut budgeting with #ifdefs to not block this feature by waiting for blocking issue.

@jajanusz
jajanusz force-pushed the edf-budget-2 branch 4 times, most recently from c130c20 to eb5c389 Compare August 24, 2020 20:00

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, do we have any accompanying documentation on how this will work in sof-docs given these new updates ?

Comment thread src/schedule/edf_schedule.c Outdated
Comment thread src/schedule/edf_schedule.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we basing the budget on 8000 timer_ticks ? If so, I think this would be better as a per platform CONFIG_ variable (given that non CAVS platforms will have a different timer).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just an example. This is defined as CONFIG and defaults to 8k.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, it's probably good to explain this in the Kconfig "help" for the option. I guess 8k is based on a % of total budget (based on max clock rate?). Just looking for detail so that the option can be easily tuned based on teh help.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's already in help in kconfig - that it's within 1 systick IDK if we need to add more there.
It's not really % because when you switch from HPRO to LPRO you have 120k cycles in systick instead of 400k and budget for IPCs stays the same. It's just value enough to handle IPCs without stalling other tasks.

Add possibility to set budget for EDF tasks.
It's needed to ensure that some long running task will
not stall other tasks.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
IPC task may be time consuming and has high priority,
what may make other tasks stall. To prevent this it should
have limited cycles budget per systick.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
IDC task may be time consuming and has high priority,
what may make other tasks stall. To prevent this it should
have limited cycles budget per systick.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
@jajanusz

Copy link
Copy Markdown
Contributor Author

Cut budgeting with #ifdefs to not block this feature by waiting for blocking issue.

Restored old implementation, cos @lyakh fixed clocks for BYT and it makes code simpler.

@jajanusz jajanusz changed the title [WIP] cavs: budgeting for EDF tasks cavs: budgeting for EDF tasks Sep 10, 2020
@lgirdwood

Copy link
Copy Markdown
Member

@jajanusz as we are near to v1.6 cut off here, are you happy for this in v1.6 or would you prefer to wait for v1,7 ?

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments below, mainly to clarify some points that aren't clear to me - no change needed in the code itself.


struct edf_task_pdata {
void *ctx;
uint32_t budget; /**< cycles per systick */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure in the past we defined variable ticks for EDF. Would this scale here if the tick duration is changed dynamically. And I read in a comment below that we use '120k cycles in systick instead of 400k', so shouldn't there be multiple budget definitions, one per systick value?

{
struct edf_task_pdata *edf_pdata = edf_sch_get_pdata(task);

if (!edf_pdata->budget)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe clarify with a comment in the structure definition that a budget of zero will result in a specific behavior. It's also not clear to me if this is a feature or an error condition.


struct edf_task_pdata {
void *ctx;
uint32_t budget; /**< cycles per systick */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also explain that bugdet can be zero, and the difference in behavior between zero and non-zero values.

@jajanusz

Copy link
Copy Markdown
Contributor Author

@jajanusz as we are near to v1.6 cut off here, are you happy for this in v1.6 or would you prefer to wait for v1,7 ?

We can leave it for 1.7, better to let it mature in repo, maybe some other issues will come out like with BYT, it touched a few things that were not used a lot so far (so are not stable).

@jajanusz

Copy link
Copy Markdown
Contributor Author

Feature is not needed ATM and may impose too many sideffects without extensive long-term testing, if someone will need it in the feature than it can be continued from this PR.

@jajanusz jajanusz closed this Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants