From cb4b00ba97bb25208e846c92831bcf68bcc7e777 Mon Sep 17 00:00:00 2001 From: Naoki Hamada Date: Mon, 25 Aug 2014 16:39:02 +0900 Subject: [PATCH] Added debug messages. --- executer/kernel/ikc.c | 35 ++++++++++++++++++++++++++++++++++- kernel/host.c | 1 - kernel/procfs.c | 32 ++++++++++++++++++++++++++------ 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/executer/kernel/ikc.c b/executer/kernel/ikc.c index f438f10b..5a7f3e45 100644 --- a/executer/kernel/ikc.c +++ b/executer/kernel/ikc.c @@ -34,6 +34,14 @@ #include #endif +//#define IKC_DEBUG + +#ifdef IKC_DEBUG +#define dprintk(...) printk(__VA_ARGS__) +#else +#define dprintk(...) +#endif + #define REQUEST_SHIFT 16 //int num_channels; @@ -46,6 +54,7 @@ int mcexec_syscall(struct mcctrl_channel *c, int pid, unsigned long arg); static DECLARE_WAIT_QUEUE_HEAD(procfsq); static unsigned long procfsq_channel; +static ihk_spinlock_t procfsq_lock; int mckernel_procfs_read(char *buffer, char **start, off_t offset, int count, int *peof, void *dat); @@ -65,6 +74,7 @@ struct procfs_list_entry { }; LIST_HEAD(procfs_file_list); +static ihk_spinlock_t procfs_file_list_lock; static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, void *__packet, void *__os) @@ -97,11 +107,15 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, struct procfs_list_entry *e; int mode; ihk_device_t dev = ihk_os_to_dev(__os); + unsigned long irqflags; + dprintk("ikc: received SCD_MSG_PROCFS_CREATE message.\n"); d = kmalloc(sizeof(struct procfs_data), GFP_KERNEL); if (d == NULL) { kprintf("ERROR: not enough memory to create PROCFS entry.\n"); + goto quit; } + dprintk("osnum: %d, cpu: %d, pid: %d\n", pisp->osnum, pisp->ref, pisp->pid); d->osnum = pisp->osnum; d->os = __os; d->cpu = pisp->ref; @@ -114,6 +128,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, f->status = 1; /* done */ ihk_device_unmap_virtual(dev, f, sizeof(struct procfs_file)); ihk_device_unmap_memory(dev, parg, sizeof(struct procfs_file)); + dprintk("fname: %s, mode: %o\n", d->fname, mode); entry = create_proc_entry(d->fname, mode, NULL); if (entry == NULL) { @@ -123,6 +138,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, } entry->data = d; entry->read_proc = mckernel_procfs_read; + dprintk("made a proc entry.\n"); e = kmalloc(sizeof(struct procfs_list_entry), GFP_KERNEL); if (e == NULL) { @@ -131,7 +147,10 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, goto quit; } e->data = d; + irqflags = ihk_ikc_spinlock_lock(&procfs_file_list_lock); list_add(&(e->list), &procfs_file_list); + ihk_ikc_spinlock_unlock(&procfs_file_list_lock, irqflags); + dprintk("added to a procfs list.\n"); } quit: break; @@ -141,26 +160,34 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c, unsigned long parg; struct procfs_file *f; struct procfs_list_entry *e; + unsigned long irqflags; + dprintk("ikc: received SCD_MSG_PROCFS_DELETE message.\n"); parg = ihk_device_map_memory(dev, pisp->arg, sizeof(struct procfs_file)); f = ihk_device_map_virtual(dev, parg, sizeof(struct procfs_file), NULL, 0); + dprintk("ikc: fname: %s.\n", f->fname); list_for_each_entry(e, &procfs_file_list, list) { if (strncmp(e->data->fname, f->fname, PROCFS_NAME_MAX) == 0) { + dprintk("found and delete an entry in the list.\n"); + irqflags = ihk_ikc_spinlock_lock(&procfs_file_list_lock); list_del(&e->list); + ihk_ikc_spinlock_unlock(&procfs_file_list_lock, irqflags); kfree(e->data); kfree(e); break; } } remove_proc_entry(f->fname, NULL); + dprintk("removed procfs entry.\n"); ihk_device_unmap_virtual(dev, f, sizeof(struct procfs_file)); ihk_device_unmap_memory(dev, parg, sizeof(struct procfs_file)); } break; case SCD_MSG_PROCFS_ANSWER: + dprintk("ikc: received SCD_MSG_PROCFS_ANSWER message.\n"); procfsq_channel = pisp->arg; - wake_up(&procfsq); + wake_up_interruptible(&procfsq); break; } @@ -468,6 +495,9 @@ int mckernel_procfs_read(char *buffer, char **start, off_t offset, int ret; unsigned long pbuf; + dprintk("mckernel_procfs_read: invoked for %s\n", data->fname); + dprintk("offset: %lx, count: %d\n", offset, count\n); + if (count <= 0 || dat == NULL) { return 0; } @@ -494,12 +524,15 @@ retry: mcctrl_ikc_send(data->os, data->cpu, &isp); channel = NULL; /* Wait for a reply. */ + dprintk("now wait for a relpy\n"); wait_event_interruptible(procfsq, procfsq_channel == virt_to_phys(r)); /* Wake up and check the result. */ + dprintk("mckernel_procfs_read: woke up. ret: %d, eof: %d\n", r->ret, r->eof); if ((r->ret == 0) && (r->eof != 1)) { /* A miss-hit has occurred (caused by migration e.g.). * We simply retry the query. */ + dprintk("retry\n"); goto retry; } if (r->eof == 1) { diff --git a/kernel/host.c b/kernel/host.c index 35840d38..c5bb31ab 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -416,7 +416,6 @@ static int process_msg_prepare_process(unsigned long rphys) ihk_mc_unmap_virtual(p, npages, 1); ihk_mc_unmap_memory(NULL, phys, sz); flush_tlb(); - return 0; err: ihk_mc_free(pn); diff --git a/kernel/procfs.c b/kernel/procfs.c index d1988170..a44c1f20 100644 --- a/kernel/procfs.c +++ b/kernel/procfs.c @@ -26,10 +26,10 @@ #define DEBUG_PRINT_PROCFS -#ifdef DEBUG_PRINT_PROCFS -#define dkprintf kprintf +#ifdef DEBUG_PRINT_SC +#define dprintf(...) kprintf(__VA_ARGS__) #else -#define dkprintf(...) +#define dprintf(...) #endif extern int snprintf(char * buf, size_t size, const char *fmt, ...); @@ -56,6 +56,7 @@ void create_proc_procfs_files(int pid, int cpuid) static void create_proc_procfs_file(int pid, char *fname, int mode, int cpuid) { + dprintf("create procfs file: %s, mode: %s, cpuid: %d\n", fname, mode, cpuid); operate_proc_procfs_file(pid, fname, SCD_MSG_PROCFS_CREATE, mode, cpuid); } @@ -69,6 +70,7 @@ void delete_proc_procfs_files(int pid) static void delete_proc_procfs_file(int pid, char *fname) { + dprintf("delete procfs file: %s\n", fname); operate_proc_procfs_file(pid, fname, SCD_MSG_PROCFS_DELETE, 0, 0); } @@ -118,6 +120,8 @@ void process_procfs_request(unsigned long rarg) char *buf; struct ihk_ikc_channel_desc *syscall_channel; + dprintf("process_procfs_request: invoked.\n"); + syscall_channel = get_cpu_local_var(0)->syscall_channel; parg = ihk_mc_map_memory(NULL, rarg, sizeof(struct procfs_read)); @@ -127,17 +131,21 @@ void process_procfs_request(unsigned long rarg) pbuf = ihk_mc_map_memory(NULL, r->pbuf, r->count); buf = ihk_mc_map_virtual(pbuf, r->count, PTATTR_WRITABLE | PTATTR_ACTIVE); + dprintf("fname:%s, offset: %lx, count:%d.\n", r->fname, r->offset, r->count); + /* mcos0/PID/taks/PID/mem */ ret = sscanf(r->fname, "mcos%d/%d/task/%d/mem", &rosnum, &pid, &tid); if ((ret == 3) && (pid == tid) && (osnum == rosnum)) { if (cpu_local_var(current)->pid != pid) { - /* A hit-miss caused by migration */ + /* When the target process is no more here. + This kind of hit-misses are caused by migration */ ans = 0; } else { struct vm_range *range; struct process_vm *vm = proc->vm; ans = -EIO; /* default to an I/O error */ list_for_each_entry(range, &vm->vm_range_list, list) { + dprintf("range: %lx - %lx\n", range->start, range->end); if ((range->start <= r->offset) && (r->offset <= range->end)) { if (r->offset + r->count <= range->end) { @@ -153,10 +161,22 @@ void process_procfs_request(unsigned long rarg) } } } - goto skip; + goto end; } -skip: + /* Processing of other kinds of procfs files should be located here. + Its template is something like what follows: + + ret = scanf(r->fname, "mcos%d/PATTERN", ...) + if ((ret == x) && pattern has matched) { + get the data and write it to the buffer; + ans = written bytes; + goto end; + } + */ + +end: + dprintf("read: %d, eof: %d\n", ans, eof); r->ret = ans; r->eof = eof; packet.msg = SCD_MSG_PROCFS_ANSWER;