Add background notifiers for fixed oom score app. This is because,
ForegroundApps fixs cpu affinity for foreground app, but fixed oom score app
was excluded from cpu affinity update.
newly added notifiers are like below:
- RESOURCED_NOTIFIER_APP_BACKGRD_WITH_FIXED_OOM_SCORE for background status
Change-Id: I737c568c3bd18bc8fe436df16e8bcc370c6abf71
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
RESOURCED_NOTIFIER_APP_INACTIVE,
RESOURCED_NOTIFIER_APP_PRELAUNCH,
RESOURCED_NOTIFIER_APP_ANR,
RESOURCED_NOTIFIER_APP_INACTIVE,
RESOURCED_NOTIFIER_APP_PRELAUNCH,
RESOURCED_NOTIFIER_APP_ANR,
+
+ /**
+ * FIXME: It is temporary notifier to update cpu affinity for
+ * background app with fixed oom score.
+ */
+ RESOURCED_NOTIFIER_APP_BACKGRD_WITH_FIXED_OOM_SCORE,
/*
* start terminating application
*/
/*
* start terminating application
*/
+static int check_oom_score_for_backgrd(int pid, int oom_score_adj, struct proc_app_info *pai)
+{
+ struct proc_status ps;
+
+ ps.pid = pid;
+ ps.pai = pai;
+
+ if (oom_score_adj > OOMADJ_BACKGRD_UNLOCKED)
+ return 0;
+
+ if (ps.pid < 0)
+ return -1;
+
+ if (ps.pai == NULL)
+ return -1;
+
+ if (proc_oom_priority_is_oom_fixed_process(pid)) {
+ resourced_notify(RESOURCED_NOTIFIER_APP_BACKGRD_WITH_FIXED_OOM_SCORE, &ps);
+ return 0;
+ }
+
+ if (oom_score_adj == OOMADJ_BACKGRD_PERCEPTIBLE) {
+ resourced_notify(RESOURCED_NOTIFIER_APP_BACKGRD_WITH_FIXED_OOM_SCORE, &ps);
+ return 0;
+ }
+
+ return -1;
+}
+
int proc_set_backgrd(int pid, int oom_score_adj, struct proc_app_info *pai)
{
int ret = 0;
int proc_set_backgrd(int pid, int oom_score_adj, struct proc_app_info *pai)
{
int ret = 0;
ret = proc_backgrd_manage(pid, PROC_BACKGROUND_INACTIVE, OOMADJ_BACKGRD_UNLOCKED, pai);
break;
default:
ret = proc_backgrd_manage(pid, PROC_BACKGROUND_INACTIVE, OOMADJ_BACKGRD_UNLOCKED, pai);
break;
default:
- if (oom_score_adj > OOMADJ_BACKGRD_UNLOCKED)
- ret = 0;
- else
- ret = -1;
+ ret = check_oom_score_for_backgrd(pid, oom_score_adj, pai);
register_notifier(RESOURCED_NOTIFIER_WIDGET_FOREGRD, cpu_sched_app_foreground);
register_notifier(RESOURCED_NOTIFIER_WIDGET_BACKGRD, cpu_sched_app_background);
register_notifier(RESOURCED_NOTIFIER_WIDGET_FOREGRD, cpu_sched_app_foreground);
register_notifier(RESOURCED_NOTIFIER_WIDGET_BACKGRD, cpu_sched_app_background);
+
+ register_notifier(RESOURCED_NOTIFIER_APP_BACKGRD_WITH_FIXED_OOM_SCORE, cpu_sched_app_background);
}
// register_notifier(RESOURCED_NOTIFIER_RT_SCHEDULER, cpu_sched_rt_scheduler);
}
// register_notifier(RESOURCED_NOTIFIER_RT_SCHEDULER, cpu_sched_rt_scheduler);
unregister_notifier(RESOURCED_NOTIFIER_WIDGET_FOREGRD, cpu_sched_app_foreground);
unregister_notifier(RESOURCED_NOTIFIER_WIDGET_BACKGRD, cpu_sched_app_background);
unregister_notifier(RESOURCED_NOTIFIER_WIDGET_FOREGRD, cpu_sched_app_foreground);
unregister_notifier(RESOURCED_NOTIFIER_WIDGET_BACKGRD, cpu_sched_app_background);
+
+ unregister_notifier(RESOURCED_NOTIFIER_APP_BACKGRD_WITH_FIXED_OOM_SCORE, cpu_sched_app_background);
}
// unregister_notifier(RESOURCED_NOTIFIER_RT_SCHEDULER, cpu_sched_rt_scheduler);
}
// unregister_notifier(RESOURCED_NOTIFIER_RT_SCHEDULER, cpu_sched_rt_scheduler);