From: Juergen Gross <juergen.gross@ts.fujitsu.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] Avoid panic when adjusting sedf parameters
Date: Thu, 17 Nov 2011 15:37:49 +0100 [thread overview]
Message-ID: <fabc84feab2c1a6d2277.1321540669@nehalem1> (raw)
[-- Attachment #1: Type: text/plain, Size: 507 bytes --]
When using sedf scheduler in a cpupool the system might panic when setting
sedf scheduling parameters for a domain.
Introduces for_each_domain_in_cpupool macro as it is usable 4 times now.
Add appropriate locking in cpupool_unassign_cpu().
Signed-off-by: juergen.gross@ts.fujitsu.com
4 files changed, 28 insertions(+), 11 deletions(-)
xen/common/cpupool.c | 6 +++---
xen/common/sched_sedf.c | 8 ++++----
xen/common/schedule.c | 5 +----
xen/include/xen/sched.h | 20 ++++++++++++++++++++
[-- Attachment #2: xen-staging.hg.patch --]
[-- Type: text/x-patch, Size: 4348 bytes --]
# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1321540598 -3600
# Node ID fabc84feab2c1a6d22777cdbc670f65508e6fc46
# Parent dbdc840f8f62db58321b5009e5e0f7833066386f
Avoid panic when adjusting sedf parameters
When using sedf scheduler in a cpupool the system might panic when setting
sedf scheduling parameters for a domain.
Introduces for_each_domain_in_cpupool macro as it is usable 4 times now.
Add appropriate locking in cpupool_unassign_cpu().
Signed-off-by: juergen.gross@ts.fujitsu.com
diff -r dbdc840f8f62 -r fabc84feab2c xen/common/cpupool.c
--- a/xen/common/cpupool.c Wed Nov 16 18:21:14 2011 +0000
+++ b/xen/common/cpupool.c Thu Nov 17 15:36:38 2011 +0100
@@ -309,10 +309,9 @@ int cpupool_unassign_cpu(struct cpupool
if ( (c->n_dom > 0) && (cpumask_weight(c->cpu_valid) == 1) &&
(cpu != cpupool_moving_cpu) )
{
- for_each_domain(d)
+ rcu_read_lock(&domlist_read_lock);
+ for_each_domain_in_cpupool(d, c)
{
- if ( d->cpupool != c )
- continue;
if ( !d->is_dying )
{
ret = -EBUSY;
@@ -327,6 +326,7 @@ int cpupool_unassign_cpu(struct cpupool
}
cpupool0->n_dom++;
}
+ rcu_read_unlock(&domlist_read_lock);
if ( ret )
goto out;
}
diff -r dbdc840f8f62 -r fabc84feab2c xen/common/sched_sedf.c
--- a/xen/common/sched_sedf.c Wed Nov 16 18:21:14 2011 +0000
+++ b/xen/common/sched_sedf.c Thu Nov 17 15:36:38 2011 +0100
@@ -1304,6 +1304,8 @@ static void sedf_dump_cpu_state(const st
rcu_read_lock(&domlist_read_lock);
for_each_domain ( d )
{
+ if ( (d->cpupool ? d->cpupool->sched : &sched_sedf_def) != ops )
+ continue;
for_each_vcpu(d, ed)
{
if ( !__task_on_queue(ed) && (ed->processor == i) )
@@ -1335,10 +1337,8 @@ static int sedf_adjust_weights(struct cp
/* Sum across all weights. */
rcu_read_lock(&domlist_read_lock);
- for_each_domain( d )
+ for_each_domain_in_cpupool( d, c )
{
- if ( c != d->cpupool )
- continue;
for_each_vcpu( d, p )
{
if ( (cpu = p->processor) >= nr_cpus )
@@ -1367,7 +1367,7 @@ static int sedf_adjust_weights(struct cp
/* Adjust all slices (and periods) to the new weight. */
rcu_read_lock(&domlist_read_lock);
- for_each_domain( d )
+ for_each_domain_in_cpupool( d, c )
{
for_each_vcpu ( d, p )
{
diff -r dbdc840f8f62 -r fabc84feab2c xen/common/schedule.c
--- a/xen/common/schedule.c Wed Nov 16 18:21:14 2011 +0000
+++ b/xen/common/schedule.c Thu Nov 17 15:36:38 2011 +0100
@@ -538,11 +538,8 @@ int cpu_disable_scheduler(unsigned int c
if ( c == NULL )
return ret;
- for_each_domain ( d )
+ for_each_domain_in_cpupool ( d, c )
{
- if ( d->cpupool != c )
- continue;
-
affinity_broken = 0;
for_each_vcpu ( d, v )
diff -r dbdc840f8f62 -r fabc84feab2c xen/include/xen/sched.h
--- a/xen/include/xen/sched.h Wed Nov 16 18:21:14 2011 +0000
+++ b/xen/include/xen/sched.h Thu Nov 17 15:36:38 2011 +0100
@@ -564,10 +564,30 @@ extern struct domain *domain_list;
extern struct domain *domain_list;
/* Caller must hold the domlist_read_lock or domlist_update_lock. */
+static inline struct domain *first_domain_in_cpupool( struct cpupool *c)
+{
+ struct domain *d;
+ for (d = rcu_dereference(domain_list); d && d->cpupool != c;
+ d = rcu_dereference(d->next_in_list));
+ return d;
+}
+static inline struct domain *next_domain_in_cpupool(
+ struct domain *d, struct cpupool *c)
+{
+ for (d = rcu_dereference(d->next_in_list); d && d->cpupool != c;
+ d = rcu_dereference(d->next_in_list));
+ return d;
+}
+
#define for_each_domain(_d) \
for ( (_d) = rcu_dereference(domain_list); \
(_d) != NULL; \
(_d) = rcu_dereference((_d)->next_in_list )) \
+
+#define for_each_domain_in_cpupool(_d,_c) \
+ for ( (_d) = first_domain_in_cpupool(_c); \
+ (_d) != NULL; \
+ (_d) = next_domain_in_cpupool((_d), (_c)))
#define for_each_vcpu(_d,_v) \
for ( (_v) = (_d)->vcpu ? (_d)->vcpu[0] : NULL; \
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2011-11-17 14:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-17 14:37 Juergen Gross [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-11-17 13:03 [PATCH] Avoid panic when adjusting sedf parameters Juergen Gross
2011-11-17 13:30 ` Jan Beulich
2011-11-17 13:48 ` Keir Fraser
2011-11-17 14:02 ` Juergen Gross
2011-11-17 13:52 ` Keir Fraser
2011-11-17 14:04 ` Juergen Gross
2011-11-17 14:32 ` Jan Beulich
2011-11-17 14:41 ` Juergen Gross
2011-11-17 14:29 ` Jan Beulich
2011-11-17 12:33 Juergen Gross
2011-11-17 12:43 ` George Dunlap
2011-11-17 13:07 ` Juergen Gross
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=fabc84feab2c1a6d2277.1321540669@nehalem1 \
--to=juergen.gross@ts.fujitsu.com \
--cc=xen-devel@lists.xensource.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).