* [PATCH] hpfall.c improvements, thoughts [not found] ` <20090324211555.GA24172@elf.ucw.cz> @ 2009-03-25 21:27 ` Christian Thaeter 2009-03-25 21:33 ` Pavel Machek 2009-05-20 21:04 ` Éric Piel 0 siblings, 2 replies; 3+ messages in thread From: Christian Thaeter @ 2009-03-25 21:27 UTC (permalink / raw) To: linux-kernel; +Cc: Pavel Machek, eric.piel 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 Pavel Machek wrote: > Hi! > >> 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! >> >> 2. daemon(0, 0); ... Quick and dirty way to daemonize it >> >> 3. 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. > >> .. 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 > Signed-off-by: Christian Thaeter <ct@pipapo.org> --- diff --git a/Documentation/hwmon/hpfall.c b/Documentation/hwmon/hpfall.c index bbea1cc..f3cde67 100644 --- a/Documentation/hwmon/hpfall.c +++ b/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) { @@ -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; ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hpfall.c improvements, thoughts 2009-03-25 21:27 ` [PATCH] hpfall.c improvements, thoughts Christian Thaeter @ 2009-03-25 21:33 ` Pavel Machek 2009-05-20 21:04 ` Éric Piel 1 sibling, 0 replies; 3+ messages in thread From: Pavel Machek @ 2009-03-25 21:33 UTC (permalink / raw) To: Christian Thaeter; +Cc: linux-kernel, eric.piel Hi! > 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 <pavel@ucw.cz> Pavel > Signed-off-by: Christian Thaeter <ct@pipapo.org> > --- > > diff --git a/Documentation/hwmon/hpfall.c b/Documentation/hwmon/hpfall.c > index bbea1cc..f3cde67 100644 > --- a/Documentation/hwmon/hpfall.c > +++ b/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) > { > @@ -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; -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hpfall.c improvements, thoughts 2009-03-25 21:27 ` [PATCH] hpfall.c improvements, thoughts Christian Thaeter 2009-03-25 21:33 ` Pavel Machek @ 2009-05-20 21:04 ` Éric Piel 1 sibling, 0 replies; 3+ messages in thread From: Éric Piel @ 2009-05-20 21:04 UTC (permalink / raw) To: Christian Thaeter; +Cc: linux-kernel, Pavel Machek, Andrew Morton Op 25-03-09 22:27, Christian Thaeter schreef: > 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 > > Signed-off-by: Christian Thaeter <ct@pipapo.org> Acked-by: Éric Piel <eric.piel@tremplin-utc.net> > --- > > diff --git a/Documentation/hwmon/hpfall.c b/Documentation/hwmon/hpfall.c > index bbea1cc..f3cde67 100644 > --- a/Documentation/hwmon/hpfall.c > +++ b/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) > { > @@ -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; ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-20 21:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <49C8F338.7030901@pipapo.org>
[not found] ` <20090324211555.GA24172@elf.ucw.cz>
2009-03-25 21:27 ` [PATCH] hpfall.c improvements, thoughts Christian Thaeter
2009-03-25 21:33 ` Pavel Machek
2009-05-20 21:04 ` Éric Piel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox