hpfall.c improvements, thoughts
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 hpfall.c improvements, thoughts
Some conversation I had with Pavel,
imo the example code should be at least barely useable as in not causing harm like I sketched in (1.). Maybe someone else picks that up and improves it later on. Patch at the end, quite sketchy and imature as it doesn't check for errors, but certainly better than before.
Christian
Quoted 22 lines · Pavel Machek
Hi!
Quoted 9 lines
I just hacked and installed the hpfall utility a little bit. By that I thought I should share some ideas with you. (made no patch since this is trivial, but important)
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!Quoted 6 lines
2.
daemon(0, 0); ... Quick and dirty way to daemonize it3. Realtime priority:
param.sched_priority =sched_get_priority_max(SCHED_FIFO);sched_setscheduler(0, SCHED_FIFO, ¶m);
Should give a chance that it has less latency when woken up.Good ideas. I ommited them, thinking that someone else will do it. Can you submit a patch? (akpm, cc: lk, Eric Piel) I no longer have the hardware, and would prefer not to patch code I can't test.
Quoted 8 lines
Quoted 4 lines
.. another thing is that I still use the old IDE driver, I just changed sda to hda, maybe a bandaid is to use argv[1] for defining the drive (well I understand that it is very basic example code, so maybe someday someone adds a better option parser)
Option parser would indeed be nice.
Pavel
---
Documentation/hwmon/hpfall.c +9 -1
@@ -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) {
@@ -63,6 +65,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 ) {
@@ -70,7 +73,12 @@ int main(int argc, char* argv[])return EXIT_FAILURE ; } -signal (SIGALRM , ignore_me); +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 (;;) {unsigned char count;
Hi!
Quoted 6 lines
Some conversation I had with Pavel,
imo the example code should be at least barely useable as in not causing harm like I sketched in (1.). Maybe someone else picks that up and improves it later on. Patch at the end, quite sketchy and imature as it doesn't check for errors, but certainly better than before.
Thanks. Acked-by: Pavel Machek <[email protected]>
Pavel
Quoted 38 lines
Signed-off-by Christian Thaeter <[email protected]>---
Documentation/hwmon/hpfall.c +9
-1@@ -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) {@@ -63,6 +65,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 ) {@@ -70,7 +73,12 @@ int main(int argc, char* argv[])return EXIT_FAILURE ; } -signal (SIGALRM , ignore_me); +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 (;;) {unsigned char count;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Op 25-03-09 22:27, Christian Thaeter schreef:
Quoted 7 lines
Some conversation I had with Pavel,
imo the example code should be at least barely useable as in not causing harm like I sketched in (1.). Maybe someone else picks that up and improves it later on. Patch at the end, quite sketchy and imature as it doesn't check for errors, but certainly better than before.
Hello Christian,
Would you mind resending the patch with a changelog, so that Andrew can merge it?
Thanks,
Eric
Quoted 2 lines
Signed-off-by Christian Thaeter <[email protected]>
Quoted 37 lines
---
Documentation/hwmon/hpfall.c +9
-1@@ -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) {@@ -63,6 +65,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 ) {@@ -70,7 +73,12 @@ int main(int argc, char* argv[])return EXIT_FAILURE ; } -signal (SIGALRM , ignore_me); +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 (;;) {unsigned char count;