From 759f7060a5bfd8cc991171ed6bffe7d43f178920 Mon Sep 17 00:00:00 2001 From: Park Bumgyu Date: Mon, 13 Aug 2018 15:21:27 +0900 Subject: [PATCH] [RAMEN9610-9421][COMMON] sched: ems: introduce ems service Change-Id: I6e0cc8b8db43035c5c933ed292f443c9a67e4520 Signed-off-by: Park Bumgyu --- include/linux/ems.h | 15 ---------- include/linux/ems_service.h | 30 +++++++++++++++++++ kernel/sched/ems/Makefile | 1 + kernel/sched/ems/service.c | 58 +++++++++++++++++++++++++++++++++++++ kernel/sched/ems/st_addon.c | 33 --------------------- kernel/sched/tune.c | 25 +--------------- 6 files changed, 90 insertions(+), 72 deletions(-) create mode 100644 include/linux/ems_service.h create mode 100644 kernel/sched/ems/service.c diff --git a/include/linux/ems.h b/include/linux/ems.h index b0f1252f877f..11cc63f9fc54 100644 --- a/include/linux/ems.h +++ b/include/linux/ems.h @@ -15,16 +15,6 @@ #include #include -#ifdef CONFIG_SCHED_TUNE -enum stune_group { - STUNE_ROOT, - STUNE_FOREGROUND, - STUNE_BACKGROUND, - STUNE_TOPAPP, - STUNE_GROUP_COUNT, -}; -#endif - struct gb_qos_request { struct plist_node node; char *name; @@ -75,9 +65,6 @@ extern void update_lbt_overutil(int cpu, unsigned long capacity); /* global boost */ extern void gb_qos_update_request(struct gb_qos_request *req, u32 new_value); -/* prefer perf */ -extern void request_kernel_prefer_perf(int grp_idx, int enable); - /* task band */ extern void sync_band(struct task_struct *p, bool join); extern void newbie_join_band(struct task_struct *newbie); @@ -116,8 +103,6 @@ static inline void update_lbt_overutil(int cpu, unsigned long capacity) { } static inline void gb_qos_update_request(struct gb_qos_request *req, u32 new_value) { } -static inline void request_kernel_prefer_perf(int grp_idx, int enable) { } - static inline void sync_band(struct task_struct *p, bool join) { } static inline void newbie_join_band(struct task_struct *newbie) { } static inline int alloc_bands(void) diff --git a/include/linux/ems_service.h b/include/linux/ems_service.h new file mode 100644 index 000000000000..b7dbaf042a46 --- /dev/null +++ b/include/linux/ems_service.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +enum stune_group { + STUNE_ROOT, + STUNE_FOREGROUND, + STUNE_BACKGROUND, + STUNE_TOPAPP, + STUNE_RT, + STUNE_GROUP_COUNT, +}; + +#ifdef CONFIG_SCHED_EMS +/* prefer perf */ +extern int kernel_prefer_perf(int grp_idx); +extern void request_kernel_prefer_perf(int grp_idx, int enable); +#else +static inline int kernel_prefer_perf(int grp_idx) { } +static inline void request_kernel_prefer_perf(int grp_idx, int enable) { } +#endif diff --git a/kernel/sched/ems/Makefile b/kernel/sched/ems/Makefile index 8537cfc6240f..7eb65f5566e6 100644 --- a/kernel/sched/ems/Makefile +++ b/kernel/sched/ems/Makefile @@ -1,4 +1,5 @@ obj-y += core.o pcf.o global_boost.o lbt.o ontime.o energy.o init_util.o band.o +obj-y += service.o obj-$(CONFIG_SCHED_TUNE) += st_addon.o obj-$(CONFIG_FREQVAR_TUNE) += freqvar_tune.o diff --git a/kernel/sched/ems/service.c b/kernel/sched/ems/service.c new file mode 100644 index 000000000000..50d77db1f240 --- /dev/null +++ b/kernel/sched/ems/service.c @@ -0,0 +1,58 @@ +/* + * Services for Exynos Mobile Scheduler + * + * Copyright (C) 2018 Samsung Electronics Co., Ltd + * Park Bumgyu + */ + +#include +#include + +/********************************************************************** + * Kernel Prefer Perf * + **********************************************************************/ +static atomic_t kernel_prefer_perf_req[STUNE_GROUP_COUNT]; +int kernel_prefer_perf(int grp_idx) +{ + if (grp_idx >= STUNE_GROUP_COUNT) + return -EINVAL; + + return atomic_read(&kernel_prefer_perf_req[grp_idx]); +} + +void request_kernel_prefer_perf(int grp_idx, int value) +{ + if (grp_idx >= STUNE_GROUP_COUNT) + return; + + atomic_set(&kernel_prefer_perf_req[grp_idx], value); +} + +static ssize_t show_prefer_perf(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + int i, ret = 0; + + /* shows the prefer_perf value of all schedtune groups */ + for (i = 0; i < STUNE_GROUP_COUNT; i++) + ret += snprintf(buf + ret, 10, "%d ", kernel_prefer_perf(i)); + + ret += snprintf(buf + ret, 10, "\n"); + + return ret; +} + +static struct kobj_attribute prefer_perf_attr = +__ATTR(kernel_prefer_perf, 0444, show_prefer_perf, NULL); + +static int __init init_service(void) +{ + int ret; + + ret = sysfs_create_file(ems_kobj, &prefer_perf_attr.attr); + if (ret) + pr_err("%s: faile to create sysfs file\n", __func__); + + return 0; +} +late_initcall(init_service); diff --git a/kernel/sched/ems/st_addon.c b/kernel/sched/ems/st_addon.c index ae1b130955d5..2f52d9b20226 100644 --- a/kernel/sched/ems/st_addon.c +++ b/kernel/sched/ems/st_addon.c @@ -29,24 +29,6 @@ int prefer_perf_cpu(struct task_struct *p) return select_perf_cpu(p); } -int kernel_prefer_perf(int grp_idx); -static ssize_t show_prefer_perf(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - int i, ret = 0; - - /* shows the prefer_perf value of all schedtune groups */ - for (i = 0; i < STUNE_GROUP_COUNT; i++) - ret += snprintf(buf + ret, 10, "%d ", kernel_prefer_perf(i)); - - ret += snprintf(buf + ret, 10, "\n"); - - return ret; -} - -static struct kobj_attribute prefer_perf_attr = -__ATTR(kernel_prefer_perf, 0444, show_prefer_perf, NULL); - /********************************************************************** * Prefer Idle * **********************************************************************/ @@ -149,18 +131,3 @@ int prefer_idle_cpu(struct task_struct *p) return select_idle_cpu(p); } - -/********************************************************************** - * Sysfs interface * - **********************************************************************/ -static int __init init_st_addon_sysfs(void) -{ - int ret; - - ret = sysfs_create_file(ems_kobj, &prefer_perf_attr.attr); - if (ret) - pr_err("%s: faile to create sysfs file\n", __func__); - - return 0; -} -late_initcall(init_st_addon_sysfs); diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c index 293011d3a825..7857d4b99b5e 100644 --- a/kernel/sched/tune.c +++ b/kernel/sched/tune.c @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -440,30 +441,6 @@ int schedtune_prefer_idle(struct task_struct *p) return prefer_idle; } -#ifdef CONFIG_SCHED_EMS -static atomic_t kernel_prefer_perf_req[BOOSTGROUPS_COUNT]; -int kernel_prefer_perf(int grp_idx) -{ - if (grp_idx >= BOOSTGROUPS_COUNT) - return -EINVAL; - - return atomic_read(&kernel_prefer_perf_req[grp_idx]); -} - -void request_kernel_prefer_perf(int grp_idx, int enable) -{ - if (grp_idx >= BOOSTGROUPS_COUNT) - return; - - if (enable) - atomic_inc(&kernel_prefer_perf_req[grp_idx]); - else - BUG_ON(atomic_dec_return(&kernel_prefer_perf_req[grp_idx]) < 0); -} -#else -static inline int kernel_prefer_perf(int grp_idx) { return 0; } -#endif - int schedtune_prefer_perf(struct task_struct *p) { struct schedtune *st; -- 2.20.1