Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
192e43c1
Commit
192e43c1
authored
Mar 27, 2018
by
Guy M. Broome
Committed by
Hisham Muhammad
Apr 05, 2018
Browse files
Solaris: Assorted post-LWP code cleanup
parent
75598c13
Changes
1
Hide whitespace changes
Inline
Side-by-side
solaris/SolarisProcessList.c
View file @
192e43c1
...
@@ -171,7 +171,7 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
...
@@ -171,7 +171,7 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) {
static
inline
void
SolarisProcessList_scanMemoryInfo
(
ProcessList
*
pl
)
{
static
inline
void
SolarisProcessList_scanMemoryInfo
(
ProcessList
*
pl
)
{
SolarisProcessList
*
spl
=
(
SolarisProcessList
*
)
pl
;
SolarisProcessList
*
spl
=
(
SolarisProcessList
*
)
pl
;
kstat_t
*
meminfo
=
NULL
;
kstat_t
*
meminfo
=
NULL
;
int
ksrphyserr
=
0
;
int
ksrphyserr
=
-
1
;
kstat_named_t
*
totalmem_pgs
=
NULL
;
kstat_named_t
*
totalmem_pgs
=
NULL
;
kstat_named_t
*
lockedmem_pgs
=
NULL
;
kstat_named_t
*
lockedmem_pgs
=
NULL
;
kstat_named_t
*
pages
=
NULL
;
kstat_named_t
*
pages
=
NULL
;
...
@@ -181,10 +181,6 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
...
@@ -181,10 +181,6 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
uint64_t
totalfree
=
0
;
uint64_t
totalfree
=
0
;
int
nswap
=
0
;
int
nswap
=
0
;
char
*
spath
=
NULL
;
char
*
spath
=
NULL
;
// PAGE_SIZE is a macro to a function call.
// Since we use it so much in here, go ahead copy
// the value locally.
int
pgsiz
=
PAGE_SIZE
;
// Part 1 - physical memory
// Part 1 - physical memory
if
(
spl
->
kd
!=
NULL
)
{
meminfo
=
kstat_lookup
(
spl
->
kd
,
"unix"
,
0
,
"system_pages"
);
}
if
(
spl
->
kd
!=
NULL
)
{
meminfo
=
kstat_lookup
(
spl
->
kd
,
"unix"
,
0
,
"system_pages"
);
}
...
@@ -194,19 +190,19 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
...
@@ -194,19 +190,19 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
lockedmem_pgs
=
kstat_data_lookup
(
meminfo
,
"pageslocked"
);
lockedmem_pgs
=
kstat_data_lookup
(
meminfo
,
"pageslocked"
);
pages
=
kstat_data_lookup
(
meminfo
,
"pagestotal"
);
pages
=
kstat_data_lookup
(
meminfo
,
"pagestotal"
);
pl
->
totalMem
=
((
totalmem_pgs
->
value
.
ui64
)
/
1024
)
*
pgsiz
;
pl
->
totalMem
=
totalmem_pgs
->
value
.
ui64
*
PAGE_SIZE_KB
;
pl
->
usedMem
=
((
lockedmem_pgs
->
value
.
ui64
)
/
1024
)
*
pgsiz
;
pl
->
usedMem
=
lockedmem_pgs
->
value
.
ui64
*
PAGE_SIZE_KB
;
// Not sure how to implement this on Solaris - suggestions welcome!
// Not sure how to implement this on Solaris - suggestions welcome!
pl
->
cachedMem
=
0
;
pl
->
cachedMem
=
0
;
// Not really "buffers" but the best Solaris analogue that I can find to
// Not really "buffers" but the best Solaris analogue that I can find to
// "memory in use but not by programs or the kernel itself"
// "memory in use but not by programs or the kernel itself"
pl
->
buffersMem
=
((
(
totalmem_pgs
->
value
.
ui64
)
/
1024
)
-
(
pages
->
value
.
ui64
)
/
1024
)
*
pgsiz
;
pl
->
buffersMem
=
(
totalmem_pgs
->
value
.
ui64
-
pages
->
value
.
ui64
)
*
PAGE_SIZE_KB
;
}
else
{
}
else
{
// Fall back to basic sysconf if kstat isn't working
// Fall back to basic sysconf if kstat isn't working
pl
->
totalMem
=
sysconf
(
_SC_PHYS_PAGES
)
*
pgsiz
;
pl
->
totalMem
=
sysconf
(
_SC_PHYS_PAGES
)
*
PAGE_SIZE
;
pl
->
buffersMem
=
0
;
pl
->
buffersMem
=
0
;
pl
->
cachedMem
=
0
;
pl
->
cachedMem
=
0
;
pl
->
usedMem
=
pl
->
totalMem
-
(
sysconf
(
_SC_AVPHYS_PAGES
)
*
pgsiz
);
pl
->
usedMem
=
pl
->
totalMem
-
(
sysconf
(
_SC_AVPHYS_PAGES
)
*
PAGE_SIZE
);
}
}
// Part 2 - swap
// Part 2 - swap
...
@@ -231,8 +227,8 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
...
@@ -231,8 +227,8 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
}
}
free
(
sl
);
free
(
sl
);
}
}
pl
->
totalSwap
=
(
totalswap
*
pgsiz
)
/
1024
;
pl
->
totalSwap
=
totalswap
*
PAGE_SIZE_KB
;
pl
->
usedSwap
=
pl
->
totalSwap
-
(
(
totalfree
*
pgsiz
)
/
1024
);
pl
->
usedSwap
=
pl
->
totalSwap
-
(
totalfree
*
PAGE_SIZE_KB
);
}
}
void
ProcessList_delete
(
ProcessList
*
this
)
{
void
ProcessList_delete
(
ProcessList
*
this
)
{
...
@@ -247,9 +243,6 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
...
@@ -247,9 +243,6 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
Process
*
lwp
;
Process
*
lwp
;
SolarisProcess
*
slwp
;
SolarisProcess
*
slwp
;
SolarisProcess
*
sproc
=
(
SolarisProcess
*
)
proc
;
SolarisProcess
*
sproc
=
(
SolarisProcess
*
)
proc
;
Settings
*
settings
=
pl
->
settings
;
bool
hideKernelThreads
=
settings
->
hideKernelThreads
;
bool
hideUserlandThreads
=
settings
->
hideUserlandThreads
;
char
lwpdir
[
MAX_NAME
+
1
];
char
lwpdir
[
MAX_NAME
+
1
];
DIR
*
dir
=
NULL
;
DIR
*
dir
=
NULL
;
FILE
*
fp
=
NULL
;
FILE
*
fp
=
NULL
;
...
@@ -285,7 +278,7 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
...
@@ -285,7 +278,7 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
fread
(
&
_lwprusage
,
sizeof
(
prusage_t
),
1
,
fp
);
fread
(
&
_lwprusage
,
sizeof
(
prusage_t
),
1
,
fp
);
fclose
(
fp
);
fclose
(
fp
);
}
}
slwp
->
is_lwp
=
TRUE
;
slwp
->
is_lwp
=
true
;
if
(
!
preExisting
)
{
if
(
!
preExisting
)
{
lwp
->
basenameOffset
=
-
1
;
lwp
->
basenameOffset
=
-
1
;
...
@@ -333,6 +326,7 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
...
@@ -333,6 +326,7 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
(
void
)
localtime_r
((
time_t
*
)
&
lwp
->
starttime_ctime
,
&
date
);
(
void
)
localtime_r
((
time_t
*
)
&
lwp
->
starttime_ctime
,
&
date
);
strftime
(
lwp
->
starttime_show
,
7
,
((
lwp
->
starttime_ctime
>
tv
.
tv_sec
-
86400
)
?
"%R "
:
"%b%d "
),
&
date
);
strftime
(
lwp
->
starttime_show
,
7
,
((
lwp
->
starttime_ctime
>
tv
.
tv_sec
-
86400
)
?
"%R "
:
"%b%d "
),
&
date
);
ProcessList_add
(
pl
,
lwp
);
ProcessList_add
(
pl
,
lwp
);
lwp
->
show
=
false
;
}
else
{
}
else
{
slwp
->
zoneid
=
sproc
->
zoneid
;
slwp
->
zoneid
=
sproc
->
zoneid
;
lwp
->
pgrp
=
proc
->
pgrp
;
lwp
->
pgrp
=
proc
->
pgrp
;
...
@@ -361,22 +355,12 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
...
@@ -361,22 +355,12 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
slwp
->
projid
=
sproc
->
projid
;
slwp
->
projid
=
sproc
->
projid
;
slwp
->
poolid
=
sproc
->
poolid
;
slwp
->
poolid
=
sproc
->
poolid
;
slwp
->
contid
=
sproc
->
contid
;
slwp
->
contid
=
sproc
->
contid
;
lwp
->
show
=
false
;
}
}
// Top-level process only gets this for the representative LWP
// Top-level process only gets this for the representative LWP
if
(
lwp
->
state
==
'O'
)
proc
->
state
=
'O'
;
if
(
lwp
->
state
==
'O'
)
proc
->
state
=
'O'
;
if
(
slwp
->
kernel
)
{
if
(
slwp
->
kernel
&&
!
pl
->
settings
->
hideKernelThreads
)
lwp
->
show
=
true
;
if
(
!
hideKernelThreads
)
{
if
(
!
slwp
->
kernel
&&
!
pl
->
settings
->
hideUserlandThreads
)
lwp
->
show
=
true
;
lwp
->
show
=
true
;
}
else
{
lwp
->
show
=
false
;
}
}
else
{
if
(
!
hideUserlandThreads
)
{
lwp
->
show
=
true
;
}
else
{
lwp
->
show
=
false
;
}
}
lwp
->
updated
=
true
;
lwp
->
updated
=
true
;
}
}
closedir
(
dir
);
closedir
(
dir
);
...
@@ -385,9 +369,6 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
...
@@ -385,9 +369,6 @@ void ProcessList_enumerateLWPs(Process* proc, char* name, ProcessList* pl, struc
void
ProcessList_goThroughEntries
(
ProcessList
*
this
)
{
void
ProcessList_goThroughEntries
(
ProcessList
*
this
)
{
SolarisProcessList
*
spl
=
(
SolarisProcessList
*
)
this
;
SolarisProcessList
*
spl
=
(
SolarisProcessList
*
)
this
;
Settings
*
settings
=
this
->
settings
;
bool
hideKernelThreads
=
settings
->
hideKernelThreads
;
bool
hideUserlandThreads
=
settings
->
hideUserlandThreads
;
DIR
*
dir
=
NULL
;
DIR
*
dir
=
NULL
;
struct
dirent
*
entry
=
NULL
;
struct
dirent
*
entry
=
NULL
;
char
*
name
=
NULL
;
char
*
name
=
NULL
;
...
@@ -519,38 +500,23 @@ void ProcessList_goThroughEntries(ProcessList* this) {
...
@@ -519,38 +500,23 @@ void ProcessList_goThroughEntries(ProcessList* this) {
if
(
proc
->
nlwp
>
1
)
{
if
(
proc
->
nlwp
>
1
)
{
ProcessList_enumerateLWPs
(
proc
,
name
,
this
,
tv
);
ProcessList_enumerateLWPs
(
proc
,
name
,
this
,
tv
);
}
}
proc
->
show
=
!
(
hideKernelThreads
&&
sproc
->
kernel
);
if
(
sproc
->
kernel
)
{
proc
->
show
=
!
(
this
->
settings
->
hideKernelThreads
&&
sproc
->
kernel
);
if
(
hideKernelThreads
)
{
addRunning
=
0
;
if
(
sproc
->
kernel
&&
!
this
->
settings
->
hideKernelThreads
)
{
addTotal
=
0
;
this
->
kernelThreads
+=
proc
->
nlwp
;
}
else
{
addTotal
=
proc
->
nlwp
+
1
;
this
->
kernelThreads
+=
proc
->
nlwp
;
if
(
proc
->
state
==
'O'
)
addRunning
++
;
if
(
proc
->
state
==
'O'
)
{
}
else
if
(
!
sproc
->
kernel
)
{
addRunning
++
;
if
(
proc
->
state
==
'O'
)
addRunning
++
;
addTotal
=
proc
->
nlwp
+
1
;
if
(
this
->
settings
->
hideUserlandThreads
)
{
}
else
{
addTotal
++
;
addTotal
=
proc
->
nlwp
+
1
;
}
}
}
else
{
if
(
hideUserlandThreads
)
{
if
(
proc
->
state
==
'O'
)
{
addRunning
++
;
addTotal
++
;
}
else
{
addTotal
++
;
}
}
else
{
}
else
{
this
->
userlandThreads
+=
proc
->
nlwp
;
this
->
userlandThreads
+=
proc
->
nlwp
;
if
(
proc
->
state
==
'O'
)
{
addTotal
=
proc
->
nlwp
+
1
;
addRunning
++
;
addTotal
=
proc
->
nlwp
+
1
;
}
else
{
addTotal
=
proc
->
nlwp
+
1
;
}
}
}
}
}
this
->
runningTasks
+=
addRunning
;
this
->
runningTasks
+=
addRunning
;
this
->
totalTasks
+=
addTotal
;
this
->
totalTasks
+=
addTotal
;
proc
->
updated
=
true
;
proc
->
updated
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment