ANDROID: vendor_hooks: add hook account_process_tick_gran

this hook will allow to account tick in every third of more ticks
to save cpu time for accounting

Bug: 279549765
Change-Id: I5d18e0167fdce076d13aecc653dcf6387bcb25f2
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
This commit is contained in:
Liujie Xie 2023-04-24 11:20:20 +08:00 committed by Treehugger Robot
parent 1a40d683e8
commit ec8c8f6e33
3 changed files with 13 additions and 3 deletions

View file

@ -347,6 +347,10 @@ DECLARE_HOOK(android_vh_sched_setaffinity_early,
TP_PROTO(struct task_struct *p, const struct cpumask *new_mask, bool *retval),
TP_ARGS(p, new_mask, retval));
DECLARE_HOOK(android_vh_account_process_tick_gran,
TP_PROTO(int user_tick, int *ticks),
TP_ARGS(user_tick, ticks));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_SCHED_H */

View file

@ -492,23 +492,28 @@ EXPORT_SYMBOL_GPL(thread_group_cputime_adjusted);
#else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE: */
/*
* Account a single tick of CPU time.
* Account a single tick or a few ticks of CPU time.
* @p: the process that the CPU time gets accounted to
* @user_tick: indicates if the tick is a user or a system tick
*/
void account_process_tick(struct task_struct *p, int user_tick)
{
u64 cputime, steal;
int ticks = 1;
trace_android_vh_account_process_tick_gran(user_tick, &ticks);
if (!ticks)
return;
if (vtime_accounting_enabled_this_cpu())
return;
if (sched_clock_irqtime) {
irqtime_account_process_tick(p, user_tick, 1);
irqtime_account_process_tick(p, user_tick, ticks);
return;
}
cputime = TICK_NSEC;
cputime = TICK_NSEC * ticks;
steal = steal_account_process_time(ULONG_MAX);
if (steal >= cputime)

View file

@ -89,3 +89,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_pelt_multiplier);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_map_util_freq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_cpus_allowed_comm);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_setaffinity_early);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_account_process_tick_gran);