The patch titled hpfall: reduce risk that hpfall can do harm has been added to the -mm tree. Its filename is hpfall-reduce-risk-that-hpfall-can-do-harm.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: hpfall: reduce risk that hpfall can do harm From: Christian Thaeter <ct@xxxxxxxxxx> Improve the example code to be at least useable, as in not causing harm (as shown below). Code can still be improved further, but this adds some basic safeguards. 1. hpfall *MUST* mlockall(MCL_CURRENT|MCL_FUTURE); itself! Since the Program sits and waits most of the time it becomes very likely swapped out. If it gets woken up when the laptop drops from the table while it is swapped out it actually triggers harddrive activity! 2. Daemonize hpfall using 'daemon(0,0)' (quick and dirty). 3. Give hpfall realtime priority. Should give a chance that it has less latency when woken up. Signed-off-by: Christian Thaeter <ct@xxxxxxxxxx> Signed-off-by: Frans Pop <elendil@xxxxxxxxx> Acked-by: Pavel Machek <pavel@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- Documentation/hwmon/hpfall.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff -puN Documentation/hwmon/hpfall.c~hpfall-reduce-risk-that-hpfall-can-do-harm Documentation/hwmon/hpfall.c --- a/Documentation/hwmon/hpfall.c~hpfall-reduce-risk-that-hpfall-can-do-harm +++ a/Documentation/hwmon/hpfall.c @@ -16,6 +16,8 @@ #include <stdint.h> #include <errno.h> #include <signal.h> +#include <sys/mman.h> +#include <sched.h> void write_int(char *path, int i) { @@ -62,6 +64,7 @@ void ignore_me(void) int main(int argc, char *argv[]) { int fd, ret; + struct sched_param param; fd = open("/dev/freefall", O_RDONLY); if (fd < 0) { @@ -69,6 +72,11 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + daemon(0, 0); + param.sched_priority = sched_get_priority_max(SCHED_FIFO); + sched_setscheduler(0, SCHED_FIFO, ¶m); + mlockall(MCL_CURRENT|MCL_FUTURE); + signal(SIGALRM, ignore_me); for (;;) { _ Patches currently in -mm which might be from ct@xxxxxxxxxx are vm-document-that-setting-vfs_cache_pressure-to-0-isnt-a-good-idea.patch hpfall-reduce-risk-that-hpfall-can-do-harm.patch hpfall-accept-disk-device-to-unload-as-argument.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html