modify procfs to read inactive thread's files
However, the following files can be read only if the corresponding thread is in active. - /proc/<PID>/mem - /proc/<PID>/task/<TID>/mem refs #371
This commit is contained in:
@@ -253,6 +253,7 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
unsigned long offset;
|
unsigned long offset;
|
||||||
int count;
|
int count;
|
||||||
int npages;
|
int npages;
|
||||||
|
int is_current = 1; /* is 'proc' same as 'current'? */
|
||||||
|
|
||||||
dprintf("process_procfs_request: invoked.\n");
|
dprintf("process_procfs_request: invoked.\n");
|
||||||
|
|
||||||
@@ -325,16 +326,25 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
|
|
||||||
dprintf("mismatched pid. We are %d, but requested pid is %d.\n",
|
dprintf("mismatched pid. We are %d, but requested pid is %d.\n",
|
||||||
pid, cpu_local_var(current)->pid);
|
pid, cpu_local_var(current)->pid);
|
||||||
if ((proc = findthread_and_lock(pid, tid, &savelock, &irqstate))){
|
tid = pid; /* main thread */
|
||||||
|
proc = findthread_and_lock(pid, tid, &savelock, &irqstate);
|
||||||
|
if (!proc) {
|
||||||
|
dprintf("We cannot find the proper cpu for requested pid.\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
else if (proc->cpu_id != ihk_mc_get_processor_id()) {
|
||||||
/* The target process has gone by migration. */
|
/* The target process has gone by migration. */
|
||||||
r->newcpu = proc->cpu_id;
|
r->newcpu = proc->cpu_id;
|
||||||
dprintf("expected cpu id is %d.\n", proc->cpu_id);
|
dprintf("expected cpu id is %d.\n", proc->cpu_id);
|
||||||
process_unlock(savelock, irqstate);
|
process_unlock(savelock, irqstate);
|
||||||
ans = 0;
|
ans = 0;
|
||||||
} else {
|
goto end;
|
||||||
dprintf("We cannot find the proper cpu for requested pid.\n");
|
}
|
||||||
|
else {
|
||||||
|
process_unlock(savelock, irqstate);
|
||||||
|
/* 'proc' is not 'current' */
|
||||||
|
is_current = 0;
|
||||||
}
|
}
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(p, "stat")) { /* "/proc/stat" */
|
else if (!strcmp(p, "stat")) { /* "/proc/stat" */
|
||||||
@@ -381,6 +391,9 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
struct vm_range *range;
|
struct vm_range *range;
|
||||||
struct process_vm *vm = proc->vm;
|
struct process_vm *vm = proc->vm;
|
||||||
|
|
||||||
|
if (!is_current) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
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);
|
dprintf("range: %lx - %lx\n", range->start, range->end);
|
||||||
if ((range->start <= r->offset) &&
|
if ((range->start <= r->offset) &&
|
||||||
@@ -539,6 +552,9 @@ void process_procfs_request(unsigned long rarg)
|
|||||||
struct vm_range *range;
|
struct vm_range *range;
|
||||||
struct process_vm *vm = proc->vm;
|
struct process_vm *vm = proc->vm;
|
||||||
|
|
||||||
|
if (!is_current) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
if (pid != tid) {
|
if (pid != tid) {
|
||||||
/* We are not multithreaded yet. */
|
/* We are not multithreaded yet. */
|
||||||
goto end;
|
goto end;
|
||||||
|
|||||||
Reference in New Issue
Block a user