From: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: dmitry.adamushko@gmail.com, a.p.zijlstra@chello.nl,
dhaval@linux.vnet.ibm.com, linux-kernel@vger.kernel.org,
efault@gmx.de, skumar@linux.vnet.ibm.com,
Balbir Singh <balbir@in.ibm.com>, Dipankar <dipankar@in.ibm.com>
Subject: [Patch 4/5] sched: introduce a mutex and corresponding API to serialize access to doms_cur[] array
Date: Tue, 27 Nov 2007 10:51:21 +0530 [thread overview]
Message-ID: <20071127052121.GF20083@linux.vnet.ibm.com> (raw)
In-Reply-To: <20071127050652.GA20083@linux.vnet.ibm.com>
doms_cur[] array represents various scheduling domains which are mutually
exclusive. Currently cpusets code can modify this array (by calling
partition_sched_domains()) as a result of user modifying sched_load_balance
flag for various cpusets.
This patch introduces a mutex and corresponding API (only when
CONFIG_FAIR_GROUP_SCHED is defined) which allows a reader to safely read the
doms_cur[] array w/o worrying abt concurrent modifications to the array.
The fair group scheduler code (introduced in next patch of this series)
makes use of this mutex to walk thr' doms_cur[] array while rebalancing
shares of task groups across cpus.
Signed-off-by: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
---
kernel/sched.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+)
Index: current/kernel/sched.c
===================================================================
--- current.orig/kernel/sched.c
+++ current/kernel/sched.c
@@ -186,6 +186,9 @@ static struct cfs_rq *init_cfs_rq_p[NR_C
*/
static DEFINE_MUTEX(task_group_mutex);
+/* doms_cur_mutex serializes access to doms_cur[] array */
+static DEFINE_MUTEX(doms_cur_mutex);
+
/* Default task group.
* Every task in system belong to this group at bootup.
*/
@@ -236,11 +239,23 @@ static inline void unlock_task_group_lis
mutex_unlock(&task_group_mutex);
}
+static inline void lock_doms_cur(void)
+{
+ mutex_lock(&doms_cur_mutex);
+}
+
+static inline void unlock_doms_cur(void)
+{
+ mutex_unlock(&doms_cur_mutex);
+}
+
#else
static inline void set_task_cfs_rq(struct task_struct *p, unsigned int cpu) { }
static inline void lock_task_group_list(void) { }
static inline void unlock_task_group_list(void) { }
+static inline void lock_doms_cur(void) { }
+static inline void unlock_doms_cur(void) { }
#endif /* CONFIG_FAIR_GROUP_SCHED */
@@ -6547,6 +6562,8 @@ void partition_sched_domains(int ndoms_n
{
int i, j;
+ lock_doms_cur();
+
/* always unregister in case we don't destroy any domains */
unregister_sched_domain_sysctl();
@@ -6587,6 +6604,8 @@ match2:
ndoms_cur = ndoms_new;
register_sched_domain_sysctl();
+
+ unlock_doms_cur();
}
#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
--
Regards,
vatsa
next prev parent reply other threads:[~2007-11-27 5:08 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-19 12:27 [PATCH 0/2] sched: Group scheduler related patches Srivatsa Vaddagiri
2007-11-19 12:28 ` [PATCH 1/2] sched: Minor cleanups Srivatsa Vaddagiri
2007-11-19 13:08 ` Ingo Molnar
2007-11-19 15:01 ` Srivatsa Vaddagiri
2007-11-19 12:30 ` [PATCH 2/2] sched: Improve fairness of cpu allocation for task groups Srivatsa Vaddagiri
2007-11-19 13:12 ` Ingo Molnar
2007-11-19 15:03 ` Srivatsa Vaddagiri
2007-11-19 15:22 ` Ingo Molnar
2007-11-19 16:06 ` Srivatsa Vaddagiri
2007-11-19 19:00 ` Ingo Molnar
2007-11-26 5:00 ` [PATCH 0/4] sched: group scheduler related patches (V3) Srivatsa Vaddagiri
2007-11-26 5:02 ` [PATCH 1/4] sched: code cleanup Srivatsa Vaddagiri
2007-11-26 5:03 ` [PATCH 2/4] sched: minor fixes for group scheduler Srivatsa Vaddagiri
2007-11-26 5:05 ` [Patch 3/4 v1] sched: change how cpu load is calculated Srivatsa Vaddagiri
2007-11-26 5:06 ` [Patch 3/4 v2] " Srivatsa Vaddagiri
2007-11-26 5:09 ` [Patch 4/4] sched: Improve fairness of cpu bandwidth allocation for task groups Srivatsa Vaddagiri
2007-11-26 20:28 ` Ingo Molnar
2007-11-27 5:06 ` [Patch 0/5] sched: group scheduler related patches (V4) Srivatsa Vaddagiri
2007-11-27 5:08 ` [Patch 1/5] sched: code cleanup Srivatsa Vaddagiri
2007-11-27 5:09 ` [Patch 2/5] sched: minor fixes for group scheduler Srivatsa Vaddagiri
2007-11-27 5:11 ` [Patch 3/5 v1] sched: change how cpu load is calculated Srivatsa Vaddagiri
2007-11-27 5:12 ` [Patch 3/5 v2] " Srivatsa Vaddagiri
2007-11-27 5:21 ` Srivatsa Vaddagiri [this message]
2007-11-27 5:27 ` [Patch 5/5] sched: Improve fairness of cpu bandwidth allocation for task groups Srivatsa Vaddagiri
2007-11-27 11:09 ` [Patch 0/5] sched: group scheduler related patches (V4) Ingo Molnar
2007-11-27 11:42 ` Srivatsa Vaddagiri
2007-11-27 12:53 ` Ingo Molnar
2007-11-27 14:32 ` Srivatsa Vaddagiri
2007-11-26 20:29 ` [Patch 4/4] sched: Improve fairness of cpu bandwidth allocation for task groups Ingo Molnar
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=20071127052121.GF20083@linux.vnet.ibm.com \
--to=vatsa@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=balbir@in.ibm.com \
--cc=dhaval@linux.vnet.ibm.com \
--cc=dipankar@in.ibm.com \
--cc=dmitry.adamushko@gmail.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=skumar@linux.vnet.ibm.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