1N/A * Copyright 2009, Intel Corporation 2N/A * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 1N/A * This file is part of PowerTOP 1N/A * This program file is free software; you can redistribute it and/or modify it 1N/A * under the terms of the GNU General Public License as published by the 1N/A * Free Software Foundation; version 2 of the License. 1N/A * This program is distributed in the hope that it will be useful, but WITHOUT 1N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1N/A * You should have received a copy of the GNU General Public License 1N/A * along with this program in a file named COPYING; if not, write to the 1N/A * Free Software Foundation, Inc., 1N/A * 51 Franklin Street, Fifth Floor, 1N/A * Boston, MA 02110-1301 USA 1N/A * Arjan van de Ven <arjan@linux.intel.com> 1N/A * Eric C Saxe <eric.saxe@sun.com> 1N/A * Aubrey Li <aubrey.li@intel.com> 1N/A * For the avoidance of doubt, except that if any license choice other 1N/A * than GPL or LGPL is available it will apply instead, Sun elects to 1N/A * use only the General Public License version 2 (GPLv2) at this time 1N/A * for any software where a choice of GPL license versions is made 1N/A * available with the language indicating that GPLv2 or any later 1N/A * version may be used, or where a choice of which version of the GPL 1N/A * is applied is otherwise unspecified. 1N/A * Returns the number of online CPUs. 1N/A /* Fall back to one CPU if any of the sysconf calls above failed */ 2N/A /* Free any previous cpu table */ 2N/A * Simple integer comparison routine for the event report qsort(3C). 1N/A "times and print list of top offenders\n");
1N/A "data in seconds [1-30s]\n");
1N/A "kernel cyclic activity\n");
1N/A * the system's bit depth. It feeds a 10 byte long buffer to 1N/A * sysinfo (we only need the first word, sysinfo truncates and 1N/A * \0 terminates the rest) from which we figure out which isa 2N/A * 2^64 - 1; includes null terminator 2N/A * max string will contain n-1 ':'s and one null terminator 2N/A * the first output will have c1 = NULL, to give results since boot 2N/A /* check there are stats to report */ 2N/A /* check there are stats to report */ 2N/A * C-State Kstats are in C(n) ... C(0) Order 2N/A * Powertop displays thenm in C(0) to C(n) order. 2N/A /* g_total_events is tranitions into C0 */ 2N/A "supported_max_pstates",
2N/A * P-State Kstats are in P(n) .. P(0) order 2N/A * powertop displays them is this order. 2N/A * The snapshot has changed for whatever reason. We need to regenerate 2N/A * all information pertaining to the cpus including the record offsets. 2N/A * Re-enumerate the system's CPUs, populate cpu_table, g_ncpus 2N/A * Walk the cpu snapshot chain, looking for the information we desire. 2N/A /* If no valid CPU is present, move on to the next one */ 2N/A * Note: the following helpers do not clean up on the failure case, 2N/A * because pt_free_snapshot() is called in main each time through the loop 2N/A * If the snap has changed or we have not obtained the 2N/A * kstat_cpu_information, then go and get the cpu information. 2N/A * Read the data in that changes between the intervals. 2N/A /* If no valid CPU is present, move on to the next one */ 2N/A /* now copy the cstate and pstate strings */ 2N/A * Note: the following helpers do not clean up on the failure case, 2N/A * because pt_free_snapshot() is called in main each time through the loop 2N/A * If the snap has changed or we have not obtained the 2N/A * kstat_cpu_information, then go and get the cpu information. 2N/A * Read the data in that changes between the intervals. 2N/A * now copy the cstate and pstate strings 2N/A * Convert a ':'-separated null terminated string into an array of values 2N/A * It is OK to modify the input string 2N/A * There will always be at least two entries (e.g. one ':') in the string. 2N/A * Return the number of entries found, or 0 for a misformed string 2N/A * Convert a pair of strings of ':'-separated uint64 numbers into an array of 2N/A * the difference between the values of the numbers in each position. 2N/A * Assumes, based on knowing the context in which it is called: 2N/A * both strings have the same number of entries 2N/A * some numbers may be "empty" (e.g. the string may contain consecutive :'s 2N/A * if an entry in one string is empty then the other will be too 2N/A * the difference between two empty strings is computed as 0 2N/A * numbers represent nanoseconds, which won't wrap in our lifetime 2N/A * Returns the number of entries found in the string, else 0 if misformed. 2N/A * If index_ptr integer value is > -1 then the index points to the 2N/A * string entry in the ks_data that we are interested in. Otherwise 2N/A * we will need to walk the array. 2N/A /* Short cut to the information. */ 2N/A /* Need to go find the string. */