From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933885AbbHLRI4 (ORCPT ); Wed, 12 Aug 2015 13:08:56 -0400 Received: from eu-smtp-delivery-143.mimecast.com ([207.82.80.143]:62071 "EHLO eu-smtp-delivery-143.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932325AbbHLRIy convert rfc822-to-8bit (ORCPT ); Wed, 12 Aug 2015 13:08:54 -0400 Message-ID: <55CB7DA1.1070600@arm.com> Date: Wed, 12 Aug 2015 18:08:49 +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> <20150812100442.GU19282@twins.programming.kicks-ass.net> In-Reply-To: <20150812100442.GU19282@twins.programming.kicks-ass.net> X-OriginalArrivalTime: 12 Aug 2015 17:08:51.0475 (UTC) FILETIME=[8FAB4E30:01D0D521] X-MC-Unique: kiHu9LAyTZmp9OsRITS1zg-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 On 12/08/15 11:04, Peter Zijlstra wrote: > On Tue, Jul 07, 2015 at 07:23:59PM +0100, Morten Rasmussen wrote: >> + >> + sge->nr_idle_states = fn(cpu)->nr_idle_states; >> + sge->nr_cap_states = fn(cpu)->nr_cap_states; >> + memcpy(sge->idle_states, fn(cpu)->idle_states, >> + sge->nr_idle_states*sizeof(struct idle_state)); >> + memcpy(sge->cap_states, fn(cpu)->cap_states, >> + sge->nr_cap_states*sizeof(struct capacity_state)); > >> + if (fn && fn(j)) { >> + nr_idle_states = fn(j)->nr_idle_states; >> + nr_cap_states = fn(j)->nr_cap_states; >> + BUG_ON(!nr_idle_states || !nr_cap_states); >> + } > >> + for_each_cpu(i, &mask) { >> + int y; >> + >> + BUG_ON(fn(i)->nr_idle_states != fn(cpu)->nr_idle_states); >> + >> + for (y = 0; y < (fn(i)->nr_idle_states); y++) { >> + BUG_ON(fn(i)->idle_states[y].power != >> + fn(cpu)->idle_states[y].power); >> + } >> + >> + BUG_ON(fn(i)->nr_cap_states != fn(cpu)->nr_cap_states); >> + >> + for (y = 0; y < (fn(i)->nr_cap_states); y++) { >> + BUG_ON(fn(i)->cap_states[y].cap != >> + fn(cpu)->cap_states[y].cap); >> + BUG_ON(fn(i)->cap_states[y].power != >> + fn(cpu)->cap_states[y].power); >> + } >> + } >> +} > > Might it not make more sense to have: > > const struct blah *const blah = fn(); > > and use blah afterwards, instead of the repeated invocation of fn()? Absolutely! I can change this in the next release.