From d8d6d4450a63474331cb8ed00f93a543fd422a1d Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Mon, 18 Jan 2010 11:57:07 +0100 Subject: [PATCH] UML kernel reads polling interval from a config file --- arch/um/include/shared/aha-defs.h | 12 ++++++++++++ arch/um/include/shared/aha.h | 3 +-- arch/um/kernel/aha.c | 4 ++-- arch/um/os-Linux/Makefile | 2 +- arch/um/os-Linux/main.c | 23 ++++++++++++++++++++++- 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 arch/um/include/shared/aha-defs.h diff --git a/arch/um/include/shared/aha-defs.h b/arch/um/include/shared/aha-defs.h new file mode 100644 index 00000000000..9d6adef81e3 --- /dev/null +++ b/arch/um/include/shared/aha-defs.h @@ -0,0 +1,12 @@ +#ifndef __AHA_DEFS__ +#define __AHA_DEFS__ +/* Global variables used for the aha framework */ + +/* Polling delay for sys_execve. AHA polls the permissions for each system call. + * The delay must be expressed in ms + * This delay is read once in the main from the conf/polldelay file. Thus one + * write. Each sys_execve calls read then this global variable + */ +extern int __aha_poll_delay; +#define AHA_DEF_POLL_DELAY 100 +#endif diff --git a/arch/um/include/shared/aha.h b/arch/um/include/shared/aha.h index 33645edba16..fa0a9b142e0 100644 --- a/arch/um/include/shared/aha.h +++ b/arch/um/include/shared/aha.h @@ -1,6 +1,5 @@ #ifndef AHA #define AHA - #define AHA_DEBUG #include "linux/kernel.h" /* printk is declared there */ //#include "linux/gfp.h" /* GFP_KERNEL */ @@ -18,7 +17,7 @@ //#include "skas.h" #include "os.h" #include "linux/delay.h" - +#include "aha-defs.h" /*FIXME use AHA name space */ #define MAX_DUMP_BUF 512 struct ReplyMessage{ diff --git a/arch/um/kernel/aha.c b/arch/um/kernel/aha.c index 52eb3085364..4e6f5dbd083 100644 --- a/arch/um/kernel/aha.c +++ b/arch/um/kernel/aha.c @@ -170,9 +170,8 @@ void aha_get_reply_message(char* key, struct ReplyMessage *msg) filename[0]=0; snprintf((char*)filename,128,"in/%s",key); - /* Give AHA the time to write the reply */ - msleep_interruptible(50); + msleep_interruptible(__aha_poll_delay); fd = os_open_file(filename, of_read(OPENFLAGS()), 0); if ( fd < 0 ) { AHA_PRINTK("Could not open reply file: %s\n",filename); @@ -224,3 +223,4 @@ void aha_record_sys_clone(int pid, int ppid) #undef filename__size #undef buf__size } + diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index d66f0388f09..6601ddd55f6 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -9,7 +9,7 @@ obj-y = aio.o elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \ main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ - tty.o tls.o uaccess.o umid.o util.o + tty.o tls.o uaccess.o umid.o util.o aha.o CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH) diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c index eee69b9f52c..b4ae751f5ee 100644 --- a/arch/um/os-Linux/main.c +++ b/arch/um/os-Linux/main.c @@ -16,11 +16,13 @@ #include "kern_util.h" #include "os.h" #include "um_malloc.h" - +#include "aha-defs.h" #define PGD_BOUND (4 * 1024 * 1024) #define STACKSIZE (8 * 1024 * 1024) #define THREAD_NAME_LEN (256) +int __aha_poll_delay; + static void set_stklim(void) { struct rlimit lim; @@ -38,6 +40,24 @@ static void set_stklim(void) } } +/* Read the polling delay from the conf/polldelay file. + * On sucess the polling value is returned. + * On failure a hardcoded default value is returned. + */ +int aha_read_poll_delay(void) +{ + FILE *fp; + int ret; + ret = AHA_DEF_POLL_DELAY; + fp = fopen("conf/polldelay","r"); + if (fp){ + if (fscanf(fp,"%d",(int*)&ret)<=0) + ret = AHA_DEF_POLL_DELAY; + fclose(fp); + } + return ret; +} + static __init void do_uml_initcalls(void) { initcall_t *call; @@ -47,6 +67,7 @@ static __init void do_uml_initcalls(void) (*call)(); call++; } + __aha_poll_delay=aha_read_poll_delay(); } static void last_ditch_exit(int sig)