Skip to content

Commit

Permalink
Updated tuningsysfs to check all SATA hosts for tuining interests. Wi…
Browse files Browse the repository at this point in the history
…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
Chris E Ferron committed Oct 15, 2012
1 parent feb21c2 commit 38a51f3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ src/parameters/.deps/
src/perf/.deps/
src/process/.deps/
src/tuning/.deps/
src/report/.deps/
m4
*.dirstamp
*.lo
Expand Down
3 changes: 1 addition & 2 deletions src/tuning/tuning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
42 changes: 42 additions & 0 deletions src/tuning/tuningsysfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/tuning/tuningsysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.