--- Makefile +++ Makefile 2009-03-13 15:01:12.317145442 +0100 @@ -15,17 +15,17 @@ OBJS = $(SRCS:.c=.o) CC = gcc OPTFLAGS = -O2 -g -Wall -W -CFLAGS = $(OPTFLAGS) -D_GNU_SOURCE $(ISSUSE) +CFLAGS = $(OPTFLAGS) -D_GNU_SOURCE ifeq ($(MAKECMDGOALS),makeboot) CFLAGS += -DTEST endif .c.o: - $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c $< + $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" $(ISSUSE) -c $< startpar: $(OBJS) - $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -o $@ $(OBJS) + $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" $(ISSUSE) -o $@ $(OBJS) makeboot: makeboot.c --- makeboot.c +++ makeboot.c 2009-03-13 13:28:08.824501381 +0100 @@ -278,8 +278,10 @@ static void filter_files(const char *dir #endif ndirs = scandir(path, &dirlist, dirfilter, alphasort); #if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600 - if (i >= 0) + if (i >= 0) { (void)posix_fadvise(i, 0, 0, POSIX_FADV_DONTNEED); + close(i); + } #endif /* mark all matching nodes */ if (ndirs >= 0) { --- startpar.c +++ startpar.c 2009-02-12 14:49:10.987760000 +0100 @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include #include @@ -64,6 +66,8 @@ static char *run_mode = NULL; static struct makenode **nodevec; +static enum { Unknown, Preload, NoPreload } ispreload = Unknown; + #define PBUF_SIZE 8192 struct prg { char *name; @@ -248,6 +252,10 @@ if (read_proc(&prcs_run, &prcs_blked)) return par; + /* if we have preload running, we expect I/O not to be a problem */ + if (ispreload == Preload) + prcs_blked = 0; + newpar = (par*numcpu) - prcs_run + 1; /* +1 for startpar its self */ newpar -= (int)(((double)prcs_blked)*iorate); /* I/O load reduction */ @@ -271,6 +279,8 @@ return checksystem(par, start, false); } +#define SOCK_PATH "/dev/shm/preload_sock" + void run(struct prg *p) { char *m = 0; @@ -341,6 +351,40 @@ closeall(); + if (!strcmp(arg, "start")) + { + int s, t, len; + struct sockaddr_un remote; + char str[100]; + + s = socket(AF_UNIX, SOCK_STREAM, 0); + if (s != -1) + { + memset(&remote, 0, sizeof(struct sockaddr_un)); + remote.sun_family = AF_UNIX; + strcpy(remote.sun_path, SOCK_PATH); + len = strlen(remote.sun_path) + sizeof(remote.sun_family); + + t = connect(s, (struct sockaddr *)&remote, len); + if (t != -1) + { + ispreload = Preload; + send(s, p->name, strlen(p->name), 0); + recv(s, str, 100, 0); + } + else if ( ispreload == Unknown) + { + /* + * if we connected to preload once, we know it ran. + * In case we can't connect to it later, it means it did + * its job and we can guess I/O is no longer a problem. + */ + ispreload = NoPreload; + } + close(s); + } + } + if (run_mode) { char path[128];