From: Yuyang Du <yuyang.du@intel.com>
To: mingo@redhat.com, peterz@infradead.org,
rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org
Cc: arjan.van.de.ven@intel.com, len.brown@intel.com,
alan.cox@intel.com, mark.gross@intel.com,
morten.rasmussen@arm.com, vincent.guittot@linaro.org,
rajeev.d.muralidhar@intel.com, vishwesh.m.rudramuni@intel.com,
nicole.chalhoub@intel.com, ajaya.durg@intel.com,
harinarayanan.seshadri@intel.com, jacob.jun.pan@linux.intel.com,
fengguang.wu@intel.com, yuyang.du@intel.com
Subject: [RFC PATCH 06/12 v2] Attach CPU topology to specify each sched_domain's workload consolidation
Date: Mon, 12 May 2014 02:16:55 +0800 [thread overview]
Message-ID: <1399832221-8314-7-git-send-email-yuyang.du@intel.com> (raw)
In-Reply-To: <1399832221-8314-1-git-send-email-yuyang.du@intel.com>
Defined SD_WORKLOAD_CONSOLIDATION flag in sched_domain. When this flag is
set, the workload consolidation applies to that domain. In addition, a
consolidating_coeff is defined in sched_domain to specify the degree of
consolidation in that domain.
Signed-off-by: Yuyang Du <yuyang.du@intel.com>
---
include/linux/sched.h | 13 +++++++++++++
include/linux/topology.h | 16 ++++++++++++++++
kernel/sched/core.c | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 70 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 25f54c7..f3f7d4a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -877,6 +877,12 @@ enum cpu_idle_type {
#define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */
#define SD_NUMA 0x4000 /* cross-node balancing */
+#ifdef CONFIG_WORKLOAD_CONSOLIDATION
+#define SD_WORKLOAD_CONSOLIDATION 0x8000 /* Higher concurrency in front */
+#else
+#define SD_WORKLOAD_CONSOLIDATION 0
+#endif
+
extern int __weak arch_sd_sibiling_asym_packing(void);
struct sched_domain_attr {
@@ -960,6 +966,13 @@ struct sched_domain {
struct rcu_head rcu; /* used during destruction */
};
+#ifdef CONFIG_WORKLOAD_CONSOLIDATION
+ unsigned int total_groups; /* total groups number */
+ unsigned int group_number; /* this CPU's group sequence */
+ unsigned int consolidating_coeff; /* consolidating coefficient */
+ struct sched_group *first_group; /* ordered by CPU number */
+#endif
+
unsigned int span_weight;
/*
* Span of all CPUs in this domain.
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 7062330..334f83e 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -66,6 +66,16 @@ int arch_update_cpu_topology(void);
#define PENALTY_FOR_NODE_WITH_CPUS (1)
#endif
+#ifdef CONFIG_WORKLOAD_CONSOLIDATION
+#ifndef WORKLOAD_CONSOLIDATION_INIT
+#define WORKLOAD_CONSOLIDATION_INIT(n) .consolidating_coeff = (n),
+#endif
+#else
+#ifndef WORKLOAD_CONSOLIDATION_INIT
+#define WORKLOAD_CONSOLIDATION_INIT(n)
+#endif
+#endif
+
/*
* Below are the 3 major initializers used in building sched_domains:
* SD_SIBLING_INIT, for SMT domains
@@ -102,12 +112,14 @@ int arch_update_cpu_topology(void);
| 0*SD_SERIALIZE \
| 0*SD_PREFER_SIBLING \
| arch_sd_sibling_asym_packing() \
+ | 0*SD_WORKLOAD_CONSOLIDATION \
, \
.last_balance = jiffies, \
.balance_interval = 1, \
.smt_gain = 1178, /* 15% */ \
.max_newidle_lb_cost = 0, \
.next_decay_max_lb_cost = jiffies, \
+ WORKLOAD_CONSOLIDATION_INIT(0) \
}
#endif
#endif /* CONFIG_SCHED_SMT */
@@ -134,11 +146,13 @@ int arch_update_cpu_topology(void);
| 0*SD_SHARE_CPUPOWER \
| 1*SD_SHARE_PKG_RESOURCES \
| 0*SD_SERIALIZE \
+ | 1*SD_WORKLOAD_CONSOLIDATION \
, \
.last_balance = jiffies, \
.balance_interval = 1, \
.max_newidle_lb_cost = 0, \
.next_decay_max_lb_cost = jiffies, \
+ WORKLOAD_CONSOLIDATION_INIT(180) \
}
#endif
#endif /* CONFIG_SCHED_MC */
@@ -167,11 +181,13 @@ int arch_update_cpu_topology(void);
| 0*SD_SHARE_PKG_RESOURCES \
| 0*SD_SERIALIZE \
| 1*SD_PREFER_SIBLING \
+ | 1*SD_WORKLOAD_CONSOLIDATION \
, \
.last_balance = jiffies, \
.balance_interval = 1, \
.max_newidle_lb_cost = 0, \
.next_decay_max_lb_cost = jiffies, \
+ WORKLOAD_CONSOLIDATION_INIT(180) \
}
#endif
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0236455..cd92f2d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4843,7 +4843,11 @@ set_table_entry(struct ctl_table *entry,
static struct ctl_table *
sd_alloc_ctl_domain_table(struct sched_domain *sd)
{
+#ifdef CONFIG_WORKLOAD_CONSOLIDATION
+ struct ctl_table *table = sd_alloc_ctl_entry(15);
+#else
struct ctl_table *table = sd_alloc_ctl_entry(14);
+#endif
if (table == NULL)
return NULL;
@@ -4876,7 +4880,13 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
sizeof(long), 0644, proc_doulongvec_minmax, false);
set_table_entry(&table[12], "name", sd->name,
CORENAME_MAX_SIZE, 0444, proc_dostring, false);
+#ifdef CONFIG_WORKLOAD_CONSOLIDATION
+ set_table_entry(&table[13], "consolidating_coeff", &sd->consolidating_coeff,
+ sizeof(int), 0644, proc_dointvec, false);
+ /* &table[14] is terminator */
+#else
/* &table[13] is terminator */
+#endif
return table;
}
@@ -5497,6 +5507,33 @@ static void update_top_cache_domain(int cpu)
rcu_assign_pointer(per_cpu(sd_asym, cpu), sd);
}
+#ifdef CONFIG_WORKLOAD_CONSOLIDATION
+static void update_domain_extra_info(struct sched_domain *sd)
+{
+ while (sd) {
+ int i = 0, j = 0, first, min = INT_MAX;
+ struct sched_group *group;
+
+ group = sd->groups;
+ first = group_first_cpu(group);
+ do {
+ int k = group_first_cpu(group);
+ i += 1;
+ if (k < first)
+ j += 1;
+ if (k < min) {
+ sd->first_group = group;
+ min = k;
+ }
+ } while (group = group->next, group != sd->groups);
+
+ sd->total_groups = i;
+ sd->group_number = j;
+ sd = sd->parent;
+ }
+}
+#endif
+
/*
* Attach the domain 'sd' to 'cpu' as its base domain. Callers must
* hold the hotplug lock.
@@ -5545,6 +5582,10 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu)
destroy_sched_domains(tmp, cpu);
update_top_cache_domain(cpu);
+
+#ifdef CONFIG_WORKLOAD_CONSOLIDATION
+ update_domain_extra_info(sd);
+#endif
}
/* cpus with isolated domains */
--
1.7.9.5
next prev parent reply other threads:[~2014-05-11 18:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-11 18:16 [RFC PATCH 00/12 v2] A new CPU load metric for power-efficient scheduler: CPU ConCurrency Yuyang Du
2014-05-11 18:16 ` [RFC PATCH 01/12 v2] CONFIG for " Yuyang Du
2014-05-11 18:16 ` [RFC PATCH 02/12 v2] Init " Yuyang Du
2014-05-11 18:16 ` [RFC PATCH 03/12 v2] CPU ConCurrency calculation Yuyang Du
2014-05-11 18:16 ` [RFC PATCH 04/12 v2] CPU ConCurrency tracking Yuyang Du
2014-05-11 18:16 ` [RFC PATCH 05/12 v2] CONFIG for Workload Consolidation Yuyang Du
2014-05-11 18:16 ` Yuyang Du [this message]
2014-05-11 18:16 ` [RFC PATCH 07/12 v2] CPU ConCurrency API " Yuyang Du
2014-05-11 18:16 ` [RFC PATCH 08/12 v2] Intercept wakeup/fork/exec load balancing Yuyang Du
2014-05-11 18:16 ` [RFC PATCH 09/12 v2] Intercept idle balancing Yuyang Du
2014-05-11 18:16 ` [RFC PATCH 10/12 v2] Intercept periodic nohz " Yuyang Du
2014-05-11 18:17 ` [RFC PATCH 11/12 v2] Intercept periodic load balancing Yuyang Du
2014-05-11 18:17 ` [RFC PATCH 12/12 v2] Intercept RT scheduler Yuyang Du
2014-05-12 6:45 ` [RFC PATCH 00/12 v2] A new CPU load metric for power-efficient scheduler: CPU ConCurrency Peter Zijlstra
2014-05-12 1:28 ` Yuyang Du
2014-05-12 15:15 ` Peter Zijlstra
2014-05-13 13:23 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399832221-8314-7-git-send-email-yuyang.du@intel.com \
--to=yuyang.du@intel.com \
--cc=ajaya.durg@intel.com \
--cc=alan.cox@intel.com \
--cc=arjan.van.de.ven@intel.com \
--cc=fengguang.wu@intel.com \
--cc=harinarayanan.seshadri@intel.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.gross@intel.com \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=nicole.chalhoub@intel.com \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rajeev.d.muralidhar@intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vishwesh.m.rudramuni@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).