scheduler/dynamic: add helper function to calculate busy pct
This will be useful in some upcoming patches where we will be calculating these percentages in more places. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: If7d84c00fe1b666988fe06537836ba7b9cb161aa Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9580 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
1cfdbd429f
commit
de04fa748f
@ -54,6 +54,16 @@ static struct core_stats *g_cores;
|
||||
#define SCHEDULER_LOAD_LIMIT 20
|
||||
#define SCHEDULER_CORE_LIMIT 95
|
||||
|
||||
static uint8_t
|
||||
_busy_pct(uint64_t busy, uint64_t idle)
|
||||
{
|
||||
if ((busy + idle) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return busy * 100 / (busy + idle);
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
_get_thread_load(struct spdk_scheduler_thread_info *thread_info)
|
||||
{
|
||||
@ -62,12 +72,8 @@ _get_thread_load(struct spdk_scheduler_thread_info *thread_info)
|
||||
busy = thread_info->current_stats.busy_tsc;
|
||||
idle = thread_info->current_stats.idle_tsc;
|
||||
|
||||
if (busy == 0) {
|
||||
/* No work was done, exit before possible division by 0. */
|
||||
return 0;
|
||||
}
|
||||
/* return percentage of time thread was busy */
|
||||
return busy * 100 / (busy + idle);
|
||||
return _busy_pct(busy, idle);
|
||||
}
|
||||
|
||||
typedef void (*_foreach_fn)(struct spdk_scheduler_thread_info *thread_info);
|
||||
@ -133,7 +139,7 @@ _is_core_over_limit(uint32_t core_id)
|
||||
}
|
||||
|
||||
/* Work done was less than the limit */
|
||||
if (busy * 100 / (busy + idle) < SCHEDULER_CORE_LIMIT) {
|
||||
if (_busy_pct(busy, idle) < SCHEDULER_CORE_LIMIT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user