From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v12 for-xen-4.5 11/20] x86/VPMU: Interface for setting PMU mode and flags Date: Mon, 29 Sep 2014 09:56:50 -0400 Message-ID: <54296522.7060001@oracle.com> References: <1411673336-32736-1-git-send-email-boris.ostrovsky@oracle.com> <1411673336-32736-12-git-send-email-boris.ostrovsky@oracle.com> <2307302.U8WBSjsMcB@amur> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <2307302.U8WBSjsMcB@amur> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dietmar Hahn , xen-devel@lists.xen.org Cc: kevin.tian@intel.com, keir@xen.org, jbeulich@suse.com, jun.nakajima@intel.com, andrew.cooper3@citrix.com, tim@xen.org, Aravind.Gopalakrishnan@amd.com, suravee.suthikulpanit@amd.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On 09/29/2014 09:25 AM, Dietmar Hahn wrote: > +static int vpmu_force_context_switch(void) > +{ > + unsigned i, j, allbutself_num, mycpu; > + static s_time_t start, now; > + struct tasklet **sync_task; > + struct vcpu *curr_vcpu = current; > + int ret = 0; > + > + allbutself_num = num_online_cpus() - 1; > + > + sync_task = xzalloc_array(struct tasklet *, allbutself_num); > + if ( !sync_task ) > + { > + printk(XENLOG_WARNING "vpmu_force_context_switch: out of memory\n"); > + return -ENOMEM; > + } > + > + for ( i = 0; i < allbutself_num; i++ ) > + { > + sync_task[i] = xmalloc(struct tasklet); > + if ( sync_task[i] == NULL ) > + { > + printk(XENLOG_WARNING "vpmu_force_context_switch: out of memory\n"); > + ret = -ENOMEM; > + goto out; > + } > + tasklet_init(sync_task[i], vpmu_sched_checkin, 0); > Only a question of understanding. > Is there a special reason not to use a single memory allocation > except for memory fragmentation on systems with a large number of cpus? > > struct tasklet *sync_task; > sync_task = xmalloc(sizeof(struct tasklet) * allbutself_num); Exactly because of fragmentation -- this will avoid asking for more than a page during runtime. I, in fact, originally had it allocated as a single chunk, just as you suggested above, but Jan asked this to be split into smaller, sub-page pieces. -boris