Added debug messages.
This commit is contained in:
@@ -34,6 +34,14 @@
|
|||||||
#include <sysdeps/mic/mic/micconst.h>
|
#include <sysdeps/mic/mic/micconst.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//#define IKC_DEBUG
|
||||||
|
|
||||||
|
#ifdef IKC_DEBUG
|
||||||
|
#define dprintk(...) printk(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define dprintk(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define REQUEST_SHIFT 16
|
#define REQUEST_SHIFT 16
|
||||||
|
|
||||||
//int num_channels;
|
//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 DECLARE_WAIT_QUEUE_HEAD(procfsq);
|
||||||
static unsigned long procfsq_channel;
|
static unsigned long procfsq_channel;
|
||||||
|
static ihk_spinlock_t procfsq_lock;
|
||||||
|
|
||||||
int mckernel_procfs_read(char *buffer, char **start, off_t offset,
|
int mckernel_procfs_read(char *buffer, char **start, off_t offset,
|
||||||
int count, int *peof, void *dat);
|
int count, int *peof, void *dat);
|
||||||
@@ -65,6 +74,7 @@ struct procfs_list_entry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
LIST_HEAD(procfs_file_list);
|
LIST_HEAD(procfs_file_list);
|
||||||
|
static ihk_spinlock_t procfs_file_list_lock;
|
||||||
|
|
||||||
static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||||
void *__packet, void *__os)
|
void *__packet, void *__os)
|
||||||
@@ -97,11 +107,15 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
|||||||
struct procfs_list_entry *e;
|
struct procfs_list_entry *e;
|
||||||
int mode;
|
int mode;
|
||||||
ihk_device_t dev = ihk_os_to_dev(__os);
|
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);
|
d = kmalloc(sizeof(struct procfs_data), GFP_KERNEL);
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
kprintf("ERROR: not enough memory to create PROCFS entry.\n");
|
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->osnum = pisp->osnum;
|
||||||
d->os = __os;
|
d->os = __os;
|
||||||
d->cpu = pisp->ref;
|
d->cpu = pisp->ref;
|
||||||
@@ -114,6 +128,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
|||||||
f->status = 1; /* done */
|
f->status = 1; /* done */
|
||||||
ihk_device_unmap_virtual(dev, f, sizeof(struct procfs_file));
|
ihk_device_unmap_virtual(dev, f, sizeof(struct procfs_file));
|
||||||
ihk_device_unmap_memory(dev, parg, 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);
|
entry = create_proc_entry(d->fname, mode, NULL);
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
@@ -123,6 +138,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
|||||||
}
|
}
|
||||||
entry->data = d;
|
entry->data = d;
|
||||||
entry->read_proc = mckernel_procfs_read;
|
entry->read_proc = mckernel_procfs_read;
|
||||||
|
dprintk("made a proc entry.\n");
|
||||||
|
|
||||||
e = kmalloc(sizeof(struct procfs_list_entry), GFP_KERNEL);
|
e = kmalloc(sizeof(struct procfs_list_entry), GFP_KERNEL);
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
@@ -131,7 +147,10 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
|||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
e->data = d;
|
e->data = d;
|
||||||
|
irqflags = ihk_ikc_spinlock_lock(&procfs_file_list_lock);
|
||||||
list_add(&(e->list), &procfs_file_list);
|
list_add(&(e->list), &procfs_file_list);
|
||||||
|
ihk_ikc_spinlock_unlock(&procfs_file_list_lock, irqflags);
|
||||||
|
dprintk("added to a procfs list.\n");
|
||||||
}
|
}
|
||||||
quit:
|
quit:
|
||||||
break;
|
break;
|
||||||
@@ -141,26 +160,34 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
|||||||
unsigned long parg;
|
unsigned long parg;
|
||||||
struct procfs_file *f;
|
struct procfs_file *f;
|
||||||
struct procfs_list_entry *e;
|
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));
|
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);
|
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) {
|
list_for_each_entry(e, &procfs_file_list, list) {
|
||||||
if (strncmp(e->data->fname, f->fname, PROCFS_NAME_MAX) == 0) {
|
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);
|
list_del(&e->list);
|
||||||
|
ihk_ikc_spinlock_unlock(&procfs_file_list_lock, irqflags);
|
||||||
kfree(e->data);
|
kfree(e->data);
|
||||||
kfree(e);
|
kfree(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remove_proc_entry(f->fname, NULL);
|
remove_proc_entry(f->fname, NULL);
|
||||||
|
dprintk("removed procfs entry.\n");
|
||||||
ihk_device_unmap_virtual(dev, f, sizeof(struct procfs_file));
|
ihk_device_unmap_virtual(dev, f, sizeof(struct procfs_file));
|
||||||
ihk_device_unmap_memory(dev, parg, sizeof(struct procfs_file));
|
ihk_device_unmap_memory(dev, parg, sizeof(struct procfs_file));
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCD_MSG_PROCFS_ANSWER:
|
case SCD_MSG_PROCFS_ANSWER:
|
||||||
|
dprintk("ikc: received SCD_MSG_PROCFS_ANSWER message.\n");
|
||||||
procfsq_channel = pisp->arg;
|
procfsq_channel = pisp->arg;
|
||||||
wake_up(&procfsq);
|
wake_up_interruptible(&procfsq);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,6 +495,9 @@ int mckernel_procfs_read(char *buffer, char **start, off_t offset,
|
|||||||
int ret;
|
int ret;
|
||||||
unsigned long pbuf;
|
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) {
|
if (count <= 0 || dat == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -494,12 +524,15 @@ retry:
|
|||||||
mcctrl_ikc_send(data->os, data->cpu, &isp);
|
mcctrl_ikc_send(data->os, data->cpu, &isp);
|
||||||
channel = NULL;
|
channel = NULL;
|
||||||
/* Wait for a reply. */
|
/* Wait for a reply. */
|
||||||
|
dprintk("now wait for a relpy\n");
|
||||||
wait_event_interruptible(procfsq, procfsq_channel == virt_to_phys(r));
|
wait_event_interruptible(procfsq, procfsq_channel == virt_to_phys(r));
|
||||||
/* Wake up and check the result. */
|
/* 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)) {
|
if ((r->ret == 0) && (r->eof != 1)) {
|
||||||
/* A miss-hit has occurred (caused by migration e.g.).
|
/* A miss-hit has occurred (caused by migration e.g.).
|
||||||
* We simply retry the query.
|
* We simply retry the query.
|
||||||
*/
|
*/
|
||||||
|
dprintk("retry\n");
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
if (r->eof == 1) {
|
if (r->eof == 1) {
|
||||||
|
|||||||
@@ -416,7 +416,6 @@ static int process_msg_prepare_process(unsigned long rphys)
|
|||||||
ihk_mc_unmap_virtual(p, npages, 1);
|
ihk_mc_unmap_virtual(p, npages, 1);
|
||||||
ihk_mc_unmap_memory(NULL, phys, sz);
|
ihk_mc_unmap_memory(NULL, phys, sz);
|
||||||
flush_tlb();
|
flush_tlb();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
ihk_mc_free(pn);
|
ihk_mc_free(pn);
|
||||||
|
|||||||
@@ -26,10 +26,10 @@
|
|||||||
|
|
||||||
#define DEBUG_PRINT_PROCFS
|
#define DEBUG_PRINT_PROCFS
|
||||||
|
|
||||||
#ifdef DEBUG_PRINT_PROCFS
|
#ifdef DEBUG_PRINT_SC
|
||||||
#define dkprintf kprintf
|
#define dprintf(...) kprintf(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define dkprintf(...)
|
#define dprintf(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int snprintf(char * buf, size_t size, const char *fmt, ...);
|
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)
|
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);
|
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)
|
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);
|
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;
|
char *buf;
|
||||||
struct ihk_ikc_channel_desc *syscall_channel;
|
struct ihk_ikc_channel_desc *syscall_channel;
|
||||||
|
|
||||||
|
dprintf("process_procfs_request: invoked.\n");
|
||||||
|
|
||||||
syscall_channel = get_cpu_local_var(0)->syscall_channel;
|
syscall_channel = get_cpu_local_var(0)->syscall_channel;
|
||||||
|
|
||||||
parg = ihk_mc_map_memory(NULL, rarg, sizeof(struct procfs_read));
|
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);
|
pbuf = ihk_mc_map_memory(NULL, r->pbuf, r->count);
|
||||||
buf = ihk_mc_map_virtual(pbuf, r->count, PTATTR_WRITABLE | PTATTR_ACTIVE);
|
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 */
|
/* mcos0/PID/taks/PID/mem */
|
||||||
ret = sscanf(r->fname, "mcos%d/%d/task/%d/mem", &rosnum, &pid, &tid);
|
ret = sscanf(r->fname, "mcos%d/%d/task/%d/mem", &rosnum, &pid, &tid);
|
||||||
if ((ret == 3) && (pid == tid) && (osnum == rosnum)) {
|
if ((ret == 3) && (pid == tid) && (osnum == rosnum)) {
|
||||||
if (cpu_local_var(current)->pid != pid) {
|
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;
|
ans = 0;
|
||||||
} else {
|
} else {
|
||||||
struct vm_range *range;
|
struct vm_range *range;
|
||||||
struct process_vm *vm = proc->vm;
|
struct process_vm *vm = proc->vm;
|
||||||
ans = -EIO; /* default to an I/O error */
|
ans = -EIO; /* default to an I/O error */
|
||||||
list_for_each_entry(range, &vm->vm_range_list, list) {
|
list_for_each_entry(range, &vm->vm_range_list, list) {
|
||||||
|
dprintf("range: %lx - %lx\n", range->start, range->end);
|
||||||
if ((range->start <= r->offset) &&
|
if ((range->start <= r->offset) &&
|
||||||
(r->offset <= range->end)) {
|
(r->offset <= range->end)) {
|
||||||
if (r->offset + r->count <= 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->ret = ans;
|
||||||
r->eof = eof;
|
r->eof = eof;
|
||||||
packet.msg = SCD_MSG_PROCFS_ANSWER;
|
packet.msg = SCD_MSG_PROCFS_ANSWER;
|
||||||
|
|||||||
Reference in New Issue
Block a user