From: "Yang, Xiaowei" <xiaowei.yang@intel.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH] Fix cpu selection at the time vCPU allocation
Date: Fri, 06 Mar 2009 16:33:56 +0800 [thread overview]
Message-ID: <49B0DFF4.7000908@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 190 bytes --]
After cpu_[online/offline], set bits in cpu_online_map could be not
continuous. Use cycle_cpu() to pick the next one.
Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
Thanks,
xiaowei
[-- Attachment #2: cycle_cpu.patch --]
[-- Type: text/x-patch, Size: 3012 bytes --]
diff -r 310c85c9cb86 xen/common/domctl.c
--- a/xen/common/domctl.c Mon Mar 02 16:24:50 2009 +0000
+++ b/xen/common/domctl.c Fri Mar 06 10:07:25 2009 +0800
@@ -428,7 +428,7 @@
cpu = (i == 0) ?
default_vcpu0_location() :
- (d->vcpu[i-1]->processor + 1) % num_online_cpus();
+ cycle_cpu(d->vcpu[i-1]->processor, cpu_online_map);
if ( alloc_vcpu(d, i, cpu) == NULL )
goto maxvcpu_out;
diff -r 310c85c9cb86 xen/common/sched_credit.c
--- a/xen/common/sched_credit.c Mon Mar 02 16:24:50 2009 +0000
+++ b/xen/common/sched_credit.c Fri Mar 06 10:07:25 2009 +0800
@@ -248,15 +248,6 @@
static struct csched_private csched_priv;
static void csched_tick(void *_cpu);
-
-static inline int
-__cycle_cpu(int cpu, const cpumask_t *mask)
-{
- int nxt = next_cpu(cpu, *mask);
- if (nxt == NR_CPUS)
- nxt = first_cpu(*mask);
- return nxt;
-}
static inline int
__vcpu_on_runq(struct csched_vcpu *svc)
@@ -428,7 +419,7 @@
cpus_and(cpus, cpu_online_map, vc->cpu_affinity);
cpu = cpu_isset(vc->processor, cpus)
? vc->processor
- : __cycle_cpu(vc->processor, &cpus);
+ : cycle_cpu(vc->processor, cpus);
ASSERT( !cpus_empty(cpus) && cpu_isset(cpu, cpus) );
/*
@@ -454,7 +445,7 @@
cpumask_t nxt_idlers;
int nxt;
- nxt = __cycle_cpu(cpu, &cpus);
+ nxt = cycle_cpu(cpu, cpus);
if ( cpu_isset(cpu, cpu_core_map[nxt]) )
{
@@ -1128,7 +1119,7 @@
while ( !cpus_empty(workers) )
{
- peer_cpu = __cycle_cpu(peer_cpu, &workers);
+ peer_cpu = cycle_cpu(peer_cpu, workers);
cpu_clear(peer_cpu, workers);
/*
diff -r 310c85c9cb86 xen/include/xen/cpumask.h
--- a/xen/include/xen/cpumask.h Mon Mar 02 16:24:50 2009 +0000
+++ b/xen/include/xen/cpumask.h Fri Mar 06 10:07:25 2009 +0800
@@ -38,6 +38,8 @@
*
* int first_cpu(mask) Number lowest set bit, or NR_CPUS
* int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
+ * int last_cpu(mask) Number highest set bit, or NR_CPUS
+ * int cycle_cpu(cpu, mask) Next cpu cycling from 'cpu', or NR_CPUS
*
* cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set
* CPU_MASK_ALL Initializer - all bits set
@@ -225,10 +227,21 @@
#define last_cpu(src) __last_cpu(&(src), NR_CPUS)
static inline int __last_cpu(const cpumask_t *srcp, int nbits)
{
- int cpu, pcpu = NR_CPUS;
- for (cpu = first_cpu(*srcp); cpu < NR_CPUS; cpu = next_cpu(cpu, *srcp))
+ int cpu, pcpu = nbits;
+ for (cpu = __first_cpu(srcp, nbits);
+ cpu < nbits;
+ cpu = __next_cpu(cpu, srcp, nbits))
pcpu = cpu;
return pcpu;
+}
+
+#define cycle_cpu(n, src) __cycle_cpu((n), &(src), NR_CPUS)
+static inline int __cycle_cpu(int n, const cpumask_t *srcp, int nbits)
+{
+ int nxt = __next_cpu(n, srcp, nbits);
+ if (nxt == nbits)
+ nxt = __first_cpu(srcp, nbits);
+ return nxt;
}
#define cpumask_of_cpu(cpu) \
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
reply other threads:[~2009-03-06 8:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=49B0DFF4.7000908@intel.com \
--to=xiaowei.yang@intel.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 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.