proc: resurrect /proc/PID/stat and fix a few fields

Change-Id: I8ffcfde4db78c66ea10845a0451ae2610261f832
This commit is contained in:
Balazs Gerofi
2019-03-15 01:20:46 +09:00
committed by Dominique Martinet
parent e5c1fdf129
commit 2ce695b47b
3 changed files with 45 additions and 3 deletions

View File

@ -1113,7 +1113,7 @@ static const struct procfs_entry pid_entry_stuff[] = {
PROC_REG("mem", 0400, NULL), PROC_REG("mem", 0400, NULL),
PROC_REG("pagemap", 0444, NULL), PROC_REG("pagemap", 0444, NULL),
// PROC_REG("smaps", S_IRUGO, NULL), // PROC_REG("smaps", S_IRUGO, NULL),
// PROC_REG("stat", 0444, &mckernel_buff_io), PROC_REG("stat", 0444, &mckernel_buff_io),
// PROC_REG("statm", S_IRUGO, NULL), // PROC_REG("statm", S_IRUGO, NULL),
PROC_REG("status", 0444, &mckernel_buff_io), PROC_REG("status", 0444, &mckernel_buff_io),
// PROC_REG("syscall", S_IRUGO, NULL), // PROC_REG("syscall", S_IRUGO, NULL),

View File

@ -669,6 +669,42 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
} }
if (!strcmp(p, "stat")) { if (!strcmp(p, "stat")) {
const char *comm = "exe";
char state;
if (proc->saved_cmdline) {
comm = strrchr(proc->saved_cmdline, '/');
if (comm)
comm++;
else
comm = proc->saved_cmdline;
}
switch (thread->status & (0x3f)) {
case PS_INTERRUPTIBLE:
state = 'S';
break;
case PS_UNINTERRUPTIBLE:
state = 'D';
break;
case PS_ZOMBIE:
state = 'Z';
break;
case PS_EXITED:
state = 'X';
break;
case PS_STOPPED:
state = 'T';
break;
case PS_RUNNING:
default:
if (thread->in_syscall_offload > 0) {
state = 'S';
}
else {
state = 'R';
}
}
/* /*
* pid (comm) state ppid * pid (comm) state ppid
@ -695,8 +731,9 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
"%lu %lu %lu %lu " // sigignore... "%lu %lu %lu %lu " // sigignore...
"%lu %d %d %u " // cnswap... "%lu %d %d %u " // cnswap...
"%u %llu %lu %ld\n", // policy... "%u %llu %lu %ld\n", // policy...
0, "exe", 'R', 0, // pid... thread->tid, comm, state,
0, 0, 0, 0, // pgrp... thread->proc->ppid_parent->pid, // pid...
thread->proc->pid, 0, 0, 0, // pgrp...
0, 0L, 0L, 0L, // flags... 0, 0L, 0L, 0L, // flags...
0L, 0L, 0L, 0L, // cmajflt... 0L, 0L, 0L, 0L, // cmajflt...
0L, 0L, 0L, 0L, // cstime... 0L, 0L, 0L, 0L, // cstime...

View File

@ -4324,6 +4324,7 @@ SYSCALL_DECLARE(rt_sigtimedwait)
thread->sigevent = 1; thread->sigevent = 1;
for(;;){ for(;;){
while(thread->sigevent == 0){ while(thread->sigevent == 0){
thread->status = PS_INTERRUPTIBLE;
if(timeout){ if(timeout){
if (gettime_local_support) if (gettime_local_support)
calculate_time_from_tsc(&ats); calculate_time_from_tsc(&ats);
@ -4340,6 +4341,7 @@ SYSCALL_DECLARE(rt_sigtimedwait)
thread->sigevent = 0; thread->sigevent = 0;
#endif /* POSTK_DEBUG_TEMP_FIX_33 */ #endif /* POSTK_DEBUG_TEMP_FIX_33 */
thread->status = PS_RUNNING;
lock = &thread->sigcommon->lock; lock = &thread->sigcommon->lock;
head = &thread->sigcommon->sigpending; head = &thread->sigcommon->sigpending;
mcs_rwlock_writer_lock(lock, &mcs_rw_node); mcs_rwlock_writer_lock(lock, &mcs_rw_node);
@ -4454,6 +4456,8 @@ do_sigsuspend(struct thread *thread, const sigset_t *set)
int do_schedule = 0; int do_schedule = 0;
struct cpu_local_var *v; struct cpu_local_var *v;
long runq_irqstate; long runq_irqstate;
thread->status = PS_INTERRUPTIBLE;
runq_irqstate = runq_irqstate =
ihk_mc_spinlock_lock(&(get_this_cpu_local_var()->runq_lock)); ihk_mc_spinlock_lock(&(get_this_cpu_local_var()->runq_lock));
v = get_this_cpu_local_var(); v = get_this_cpu_local_var();
@ -4475,6 +4479,7 @@ do_sigsuspend(struct thread *thread, const sigset_t *set)
thread->sigevent = 0; thread->sigevent = 0;
#endif /* POSTK_DEBUG_TEMP_FIX_33 */ #endif /* POSTK_DEBUG_TEMP_FIX_33 */
thread->status = PS_RUNNING;
lock = &thread->sigcommon->lock; lock = &thread->sigcommon->lock;
head = &thread->sigcommon->sigpending; head = &thread->sigcommon->sigpending;
mcs_rwlock_writer_lock(lock, &mcs_rw_node); mcs_rwlock_writer_lock(lock, &mcs_rw_node);