From: "Jan Beulich" Subject: Re: [PATCH v2 4/7] x86: add support for COS/CBM manangement Date: Mon, 23 Mar 2015 09:03:28 +0000 Message-ID: <550FE4F0020000780006C7DC@mail.emea.novell.com> References: <1426761695-12545-1-git-send-email-chao.p.peng@linux.intel.com> <1426761695-12545-5-git-send-email-chao.p.peng@linux.intel.com> <550C6358020000780006C338@mail.emea.novell.com> <20150323084745.GK5371@pengc-linux.bj.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150323084745.GK5371@pengc-linux.bj.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, 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.03.15 at 09:47, wrote: > On Fri, Mar 20, 2015 at 05:13:44PM +0000, Jan Beulich wrote: >> >>> On 19.03.15 at 11:41, wrote: >> > +static unsigned int get_socket_cpu(unsigned int socket) >> > +{ >> > + unsigned int cpu; >> > + >> > + for_each_online_cpu ( cpu ) >> > + if ( cpu_to_socket(cpu) == socket ) >> > + return cpu; >> > + return nr_cpu_ids; >> > +} >> >> This can be a rather long loop for a huge system. I think you need to >> find some better solution for this. > > Maintain a socket_cpu_map for each socket? Sounds no existed way. Perhaps your per-socket data structure could store a pointer to a suitable cpu_sibling_mask instance (and then the function above could simply be cpumask_any() on that mask). Of course it'll need updating when the owning CPU goes down, but thanks to you having the very sibling mask in your hands at that point, finding a replacement should be trivial. Jan