From patchwork Thu Mar 7 16:42:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuansheng Liu X-Patchwork-Id: 2230491 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A07FD3FC8F for ; Thu, 7 Mar 2013 07:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752300Ab3CGHdk (ORCPT ); Thu, 7 Mar 2013 02:33:40 -0500 Received: from mga02.intel.com ([134.134.136.20]:34677 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222Ab3CGHdk (ORCPT ); Thu, 7 Mar 2013 02:33:40 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 06 Mar 2013 23:33:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,800,1355126400"; d="scan'208";a="295523508" Received: from cliu38-desktop-build.sh.intel.com (HELO [10.239.67.35]) ([10.239.67.35]) by orsmga002.jf.intel.com with ESMTP; 06 Mar 2013 23:33:02 -0800 Subject: [PATCH] intel_idle: set the state_tables array into __initdata to save mem From: Chuansheng Liu To: lenb@kernel.org, len.brown@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, chuansheng.liu@intel.com Date: Fri, 08 Mar 2013 00:42:09 +0800 Message-ID: <1362674529.31506.17.camel@cliu38-desktop-build> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently, in intel_idle.c, there are 5 state_tables array, every array size is sizeof(struct cpuidle_state) * CPUIDLE_STATE_MAX. But after intel_idle_probe(), just only one array is useful. Here we can just define one static state_table, and initialize it in intel_idle_probe(), and set other data state_tables as __initdata. It can save about 3K, which also benefits mobile devices. Signed-off-by: liu chuansheng --- drivers/idle/intel_idle.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 5d66750..0642bfe 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -99,7 +99,7 @@ static int intel_idle(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index); static int intel_idle_cpu_init(int cpu); -static struct cpuidle_state *cpuidle_state_table; +static struct cpuidle_state cpuidle_state_table[CPUIDLE_STATE_MAX]; /* * Set this flag for states where the HW flushes the TLB for us @@ -124,7 +124,7 @@ static struct cpuidle_state *cpuidle_state_table; * which is also the index into the MWAIT hint array. * Thus C0 is a dummy. */ -static struct cpuidle_state nehalem_cstates[CPUIDLE_STATE_MAX] = { +static struct cpuidle_state nehalem_cstates[CPUIDLE_STATE_MAX] __initdata = { { .name = "C1-NHM", .desc = "MWAIT 0x00", @@ -157,7 +157,7 @@ static struct cpuidle_state nehalem_cstates[CPUIDLE_STATE_MAX] = { .enter = NULL } }; -static struct cpuidle_state snb_cstates[CPUIDLE_STATE_MAX] = { +static struct cpuidle_state snb_cstates[CPUIDLE_STATE_MAX] __initdata = { { .name = "C1-SNB", .desc = "MWAIT 0x00", @@ -197,7 +197,7 @@ static struct cpuidle_state snb_cstates[CPUIDLE_STATE_MAX] = { .enter = NULL } }; -static struct cpuidle_state ivb_cstates[CPUIDLE_STATE_MAX] = { +static struct cpuidle_state ivb_cstates[CPUIDLE_STATE_MAX] __initdata = { { .name = "C1-IVB", .desc = "MWAIT 0x00", @@ -237,7 +237,7 @@ static struct cpuidle_state ivb_cstates[CPUIDLE_STATE_MAX] = { .enter = NULL } }; -static struct cpuidle_state hsw_cstates[CPUIDLE_STATE_MAX] = { +static struct cpuidle_state hsw_cstates[CPUIDLE_STATE_MAX] __initdata = { { .name = "C1-HSW", .desc = "MWAIT 0x00", @@ -277,7 +277,7 @@ static struct cpuidle_state hsw_cstates[CPUIDLE_STATE_MAX] = { .enter = NULL } }; -static struct cpuidle_state atom_cstates[CPUIDLE_STATE_MAX] = { +static struct cpuidle_state atom_cstates[CPUIDLE_STATE_MAX] __initdata = { { .name = "C1E-ATM", .desc = "MWAIT 0x00", @@ -504,7 +504,12 @@ static int intel_idle_probe(void) pr_debug(PREFIX "MWAIT substates: 0x%x\n", mwait_substates); icpu = (const struct idle_cpu *)id->driver_data; - cpuidle_state_table = icpu->state_table; + /* Copy the icpu->state_table into cpuidle_state_table, + * The pointing array by icpu->state_table is with __initdata, + * which will be freed after kernel init ending. + */ + memcpy(cpuidle_state_table, icpu->state_table, + sizeof(cpuidle_state_table)); if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */ lapic_timer_reliable_states = LAPIC_TIMER_ALWAYS_RELIABLE;