Updated tuningsysfs to check all SATA hosts for tuining interests. With new power off to unused SATA ports making it into libata, PowerTOP should now suggest writing min_power to all SATA ports, whether they are populated or not.
diff --git a/.gitignore b/.gitignore
index 126713b..96ffdba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,7 @@
src/perf/.deps/
src/process/.deps/
src/tuning/.deps/
+src/report/.deps/
m4
*.dirstamp
*.lo
diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp
index ebb4ac8..08d8251 100644
--- a/src/tuning/tuning.cpp
+++ b/src/tuning/tuning.cpp
@@ -57,11 +57,10 @@
static void init_tuning(void)
{
add_sysfs_tunable(_("Enable Audio codec power management"), "/sys/module/snd_hda_intel/parameters/power_save", "1");
- add_sysfs_tunable(_("Enable SATA link power management for /dev/sda"), "/sys/class/scsi_host/host0/link_power_management_policy", "min_power");
add_sysfs_tunable(_("NMI watchdog should be turned off"), "/proc/sys/kernel/nmi_watchdog", "0");
add_sysfs_tunable(_("Power Aware CPU scheduler"), "/sys/devices/system/cpu/sched_mc_power_savings", "1");
add_sysfs_tunable(_("VM writeback timeout"), "/proc/sys/vm/dirty_writeback_centisecs", "1500");
-
+ add_sata_tunables();
add_usb_tunables();
add_runtime_tunables("pci");
add_ethernet_tunable();
diff --git a/src/tuning/tuningsysfs.cpp b/src/tuning/tuningsysfs.cpp
index 602d62d..33d3786 100644
--- a/src/tuning/tuningsysfs.cpp
+++ b/src/tuning/tuningsysfs.cpp
@@ -28,9 +28,16 @@
#include "unistd.h"
#include "tuningsysfs.h"
#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <utility>
#include <iostream>
#include <fstream>
+#include <unistd.h>
+#include <sys/types.h>
+#include <dirent.h>
+
#include "../lib.h"
@@ -105,3 +112,38 @@
all_tunables.push_back(tunable);
}
+
+void add_sata_tunables(void)
+{
+ struct dirent *entry;
+ DIR *dir;
+ char filename[4096];
+ char msg[4096];
+
+ dir = opendir("/sys/class/scsi_host");
+
+ if (!dir)
+ return;
+
+ while (1) {
+ entry = readdir(dir);
+
+ if (!entry)
+ break;
+
+ if (strcmp(entry->d_name, ".") == 0)
+ continue;
+
+ if (strcmp(entry->d_name, "..") == 0)
+ continue;
+
+ sprintf(filename, "/sys/class/scsi_host/%s/link_power_management_policy", entry->d_name);
+
+ sprintf(msg, _("Enable SATA link power Managmenet for %s"),entry->d_name);
+
+ add_sysfs_tunable(msg, filename,"min_power");
+
+ }
+
+ closedir(dir);
+}
diff --git a/src/tuning/tuningsysfs.h b/src/tuning/tuningsysfs.h
index ac7938c..ad89717 100644
--- a/src/tuning/tuningsysfs.h
+++ b/src/tuning/tuningsysfs.h
@@ -47,6 +47,6 @@
};
extern void add_sysfs_tunable(const char *str, const char *_sysfs_path, const char *_target_content);
-
+extern void add_sata_tunables(void);
#endif