Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934074AbbHLRKJ (ORCPT ); Wed, 12 Aug 2015 13:10:09 -0400 Received: from eu-smtp-delivery-143.mimecast.com ([146.101.78.143]:5937 "EHLO eu-smtp-delivery-143.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932302AbbHLRKH convert rfc822-to-8bit (ORCPT ); Wed, 12 Aug 2015 13:10:07 -0400 Message-ID: <55CB7DE7.9060403@arm.com> Date: Wed, 12 Aug 2015 18:09:59 +0100 From: Dietmar Eggemann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Peter Zijlstra , Morten Rasmussen CC: "mingo@redhat.com" , "vincent.guittot@linaro.org" , "daniel.lezcano@linaro.org" , "yuyang.du@intel.com" , "mturquette@baylibre.com" , "rjw@rjwysocki.net" , Juri Lelli , "sgurrappadi@nvidia.com" , "pang.xunlei@zte.com.cn" , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" Subject: Re: [RFCv5 PATCH 16/46] sched: Allocate and initialize energy data structures References: <1436293469-25707-1-git-send-email-morten.rasmussen@arm.com> <1436293469-25707-17-git-send-email-morten.rasmussen@arm.com> <20150812101721.GV19282@twins.programming.kicks-ass.net> In-Reply-To: <20150812101721.GV19282@twins.programming.kicks-ass.net> X-OriginalArrivalTime: 12 Aug 2015 17:10:01.0212 (UTC) FILETIME=[B93C53C0:01D0D521] X-MC-Unique: BS0Kgi_QRPe0arEeSzdf7A-1 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1588 Lines: 44 On 12/08/15 11:17, Peter Zijlstra wrote: > On Tue, Jul 07, 2015 at 07:23:59PM +0100, Morten Rasmussen wrote: >> @@ -6647,10 +6703,24 @@ static int __sdt_alloc(const struct cpumask *cpu_map) [...] >> @@ -6674,6 +6744,16 @@ static int __sdt_alloc(const struct cpumask *cpu_map) >> return -ENOMEM; >> >> *per_cpu_ptr(sdd->sgc, j) = sgc; >> + >> + sge = kzalloc_node(sizeof(struct sched_group_energy) + >> + nr_idle_states*sizeof(struct idle_state) + >> + nr_cap_states*sizeof(struct capacity_state), >> + GFP_KERNEL, cpu_to_node(j)); >> + >> + if (!sge) >> + return -ENOMEM; >> + >> + *per_cpu_ptr(sdd->sge, j) = sge; >> } >> } >> > > One more question, if fn() returns a full structure, why are we > allocating and copying the thing? Its all const read only data, right? > Yeah, that's not strictly necessary. I could get rid of all the allocation/copying/ and freeing code and just simply set sd->groups->sge = fn(cpu) in init_sched_energy(). Plus delete the atomic_t ref in struct sched_group_energy. In this case, should I still keep the check_sched_energy_data() function to verify that the scheduler got valid data via the struct sched_domain_topology_level table from the arch, i.e. to make sure that the per-cpu provided sd energy data is consistent for all cpus within the sched group cpumask? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/