Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752847AbbD3URz (ORCPT ); Thu, 30 Apr 2015 16:17:55 -0400 Received: from eu-smtp-delivery-143.mimecast.com ([146.101.78.143]:44296 "EHLO eu-smtp-delivery-143.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751720AbbD3URw convert rfc822-to-8bit (ORCPT ); Thu, 30 Apr 2015 16:17:52 -0400 Message-ID: <55428DEF.7080801@arm.com> Date: Thu, 30 Apr 2015 21:17:51 +0100 From: Dietmar Eggemann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "pang.xunlei@zte.com.cn" , Morten Rasmussen CC: Juri Lelli , "linux-kernel@vger.kernel.org" , "linux-kernel-owner@vger.kernel.org" , "mingo@redhat.com" , "mturquette@linaro.org" , "nico@linaro.org" , "peterz@infradead.org" , "preeti@linux.vnet.ibm.com" , "rjw@rjwysocki.net" , "vincent.guittot@linaro.org" , "yuyang.du@intel.com" Subject: Re: [RFCv3 PATCH 37/48] sched: Determine the current sched_group idle-state References: <1423074685-6336-1-git-send-email-morten.rasmussen@arm.com> <1423074685-6336-38-git-send-email-morten.rasmussen@arm.com> In-Reply-To: X-OriginalArrivalTime: 30 Apr 2015 20:17:48.0715 (UTC) FILETIME=[BA3AD7B0:01D08382] X-MC-Unique: d4WxeU-3SCWFBg-wETlIPQ-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: 2989 Lines: 87 On 30/04/15 06:12, pang.xunlei@zte.com.cn wrote: > linux-kernel-owner@vger.kernel.org wrote 2015-02-05 AM 02:31:14: > >> Morten Rasmussen >> >> [RFCv3 PATCH 37/48] sched: Determine the current sched_group idle-state >> >> To estimate the energy consumption of a sched_group in >> sched_group_energy() it is necessary to know which idle-state the group >> is in when it is idle. For now, it is assumed that this is the current >> idle-state (though it might be wrong). Based on the individual cpu >> idle-states group_idle_state() finds the group idle-state. [...] >> +static int group_idle_state(struct sched_group *sg) >> +{ >> + struct sched_group_energy *sge = sg->sge; >> + int shallowest_state = sge->idle_states_below + sge->nr_idle_states; >> + int i; >> + >> + for_each_cpu(i, sched_group_cpus(sg)) { >> + int cpuidle_idx = idle_get_state_idx(cpu_rq(i)); >> + int group_idx = cpuidle_idx - sge->idle_states_below + 1; > > So cpuidle_idx==0 for core-level(2 C-States for example) groups, it > returns 1? Yes. > > What does this mean? So for ARM TC2 and CPU0 (Cortex A15, big) for example: # cat /sys/devices/system/cpu/cpu0/cpuidle/state*/name WFI [cpuidle_idx=0] cluster-sleep-b [cpuidle_idx=1] group_idx is the system C state re-indexed to the sd (e.g.on MC level WFI is group idx 1 and on DIE level it's group idx 0). For MC (or core-) level groups: cpu=0 sg_mask=0x1 group_idx=1 cpuidle_idx=0 sge->idle_states_below=0 shallowest_state=1 sge->nr_idle_states=1 group_idle_state() returns 0 in this case because of (shallowest_state=1 >= sge->nr_idle_states=1). This value is then used to index into the sg->sge->idle_states[] to get the idle power value for the topology bit represented by sg (i.e. for CPU0). The idle power value for CPU0 is originally specified in the energy model: static struct idle_state idle_states_core_a15[] = { .power = 0 }, }; [arch/arm/kernel/topology.c] Another example would be to find the idle power value for the LITTLE cluster if it is in 'cluster-sleep-l' [cpuidle_idx=1]: cpu=2 sg_mask=0x1c group_idx=1 cpuidle_idx=1 sge->idle_states_below=1 shallowest_state=3 sge->nr_idle_states=2 cpu=3 sg_mask=0x1c group_idx=1 cpuidle_idx=1 sge->idle_states_below=1 shallowest_state=1 sge->nr_idle_states=2 cpu=3 sg_mask=0x1c group_idx=1 cpuidle_idx=1 sge->idle_states_below=1 shallowest_state=1 sge->nr_idle_states=2 group_idle_state() returns 1 (shallowest_state=1) and the idle power value is 10. static struct idle_state idle_states_cluster_a7[] = { ..., { .power = 10 }}; To sum it up, group_idle_state() is necessary to transform the C state values (-1, 0, 1) into sg->sge->idle_states[] indexes for the different sg's (MC, DIE). [...] -- 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/