Merge "metricsd: Remove dead code."
This commit is contained in:
commit
695da48944
4 changed files with 0 additions and 123 deletions
|
|
@ -74,11 +74,6 @@ const int kMetricMeminfoInterval = 30; // seconds
|
|||
const char kMeminfoFileName[] = "/proc/meminfo";
|
||||
const char kVmStatFileName[] = "/proc/vmstat";
|
||||
|
||||
// Thermal CPU throttling.
|
||||
|
||||
const char kMetricScaledCpuFrequencyName[] =
|
||||
"Platform.CpuFrequencyThermalScaling";
|
||||
|
||||
} // namespace
|
||||
|
||||
// Zram sysfs entries.
|
||||
|
|
@ -169,8 +164,6 @@ void MetricsDaemon::Init(bool testing,
|
|||
bool dbus_enabled,
|
||||
MetricsLibraryInterface* metrics_lib,
|
||||
const string& diskstats_path,
|
||||
const string& scaling_max_freq_path,
|
||||
const string& cpuinfo_max_freq_path,
|
||||
const base::TimeDelta& upload_interval,
|
||||
const string& server,
|
||||
const base::FilePath& metrics_directory) {
|
||||
|
|
@ -221,8 +214,6 @@ void MetricsDaemon::Init(bool testing,
|
|||
weekly_cycle_.reset(new PersistentInteger("weekly.cycle"));
|
||||
version_cycle_.reset(new PersistentInteger("version.cycle"));
|
||||
|
||||
scaling_max_freq_path_ = scaling_max_freq_path;
|
||||
cpuinfo_max_freq_path_ = cpuinfo_max_freq_path;
|
||||
disk_usage_collector_.reset(new DiskUsageCollector(metrics_lib_));
|
||||
averaged_stats_collector_.reset(
|
||||
new AveragedStatisticsCollector(metrics_lib_, diskstats_path,
|
||||
|
|
@ -461,63 +452,6 @@ void MetricsDaemon::StatsReporterInit() {
|
|||
averaged_stats_collector_->ScheduleWait();
|
||||
}
|
||||
|
||||
|
||||
bool MetricsDaemon::ReadFreqToInt(const string& sysfs_file_name, int* value) {
|
||||
const FilePath sysfs_path(sysfs_file_name);
|
||||
string value_string;
|
||||
if (!base::ReadFileToString(sysfs_path, &value_string)) {
|
||||
LOG(WARNING) << "cannot read " << sysfs_path.value().c_str();
|
||||
return false;
|
||||
}
|
||||
if (!base::RemoveChars(value_string, "\n", &value_string)) {
|
||||
LOG(WARNING) << "no newline in " << value_string;
|
||||
// Continue even though the lack of newline is suspicious.
|
||||
}
|
||||
if (!base::StringToInt(value_string, value)) {
|
||||
LOG(WARNING) << "cannot convert " << value_string << " to int";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MetricsDaemon::SendCpuThrottleMetrics() {
|
||||
// |max_freq| is 0 only the first time through.
|
||||
static int max_freq = 0;
|
||||
if (max_freq == -1)
|
||||
// Give up, as sysfs did not report max_freq correctly.
|
||||
return;
|
||||
if (max_freq == 0 || testing_) {
|
||||
// One-time initialization of max_freq. (Every time when testing.)
|
||||
if (!ReadFreqToInt(cpuinfo_max_freq_path_, &max_freq)) {
|
||||
max_freq = -1;
|
||||
return;
|
||||
}
|
||||
if (max_freq == 0) {
|
||||
LOG(WARNING) << "sysfs reports 0 max CPU frequency\n";
|
||||
max_freq = -1;
|
||||
return;
|
||||
}
|
||||
if (max_freq % 10000 == 1000) {
|
||||
// Special case: system has turbo mode, and max non-turbo frequency is
|
||||
// max_freq - 1000. This relies on "normal" (non-turbo) frequencies
|
||||
// being multiples of (at least) 10 MHz. Although there is no guarantee
|
||||
// of this, it seems a fairly reasonable assumption. Otherwise we should
|
||||
// read scaling_available_frequencies, sort the frequencies, compare the
|
||||
// two highest ones, and check if they differ by 1000 (kHz) (and that's a
|
||||
// hack too, no telling when it will change).
|
||||
max_freq -= 1000;
|
||||
}
|
||||
}
|
||||
int scaled_freq = 0;
|
||||
if (!ReadFreqToInt(scaling_max_freq_path_, &scaled_freq))
|
||||
return;
|
||||
// Frequencies are in kHz. If scaled_freq > max_freq, turbo is on, but
|
||||
// scaled_freq is not the actual turbo frequency. We indicate this situation
|
||||
// with a 101% value.
|
||||
int percent = scaled_freq > max_freq ? 101 : scaled_freq / (max_freq / 100);
|
||||
SendLinearSample(kMetricScaledCpuFrequencyName, percent, 101, 102);
|
||||
}
|
||||
|
||||
void MetricsDaemon::ScheduleMeminfoCallback(int wait) {
|
||||
if (testing_) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ class MetricsDaemon : public brillo::DBusDaemon {
|
|||
bool dbus_enabled,
|
||||
MetricsLibraryInterface* metrics_lib,
|
||||
const std::string& diskstats_path,
|
||||
const std::string& cpuinfo_max_freq_path,
|
||||
const std::string& scaling_max_freq_path,
|
||||
const base::TimeDelta& upload_interval,
|
||||
const std::string& server,
|
||||
const base::FilePath& metrics_directory);
|
||||
|
|
@ -92,12 +90,10 @@ class MetricsDaemon : public brillo::DBusDaemon {
|
|||
FRIEND_TEST(MetricsDaemonTest, ProcessUncleanShutdown);
|
||||
FRIEND_TEST(MetricsDaemonTest, ProcessUserCrash);
|
||||
FRIEND_TEST(MetricsDaemonTest, ReportCrashesDailyFrequency);
|
||||
FRIEND_TEST(MetricsDaemonTest, ReadFreqToInt);
|
||||
FRIEND_TEST(MetricsDaemonTest, ReportKernelCrashInterval);
|
||||
FRIEND_TEST(MetricsDaemonTest, ReportUncleanShutdownInterval);
|
||||
FRIEND_TEST(MetricsDaemonTest, ReportUserCrashInterval);
|
||||
FRIEND_TEST(MetricsDaemonTest, SendSample);
|
||||
FRIEND_TEST(MetricsDaemonTest, SendCpuThrottleMetrics);
|
||||
FRIEND_TEST(MetricsDaemonTest, SendZramMetrics);
|
||||
|
||||
// Type of scale to use for meminfo histograms. For most of them we use
|
||||
|
|
@ -215,12 +211,6 @@ class MetricsDaemon : public brillo::DBusDaemon {
|
|||
// Parses meminfo data and sends it to UMA.
|
||||
bool ProcessMemuse(const std::string& meminfo_raw);
|
||||
|
||||
// Sends stats for thermal CPU throttling.
|
||||
void SendCpuThrottleMetrics();
|
||||
|
||||
// Reads an integer CPU frequency value from sysfs.
|
||||
bool ReadFreqToInt(const std::string& sysfs_file_name, int* value);
|
||||
|
||||
// Reads the current OS version from /etc/lsb-release and hashes it
|
||||
// to a unsigned 32-bit int.
|
||||
uint32_t GetOsVersionHash();
|
||||
|
|
@ -301,9 +291,6 @@ class MetricsDaemon : public brillo::DBusDaemon {
|
|||
scoped_ptr<DiskUsageCollector> disk_usage_collector_;
|
||||
scoped_ptr<AveragedStatisticsCollector> averaged_stats_collector_;
|
||||
|
||||
std::string scaling_max_freq_path_;
|
||||
std::string cpuinfo_max_freq_path_;
|
||||
|
||||
base::TimeDelta upload_interval_;
|
||||
std::string server_;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,6 @@
|
|||
#include "constants.h"
|
||||
#include "metrics_daemon.h"
|
||||
|
||||
const char kScalingMaxFreqPath[] =
|
||||
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq";
|
||||
const char kCpuinfoMaxFreqPath[] =
|
||||
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq";
|
||||
|
||||
// Returns the path to the disk stats in the sysfs. Returns the null string if
|
||||
// it cannot find the disk stats file.
|
||||
|
|
@ -112,8 +108,6 @@ int main(int argc, char** argv) {
|
|||
FLAGS_withdbus,
|
||||
&metrics_lib,
|
||||
MetricsMainDiskStatsPath(),
|
||||
kScalingMaxFreqPath,
|
||||
kCpuinfoMaxFreqPath,
|
||||
base::TimeDelta::FromSeconds(FLAGS_upload_interval_secs),
|
||||
FLAGS_server,
|
||||
base::FilePath(FLAGS_metrics_directory));
|
||||
|
|
|
|||
|
|
@ -45,11 +45,6 @@ class MetricsDaemonTest : public testing::Test {
|
|||
virtual void SetUp() {
|
||||
brillo::FlagHelper::Init(0, nullptr, "");
|
||||
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
|
||||
scaling_max_freq_path_ = temp_dir_.path().Append("scaling_max");
|
||||
cpu_max_freq_path_ = temp_dir_.path().Append("cpu_freq_max");
|
||||
|
||||
CreateUint64ValueFile(cpu_max_freq_path_, 10000000);
|
||||
CreateUint64ValueFile(scaling_max_freq_path_, 10000000);
|
||||
|
||||
chromeos_metrics::PersistentInteger::SetMetricsDirectory(
|
||||
temp_dir_.path().value());
|
||||
|
|
@ -58,8 +53,6 @@ class MetricsDaemonTest : public testing::Test {
|
|||
true,
|
||||
&metrics_lib_,
|
||||
"",
|
||||
scaling_max_freq_path_.value(),
|
||||
cpu_max_freq_path_.value(),
|
||||
base::TimeDelta::FromMinutes(30),
|
||||
metrics::kMetricsServer,
|
||||
temp_dir_.path());
|
||||
|
|
@ -120,10 +113,6 @@ class MetricsDaemonTest : public testing::Test {
|
|||
// Temporary directory used for tests.
|
||||
base::ScopedTempDir temp_dir_;
|
||||
|
||||
// Path for the fake files.
|
||||
base::FilePath scaling_max_freq_path_;
|
||||
base::FilePath cpu_max_freq_path_;
|
||||
|
||||
// Mocks. They are strict mock so that all unexpected
|
||||
// calls are marked as failures.
|
||||
StrictMock<MetricsLibraryMock> metrics_lib_;
|
||||
|
|
@ -209,33 +198,6 @@ TEST_F(MetricsDaemonTest, ProcessMeminfo2) {
|
|||
EXPECT_FALSE(daemon_.ProcessMeminfo(meminfo));
|
||||
}
|
||||
|
||||
TEST_F(MetricsDaemonTest, ReadFreqToInt) {
|
||||
const int fake_scaled_freq = 1666999;
|
||||
const int fake_max_freq = 2000000;
|
||||
int scaled_freq = 0;
|
||||
int max_freq = 0;
|
||||
CreateUint64ValueFile(scaling_max_freq_path_, fake_scaled_freq);
|
||||
CreateUint64ValueFile(cpu_max_freq_path_, fake_max_freq);
|
||||
EXPECT_TRUE(daemon_.testing_);
|
||||
EXPECT_TRUE(daemon_.ReadFreqToInt(scaling_max_freq_path_.value(),
|
||||
&scaled_freq));
|
||||
EXPECT_TRUE(daemon_.ReadFreqToInt(cpu_max_freq_path_.value(), &max_freq));
|
||||
EXPECT_EQ(fake_scaled_freq, scaled_freq);
|
||||
EXPECT_EQ(fake_max_freq, max_freq);
|
||||
}
|
||||
|
||||
TEST_F(MetricsDaemonTest, SendCpuThrottleMetrics) {
|
||||
CreateUint64ValueFile(cpu_max_freq_path_, 2001000);
|
||||
// Test the 101% and 100% cases.
|
||||
CreateUint64ValueFile(scaling_max_freq_path_, 2001000);
|
||||
EXPECT_TRUE(daemon_.testing_);
|
||||
EXPECT_CALL(metrics_lib_, SendEnumToUMA(_, 101, 101));
|
||||
daemon_.SendCpuThrottleMetrics();
|
||||
CreateUint64ValueFile(scaling_max_freq_path_, 2000000);
|
||||
EXPECT_CALL(metrics_lib_, SendEnumToUMA(_, 100, 101));
|
||||
daemon_.SendCpuThrottleMetrics();
|
||||
}
|
||||
|
||||
TEST_F(MetricsDaemonTest, SendZramMetrics) {
|
||||
EXPECT_TRUE(daemon_.testing_);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue