From: Dario Faggioli <dario.faggioli@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Keir Fraser <keir@xen.org>, Meng Xu <xumengpanda@gmail.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH v2 5/5] xen: sched_rt: print useful affinity info when dumping
Date: Tue, 17 Mar 2015 16:33:26 +0100 [thread overview]
Message-ID: <20150317153326.9867.76671.stgit@Solace.station> (raw)
In-Reply-To: <20150317152615.9867.48676.stgit@Solace.station>
In fact, printing the cpupool's CPU online mask
for each vCPU is just redundant, as that is the
same for all the vCPUs of all the domains in the
same cpupool, while hard affinity is already part
of the output of dumping domains info.
Instead, print the intersection between hard
affinity and online CPUs, which is --in case of this
scheduler-- the effective affinity always used for
the vCPUs.
This change also takes the chance to add a scratch
cpumask area, to avoid having to either put one
(more) cpumask_t on the stack, or dynamically
allocate it within the dumping routine. (The former
being bad because hypervisor stack size is limited,
the latter because dynamic allocations can fail, if
the hypervisor was built for a large enough number
of CPUs.)
Such scratch area can be used to kill most of the
cpumasks{_var}_t local variables in other functions
in the file, but that is *NOT* done in this chage.
Finally, convert the file to use keyhandler scratch,
instead of open coded string buffers.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Meng Xu <xumengpanda@gmail.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
---
Changes from v1:
* improved changelog;
* made a local variable to point to the correct
scratch mask, as suggested during review.
---
xen/common/sched_rt.c | 42 +++++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 9 deletions(-)
diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c
index 7c39a9e..ec28956 100644
--- a/xen/common/sched_rt.c
+++ b/xen/common/sched_rt.c
@@ -124,6 +124,12 @@
#define TRC_RTDS_BUDGET_REPLENISH TRC_SCHED_CLASS_EVT(RTDS, 4)
#define TRC_RTDS_SCHED_TASKLET TRC_SCHED_CLASS_EVT(RTDS, 5)
+ /*
+ * Useful to avoid too many cpumask_var_t on the stack.
+ */
+static cpumask_t **_cpumask_scratch;
+#define cpumask_scratch _cpumask_scratch[smp_processor_id()]
+
/*
* Systme-wide private data, include global RunQueue/DepletedQ
* Global lock is referenced by schedule_data.schedule_lock from all
@@ -218,8 +224,7 @@ __q_elem(struct list_head *elem)
static void
rt_dump_vcpu(const struct scheduler *ops, const struct rt_vcpu *svc)
{
- char cpustr[1024];
- cpumask_t *cpupool_mask;
+ cpumask_t *cpupool_mask, *mask;
ASSERT(svc != NULL);
/* idle vcpu */
@@ -229,10 +234,22 @@ rt_dump_vcpu(const struct scheduler *ops, const struct rt_vcpu *svc)
return;
}
- cpumask_scnprintf(cpustr, sizeof(cpustr), svc->vcpu->cpu_hard_affinity);
+ /*
+ * We can't just use 'cpumask_scratch' because the dumping can
+ * happen from a pCPU outside of this scheduler's cpupool, and
+ * hence it's not right to use the pCPU's scratch mask (which
+ * may even not exist!). On the other hand, it is safe to use
+ * svc->vcpu->processor's own scratch space, since we hold the
+ * runqueue lock.
+ */
+ mask = _cpumask_scratch[svc->vcpu->processor];
+
+ cpupool_mask = cpupool_scheduler_cpumask(svc->vcpu->domain->cpupool);
+ cpumask_and(mask, cpupool_mask, svc->vcpu->cpu_hard_affinity);
+ cpulist_scnprintf(keyhandler_scratch, sizeof(keyhandler_scratch), mask);
printk("[%5d.%-2u] cpu %u, (%"PRI_stime", %"PRI_stime"),"
" cur_b=%"PRI_stime" cur_d=%"PRI_stime" last_start=%"PRI_stime"\n"
- " \t\t onQ=%d runnable=%d cpu_hard_affinity=%s ",
+ " \t\t onQ=%d runnable=%d flags=%x effective hard_affinity=%s\n",
svc->vcpu->domain->domain_id,
svc->vcpu->vcpu_id,
svc->vcpu->processor,
@@ -243,11 +260,8 @@ rt_dump_vcpu(const struct scheduler *ops, const struct rt_vcpu *svc)
svc->last_start,
__vcpu_on_q(svc),
vcpu_runnable(svc->vcpu),
- cpustr);
- memset(cpustr, 0, sizeof(cpustr));
- cpupool_mask = cpupool_scheduler_cpumask(svc->vcpu->domain->cpupool);
- cpumask_scnprintf(cpustr, sizeof(cpustr), cpupool_mask);
- printk("cpupool=%s\n", cpustr);
+ svc->flags,
+ keyhandler_scratch);
}
static void
@@ -409,6 +423,10 @@ rt_init(struct scheduler *ops)
if ( prv == NULL )
return -ENOMEM;
+ _cpumask_scratch = xmalloc_array(cpumask_var_t, nr_cpu_ids);
+ if ( _cpumask_scratch == NULL )
+ return -ENOMEM;
+
spin_lock_init(&prv->lock);
INIT_LIST_HEAD(&prv->sdom);
INIT_LIST_HEAD(&prv->runq);
@@ -426,6 +444,7 @@ rt_deinit(const struct scheduler *ops)
{
struct rt_private *prv = rt_priv(ops);
+ xfree(_cpumask_scratch);
xfree(prv);
}
@@ -443,6 +462,9 @@ rt_alloc_pdata(const struct scheduler *ops, int cpu)
per_cpu(schedule_data, cpu).schedule_lock = &prv->lock;
spin_unlock_irqrestore(&prv->lock, flags);
+ if ( !alloc_cpumask_var(&_cpumask_scratch[cpu]) )
+ return NULL;
+
/* 1 indicates alloc. succeed in schedule.c */
return (void *)1;
}
@@ -462,6 +484,8 @@ rt_free_pdata(const struct scheduler *ops, void *pcpu, int cpu)
sd->schedule_lock = &sd->_lock;
spin_unlock_irqrestore(&prv->lock, flags);
+
+ free_cpumask_var(_cpumask_scratch[cpu]);
}
static void *
next prev parent reply other threads:[~2015-03-17 15:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 15:32 [PATCH v2 0/5] Improving dumping of scheduler related info Dario Faggioli
2015-03-17 15:32 ` [PATCH v2 1/5] xen: sched_rt: avoid ASSERT()ing on runq dump if there are no domains Dario Faggioli
2015-03-17 15:33 ` [PATCH v2 2/5] xen: rework locking for dump of scheduler info (debug-key r) Dario Faggioli
2015-03-30 13:34 ` George Dunlap
2015-03-17 15:33 ` [PATCH v2 3/5] xen: print online pCPUs and free pCPUs when dumping Dario Faggioli
2015-03-18 4:29 ` Juergen Gross
2015-03-18 11:03 ` Jan Beulich
2015-03-18 11:26 ` Dario Faggioli
2015-03-17 15:33 ` [PATCH v2 4/5] xen: sched_credit2: more info " Dario Faggioli
2015-03-17 15:33 ` Dario Faggioli [this message]
2015-03-18 1:09 ` [PATCH v2 5/5] xen: sched_rt: print useful affinity " Meng Xu
2015-03-30 13:47 ` George Dunlap
2015-03-31 16:58 ` Dario Faggioli
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=20150317153326.9867.76671.stgit@Solace.station \
--to=dario.faggioli@citrix.com \
--cc=JBeulich@suse.com \
--cc=george.dunlap@eu.citrix.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xen.org \
--cc=xumengpanda@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.