wchan for multithreaded process is now ~0ull or "*"

This commit is contained in:
albert 2004-07-21 21:17:35 +00:00
parent 9e52b5aa29
commit 266d5b708a
7 changed files with 23 additions and 12 deletions

1
NEWS
View File

@ -4,6 +4,7 @@ avoid truncating long usernames
avoid warning about -lncurses when not linking (more) avoid warning about -lncurses when not linking (more)
new names for shared libraries (packagers: watch out!) new names for shared libraries (packagers: watch out!)
"make install" no longer rebuilds everything "make install" no longer rebuilds everything
wchan now '*' for multi-threaded processes
procps-3.2.1 --> procps-3.2.2 procps-3.2.1 --> procps-3.2.2

View File

@ -109,9 +109,6 @@ typedef struct symb {
unsigned KLONG addr; unsigned KLONG addr;
} symb; } symb;
static const symb fail = { "?", 0 };
static const char dash[] = "-";
/* These mostly rely on POSIX to make them zero. */ /* These mostly rely on POSIX to make them zero. */
static symb hashtable[256]; static symb hashtable[256];
@ -602,10 +599,14 @@ static const char * read_wchan_file(unsigned pid){
/***************************************/ /***************************************/
static const symb fail = { .name = "?" };
static const char dash[] = "-";
static const char star[] = "*";
#define MAX_OFFSET (0x1000*sizeof(long)) /* past this is generally junk */ #define MAX_OFFSET (0x1000*sizeof(long)) /* past this is generally junk */
/* return pointer to temporary static buffer with function name */ /* return pointer to temporary static buffer with function name */
const char * wchan(unsigned KLONG address, unsigned pid) { const char * lookup_wchan(unsigned KLONG address, unsigned pid) {
const symb *mod_symb; const symb *mod_symb;
const symb *map_symb; const symb *map_symb;
const symb *good_symb; const symb *good_symb;
@ -616,6 +617,7 @@ const char * wchan(unsigned KLONG address, unsigned pid) {
if(use_wchan_file) return read_wchan_file(pid); if(use_wchan_file) return read_wchan_file(pid);
if(!address) return dash; if(!address) return dash;
if(!~address) return star;
read_and_parse(); read_and_parse();
hash = (address >> 4) & 0xff; /* got 56/63 hits & 7/63 misses */ hash = (address >> 4) & 0xff; /* got 56/63 hits & 7/63 misses */

View File

@ -1,3 +1,6 @@
# for --version-script
# WTF is the syntax for this file?
# Give me a BNF, man!
_3_1_14 { _3_1_14 {
global: global:
__cyg_profile_func_enter; __cyg_profile_func_exit; main; __cyg_profile_func_enter; __cyg_profile_func_exit; main;
@ -5,7 +8,7 @@ global:
readproc; readtask; readproctab; readproctab2; look_up_our_self; escape_command; readproc; readtask; readproctab; readproctab2; look_up_our_self; escape_command;
escape_str; escape_strlist; escape_str; escape_strlist;
openproc; closeproc; openproc; closeproc;
tty_to_dev; dev_to_tty; open_psdb_message; open_psdb; wchan; tty_to_dev; dev_to_tty; open_psdb_message; open_psdb; lookup_wchan;
display_version; procps_version; linux_version_code; display_version; procps_version; linux_version_code;
Hertz; smp_num_cpus; Hertz; smp_num_cpus;
sprint_uptime; uptime; user_from_uid; print_uptime; loadavg; sprint_uptime; uptime; user_from_uid; print_uptime; loadavg;

View File

@ -521,7 +521,12 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons
} }
} }
/* some number->text resolving which is time consuming */ // if multithreaded, some values are crap
if(p->nlwp > 1){
p->wchan = (KLONG)~0ull;
}
/* some number->text resolving which is time consuming and kind of insane */
if (flags & PROC_FILLUSR){ if (flags & PROC_FILLUSR){
memcpy(p->euser, user_from_uid(p->euid), sizeof p->euser); memcpy(p->euser, user_from_uid(p->euid), sizeof p->euser);
if(flags & PROC_FILLSTATUS) { if(flags & PROC_FILLSTATUS) {
@ -531,7 +536,7 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons
} }
} }
/* some number->text resolving which is time consuming */ /* some number->text resolving which is time consuming and kind of insane */
if (flags & PROC_FILLGRP){ if (flags & PROC_FILLGRP){
memcpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup); memcpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
if(flags & PROC_FILLSTATUS) { if(flags & PROC_FILLSTATUS) {

View File

@ -5,7 +5,7 @@
EXTERN_C_BEGIN EXTERN_C_BEGIN
extern const char * wchan(unsigned KLONG address, unsigned pid); extern const char * lookup_wchan(unsigned KLONG address, unsigned pid);
extern int open_psdb(const char *restrict override); extern int open_psdb(const char *restrict override);
extern int open_psdb_message(const char *restrict override, void (*message)(const char *, ...)); extern int open_psdb_message(const char *restrict override, void (*message)(const char *, ...));

View File

@ -502,7 +502,7 @@ static int pr_wchan(char *restrict const outbuf, const proc_t *restrict const pp
*/ */
if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, COLWID, "%s", "-"); if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, COLWID, "%s", "-");
if(wchan_is_number) return snprintf(outbuf, COLWID, "%x", (unsigned)(pp->wchan) & 0xffffffu); if(wchan_is_number) return snprintf(outbuf, COLWID, "%x", (unsigned)(pp->wchan) & 0xffffffu);
return snprintf(outbuf, COLWID, "%s", wchan(pp->wchan, pp->XXXID)); return snprintf(outbuf, COLWID, "%s", lookup_wchan(pp->wchan, pp->XXXID));
} }
/* Terrible trunctuation, like BSD crap uses: I999 J999 K999 */ /* Terrible trunctuation, like BSD crap uses: I999 J999 K999 */
@ -704,7 +704,7 @@ static int pr_wname(char *restrict const outbuf, const proc_t *restrict const pp
* more than one thread waiting in the kernel. * more than one thread waiting in the kernel.
*/ */
if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, COLWID, "%s", "-"); if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, COLWID, "%s", "-");
return snprintf(outbuf, COLWID, "%s", wchan(pp->wchan, pp->XXXID)); return snprintf(outbuf, COLWID, "%s", lookup_wchan(pp->wchan, pp->XXXID));
} }
static int pr_nwchan(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_nwchan(char *restrict const outbuf, const proc_t *restrict const pp){

2
top.c
View File

@ -3024,7 +3024,7 @@ static void task_show (const WIN_t *q, const proc_t *p)
f = " %08lx "; f = " %08lx ";
MKCOL((long)p->wchan); MKCOL((long)p->wchan);
} else { } else {
MKCOL(wchan(p->wchan, p->XXXID)); MKCOL(lookup_wchan(p->wchan, p->XXXID));
} }
break; break;