From: "Jan Beulich" Subject: Re: [PATCH v2 6/9] x86/intel_pstate: the main boby of the intel_pstate driver Date: Tue, 02 Jun 2015 07:32:39 +0100 Message-ID: <556D6A270200007800080015@mail.emea.novell.com> References: <1463125852-14155-1-git-send-email-wei.w.wang@intel.com> <55649803020000780007DF1A@mail.emea.novell.com> <286AC319A985734F985F78AFA26841F7979651@shsmsx102.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <286AC319A985734F985F78AFA26841F7979651@shsmsx102.ccr.corp.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: Wei W Wang Cc: "jinsong.liu@alibaba-inc.com" , "xen-devel@lists.xen.org" , "wei.liu2@citrix.com" , "ian.campbell@citrix.com" , "andrew.cooper3@citrix.com" List-Id: xen-devel@lists.xenproject.org >>> On 02.06.15 at 05:23, wrote: > On 26/05/2015 21:58, Jan Beulich wrote >> >>> On 13.05.16 at 09:50, wrote: >> > + id = x86_match_cpu(intel_pstate_cpu_ids); >> > + if (!id) >> > + return -ENODEV; >> > + >> > + cpu_info = (struct cpu_defaults *)id->driver_data; >> > + >> > + copy_pid_params(&cpu_info->pid_policy); >> > + copy_cpu_funcs(&cpu_info->funcs); >> > + if (intel_pstate_msrs_not_valid()) >> > + return -ENODEV; >> > + >> > + all_cpu_data = xzalloc_array(struct cpudata *, >> > + num_online_cpus()); >> >> This looks suspicious considering CPU hotplug, the more that this is the only >> place it gets allocated. > > I just found that "num_possible_cpus()" is currently not usable for the x86 > code. Can we use the Xen supported max possible CPUs - NR_CPUS (usually it's > 256), i.e. all_cpu_data = xzalloc_array(struct cpudata *, NR_CPUS) ? > Since each entry is just a pointer, this won't waste too much memory. If anything it would be nr_cpu_ids that you'd want to use here. (And no, assuming NR_CPUS to "usually" be 256 is wrong - this is merely the default, no more and no less). Jan