/*
* Copyright 2009, Intel Corporation
*
* This file is part of PowerTOP
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program in a file named COPYING; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authors:
* Arjan van de Ven <arjan@linux.intel.com>
* Eric C Saxe <eric.saxe@sun.com>
* Aubrey Li <aubrey.li@intel.com>
*/
/*
* GPL Disclaimer
*
* For the avoidance of doubt, except that if any license choice other
* than GPL or LGPL is available it will apply instead, Sun elects to
* use only the General Public License version 2 (GPLv2) at this time
* for any software where a choice of GPL license versions is made
* available with the language indicating that GPLv2 or any later
* version may be used, or where a choice of which version of the GPL
* is applied is otherwise unspecified.
*/
#include <stdlib.h>
#include <string.h>
#include <dtrace.h>
#include <kstat.h>
#include <errno.h>
#include "powertop.h"
/*
* Global turbo related variables definitions
*/
double g_turbo_ratio;
/*
* The variables to store kstat snapshot
*/
/*
* Perform setup necessary to enumerate and track CPU turbo information
*/
static int
pt_turbo_init(void)
{
/*
* check if the CPU turbo is supported
*/
return (-1);
}
pt_error("couldn't find 'turbo_supported' kstat\n");
return (-2);
}
/*
* Initialize turbo information structure if turbo mode is supported
*/
}
return (0);
}
/*
* Take a snapshot of each CPU's turbo information
* by looking through the turbo kstats.
*/
static int
{
int cpu;
pt_error("couldn't find 'turbo' kstat for CPU %d\n",
cpu);
return (-1);
}
pt_error("couldn't read 'turbo' kstat for CPU %d\n",
cpu);
return (-2);
}
pt_error("couldn't find 'turbo_mcnt' kstat for CPU "
"%d\n", cpu);
return (-3);
}
/*
* snapshot IA32_MPERF_MSR
*/
pt_error("couldn't find 'turbo_acnt' kstat for CPU "
"%d\n", cpu);
return (-4);
}
/*
* snapshot IA32_APERF_MSR
*/
}
return (0);
}
/*
* Turbo support checking and information initialization
*/
int
pt_turbo_stat_prepare(void)
{
int ret = 0;
if ((ret = pt_turbo_init()) != 0)
return (ret);
pt_error("failed to snapshot 'turbo' kstat\n");
return (ret);
}
/*
* When doing the statistics collection, we compare two kstat snapshot
* and get a delta. the final ratio of performance boost will be worked
* out according to the kstat delta
*/
int
pt_turbo_stat_collect(void)
{
int cpu;
double ratio;
int ret;
/*
* Take a snapshot of turbo information to setup turbo_info_t
* structure
*/
pt_error("failed to snapshot 'turbo' kstat\n");
return (ret);
}
/*
* Calculate the kstat delta and work out the performance boost ratio
*/
ratio = 1.0;
else
g_turbo_ratio += ratio;
}
/*
* Update the structure of the kstat for the next time calculation
*/
return (0);
}