From: "Jan Beulich" Subject: Re: [PATCH v6 01/14] x86: add socket_to_cpumask Date: Fri, 24 Apr 2015 15:46:11 +0100 Message-ID: <553A73530200007800075A2F@mail.emea.novell.com> References: <1429782951-18813-1-git-send-email-chao.p.peng@linux.intel.com> <1429782951-18813-2-git-send-email-chao.p.peng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1429782951-18813-2-git-send-email-chao.p.peng@linux.intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Chao Peng Cc: wei.liu2@citrix.com, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, will.auld@intel.com, keir@xen.org, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org >>> On 23.04.15 at 11:55, wrote: > @@ -301,6 +304,8 @@ static void set_cpu_sibling_map(int cpu) > } > } > } > + > + cpumask_set_cpu(cpu, &socket_to_cpumask[cpu_to_socket(cpu)]); > } There is an early return path in this function, which you need to deal with. > @@ -717,6 +722,14 @@ void __init smp_prepare_cpus(unsigned int max_cpus) > > stack_base[0] = stack_start; > > + nr_sockets = DIV_ROUND_UP(nr_cpu_ids, boot_cpu_data.x86_max_cores * > + boot_cpu_data.x86_num_siblings); I think this is going to be problematic when there are more CPUs in the system than Xen can (or is told to) handle. > + ASSERT(nr_sockets > 0); Due to the DIV_ROUND_UP() I think this can never trigger. > + socket_to_cpumask = xzalloc_array(cpumask_t, nr_sockets); This is going to be very wasteful when Xen was built for very many CPUs. I think the array should be of cpumask_var_t type, and the array elements be initialized individually. > --- a/xen/include/asm-x86/smp.h > +++ b/xen/include/asm-x86/smp.h > @@ -58,6 +58,14 @@ int hard_smp_processor_id(void); > > void __stop_this_cpu(void); > > +/* > + * This value is considered to not change from the initial startup. > + * Otherwise all the relevant places need to be retrofitted. > + */ > +extern unsigned int nr_sockets; > + > +/* Representing HT and core siblings in each socket */ > +extern cpumask_t *socket_to_cpumask; > #endif /* !__ASSEMBLY__ */ Please retain the blank line before the #endif. Jan