Repository navigation
lib: MCPS budget manager - #6649
Conversation
4091080 to
d99810d
Compare
abonislawski
left a comment
There was a problem hiding this comment.
Why there are no users of this manager? Even not supporting IPC to set CoreCpsAdjust from IPC data?
There was a problem hiding this comment.
CONFIG_ZEPHYR_NATIVE_DRIVERS not needed in this file
77dfed5 to
e6436e4
Compare
There was a problem hiding this comment.
This is not recommended on multicore as the array[CORE_COUNT] can easily be clobbered. This structure should either use coherent API or be uncache only (with the correct SPARSE types).
There was a problem hiding this comment.
Needs to be a for loop with an array size end condition.
There was a problem hiding this comment.
Given my previous statement, its worth saying in a comment that this should be in uncache (which it should be on Zephyr) so no one is tempted to move it to cache.
There was a problem hiding this comment.
is a comment there sufficient or do we have sth else (sparse?) for uncache specifically?
There was a problem hiding this comment.
@lyakh can sparse be used to say static variables are uncache atm ?
There was a problem hiding this comment.
@lgirdwood don't think so. An address space has to be specified explicitly for sparse to check it, all objects, that don't specify one explicitly are assumed to belong to the default address space - regardless whether static or automatic.
There was a problem hiding this comment.
would be nice to have something in the logs here.
abonislawski
left a comment
There was a problem hiding this comment.
Please add basic usage for this driver/manager in base_fw (set&get kcps data)
For clock adjustment, discuss with single core first, if I remember correctly, ADSP have 38.4/100/400 Mhz to choose, 38.4 is not possible for now, since a single playback is 40-50 mcps, and peak may go to 60, 38.4 may be possible for capture, I did not test it, later CI will have data on capture. So our strategy may be simple: whether need set clock to 100Mhz, a simple way is depend on pipeline and component num, we do have those data, please check implementation from app/perf_overlay.conf, later CI will have a report for different case performance data. |
There was a problem hiding this comment.
What's the full name for cps and kcps? anything special inside?
There was a problem hiding this comment.
cycles per second and kilo cycles per second. cps = 1000 * kcps. Nothing special inside, though I did unify the naming to use kcps where possible.
btian1
left a comment
There was a problem hiding this comment.
whether need a extra function for estimate current workload performance based on pipeline num and component name/num? then consolidate these data and set freq accordingy?
15a918d to
7dbef99
Compare
657ce00 to
acc9e9e
Compare
|
@btian1 The performance numbers can come in multiple forms. We definitely need some base usage for basefw. For audio modules their usage should come in ipc4 message (the values there are unmeasured yet afaik). Maybe some other parts of fw will have to request budget for themselves. That'll come with future PRs. |
|
@kfrydryx btw, is there any CI test that uses code in this PR or is this currently locally tested ? i.e will this code be invoked today if CI runs a low MCPS pipeline ? |
| return ipc4_logging_enable_logs(first_block, last_block, data_offset, data); | ||
| case IPC4_REGISTER_KCPS: | ||
| return basefw_register_kcps(first_block, last_block, data_offset, data); | ||
| case IPC4_RESOURCE_ALLOCATION_REQUEST: |
There was a problem hiding this comment.
@kfrydryx did you try to clarify with ACE FW/Windows SW why do we have two IPC's doing actually the same?
There was a problem hiding this comment.
I did not. register_kcps is not used in internal testing, though the call is implemented. Both are handled by closed source fw.
There was a problem hiding this comment.
yes, exactly. Just like in metric system. 1 MCPS = 1000 KCPS = 1000 000 CPS.
|
@lgirdwood This code is not used yet anywhere else, other than in those IPC requests. There are tests in internal CI calling them (though they are not made exclusively to test this functionality). |
lgirdwood
left a comment
There was a problem hiding this comment.
@kfrydryx I assume this should be our single way/API to control CPU frequency/source (when it's enabled to avoid collisions with the manual API) ? If so, I would recommend
- We check current CPU frequency/source is correct before we set new frequency/source.
- I would call it cpu-clk-manager.c/.h, the word "budget" suggest scheduling and this PR is about clock frequency/source.
There was a problem hiding this comment.
can we prefix to avoid any naming collisions/confusion ?
There was a problem hiding this comment.
Sure
Also:
File name changed.
I was thinking about having a pause/resume mechanism for overriding the managers clock choice, but according to @mmaka1 it is currently sufficient. This can be easily worked around by requesting artificial kcps budget. We were also considering an approach of holding a reference of who requested the clock and decide on the change on clock driver level, but left that topic for later.
There was a problem hiding this comment.
We need to add doxygen for these new APIs.
76d2a24 to
cf08404
Compare
There was a problem hiding this comment.
Pls update the pre-proc symbols to reflect the new (nice) name.
There was a problem hiding this comment.
Sorry for the late answer, sure. Missed that.
There was a problem hiding this comment.
Using core and core_id as symbols is a bit confusing, especially that the first variable contains a core id too. core could be renamed as adjusted_core_id or sth similar.
There was a problem hiding this comment.
Not sure why core is of signed int type (also in many other places in the code) while this piece of the code (as many others) works only for sequential values in 0..CONFIG_CORE_COUNT-1 range. Note that cpu_get_id() is now mapped to Zephyr's arch_proc_id() that returns uint32_t. Note that the latter does not guarantee the condition mentioned above (see https://docs.zephyrproject.org/latest/hardware/porting/arch.html#c.arch_proc_id), so indexing kcps_consumption with core might not be safe, unless there is some integration note but I did not find anything in place the cpu_get_id() is declared/defined.
There was a problem hiding this comment.
That's the way it's done in other parts of code. I also couldn't find any spec guaranteeing core ids to be continues and starting at 0. I can imagine something like platform specific iterator for enumerating cores, but that is probably not the place for such discussion. And it would require refactoring other code too.
I did change the iterators to be unsigned, just for the sake of it :)
There was a problem hiding this comment.
Defining multiple exit points and requiring serious cleanup like unlock in all that places might be less readable that setting error code to the local variable and jump to the label near the end of hte function.
There was a problem hiding this comment.
This needs to be POSIX and do the IPC4 translation in the IPC layer.
There was a problem hiding this comment.
I see, in base_fw.c they are mixed up. I suppose that's just lack of cleanup?
|
Is there a way to adjust DSP clock at runtime instead of at beginning? this is because beginning performance is poor at the first 1-3 ms running. |
Initial implementation of MCPS budget manager. FW can request/free MCPS usage on enabling certain FW elements. Caution should be taken when processing on different cores, as kcps_budget_data is uncache only. The manager will change clock source to match requested MCPS consumption. Budget manager may interfere with manually setting clock values! Signed-off-by: Krzysztof Frydryk <krzysztofx.frydryk@intel.com>
Handle register_kcps, resource_allocation_request for kcps, power_state_info_get. Signed-off-by: Krzysztof Frydryk <krzysztofx.frydryk@intel.com>
|
@btian1 Well... that's what this is for. The desired model is to register everything that is running on the fw and change clock accordingly at runtime. At the moment there's not enough performance data for this to make sense, so that PR consists only of base mechanism and some IPC handling as usage. |
|
ok,we will have mcps data later, Q1 will happen, for one single playback, expectation is change clock one time except there are new pipe join, since change clock also takes time. Also I would echo Liam's suggestion, title and file name better come up with: cpu-clk-manager.c/.h or adsp-clk-manager.c/h |
|
@pblaszko good for you now ? |
Review request changes have been made.
Add initial implementation of mcps budget management.
Ideally it should be used to control cpu clock, so that it runs on the lowest frequency suitable for performed tasks.
Different parts of FW can request/free some budget using
core_cps_adjustand clock should be changed accordingly. (i.e. when setting pipeline to run we should request budget required by its modules).Currently there is no proper performance data to be used, so it's advised to request some artificial, high budget on platform init to keep the clock running fast and avoid performance issues.
Requires zephyrproject-rtos/zephyr#52205 to work on mtl