Skip to content
Browse files

Updated tuningsysfs to check all SATA hosts for tuining interests. Wi…

…th 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.
  • Loading branch information...
1 parent feb21c2 commit 38a51f3dad058c0e97a9c5796edd4f82b4650444 @ceferron ceferron committed
Showing with 45 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +1 −2 src/tuning/tuning.cpp
  3. +42 −0 src/tuning/tuningsysfs.cpp
  4. +1 −1 src/tuning/tuningsysfs.h
View
1 .gitignore
@@ -51,6 +51,7 @@ src/parameters/.deps/
src/perf/.deps/
src/process/.deps/
src/tuning/.deps/
+src/report/.deps/
m4
*.dirstamp
*.lo
View
3 src/tuning/tuning.cpp
@@ -57,11 +57,10 @@ class tuning_window: public tab_window {
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();
View
42 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 @@ void add_sysfs_tunable(const char *str, const char *_sysfs_path, const char *_ta
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);
+}
View
2 src/tuning/tuningsysfs.h
@@ -47,6 +47,6 @@ class sysfs_tunable : public tunable {
};
extern void add_sysfs_tunable(const char *str, const char *_sysfs_path, const char *_target_content);
-
+extern void add_sata_tunables(void);
#endif

0 comments on commit 38a51f3

Please sign in to comment.
Something went wrong with that request. Please try again.