staticinlineunsignedlong__cpu_util_freq_walt(int cpu,structwalt_cpu_load*walt_load,unsignedint*reason){
u64 util;structrq*rq =cpu_rq(cpu);unsignedlong capacity =capacity_orig_of(cpu);structwalt_rq*wrq =(structwalt_rq*) rq->android_vendor_data1;#ifIS_ENABLED(CONFIG_OPLUS_FEATURE_OCH)int edtask_flag =0;
util =div64_u64(freq_policy_load(rq, reason,&edtask_flag),
sched_ravg_window >> SCHED_CAPACITY_SHIFT);cpufreq_health_get_edtask_state(cpu, edtask_flag);#else
util =scale_time_to_util(freq_policy_load(rq, reason));#endif/*
* util is on a scale of 0 to 1024. this is the utilization
* of the cpu in the last window
*/
wrq->util = util;if(walt_load){
u64 nl = wrq->nt_prev_runnable_sum +
wrq->grp_time.nt_prev_runnable_sum;
u64 pl = wrq->walt_stats.pred_demands_sum_scaled;
wrq->old_busy_time = util;
wrq->old_estimated_time = pl;
nl =scale_time_to_util(nl);
walt_load->nl = nl;
walt_load->pl = pl;
walt_load->ws = walt_load_reported_window;
walt_load->rtgb_active = rtgb_active;
walt_load->big_task_rotation = walt_rotation_enabled;if(wrq->ed_task)
walt_load->ed_active =true;else
walt_load->ed_active =false;}return(util >= capacity)? capacity : util;}
staticinline u64 scale_time_to_util(u64 d){/*
* The denominator at most could be (8 * tick_size) >> SCHED_CAPACITY_SHIFT,
* a value that easily fits a 32bit integer.
*/do_div(d, walt_scale_demand_divisor);return d;}