Skip to content

Commit

Permalink
Add /proc/pid/task/tid/schedstat info to thread stack dumps
Browse files Browse the repository at this point in the history
This lets us see whether a usually-blocked thread is actually making
progress in between stack snapshots.

Change-Id: If191627e4572457579d5f330d31bde86b8ce4ec5
  • Loading branch information
Christopher Tate committed Jun 3, 2010
1 parent 2b469f8 commit 962f896
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions vm/Thread.c
Expand Up @@ -3422,6 +3422,8 @@ void dvmDumpThreadEx(const DebugOutputTarget* target, Thread* thread,
int priority; // java.lang.Thread priority
int policy; // pthread policy
struct sched_param sp; // pthread scheduling parameters
char schedstatBuf[64]; // contents of /proc/[pid]/task/[tid]/schedstat
int schedstatFd;

threadObj = thread->threadObj;
if (threadObj == NULL) {
Expand Down Expand Up @@ -3483,6 +3485,19 @@ void dvmDumpThreadEx(const DebugOutputTarget* target, Thread* thread,
thread->systemTid, getpriority(PRIO_PROCESS, thread->systemTid),
policy, sp.sched_priority, schedulerGroupBuf, (int)thread->handle);

snprintf(schedstatBuf, sizeof(schedstatBuf), "/proc/%d/task/%d/schedstat",
getpid(), thread->systemTid);
schedstatFd = open(schedstatBuf, O_RDONLY);
if (schedstatFd >= 0) {
int bytes;
bytes = read(schedstatFd, schedstatBuf, sizeof(schedstatBuf) - 1);
close(schedstatFd);
if (bytes > 1) {
schedstatBuf[bytes-1] = 0; // trailing newline
dvmPrintDebugMessage(target, " | schedstat=( %s )\n", schedstatBuf);
}
}

#ifdef WITH_MONITOR_TRACKING
if (!isRunning) {
LockedObjectData* lod = thread->pLockedObjects;
Expand Down

0 comments on commit 962f896

Please sign in to comment.