Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
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
e77811e9
Commit
e77811e9
authored
9 years ago
by
Hisham
Browse files
Options
Download
Email Patches
Plain Diff
any of these values may wrap
parent
797bcd09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
linux/LinuxProcessList.c
+14
-22
linux/LinuxProcessList.c
with
14 additions
and
22 deletions
+14
-22
linux/LinuxProcessList.c
View file @
e77811e9
...
...
@@ -721,31 +721,23 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
unsigned
long
long
int
virtalltime
=
guest
+
guestnice
;
unsigned
long
long
int
totaltime
=
usertime
+
nicetime
+
systemalltime
+
idlealltime
+
steal
+
virtalltime
;
CPUData
*
cpuData
=
&
(
this
->
cpus
[
i
]);
assert
(
systemtime
>=
cpuData
->
systemTime
);
assert
(
idletime
>=
cpuData
->
idleTime
);
assert
(
totaltime
>=
cpuData
->
totalTime
);
assert
(
systemalltime
>=
cpuData
->
systemAllTime
);
assert
(
idlealltime
>=
cpuData
->
idleAllTime
);
assert
(
ioWait
>=
cpuData
->
ioWaitTime
);
assert
(
irq
>=
cpuData
->
irqTime
);
assert
(
softIrq
>=
cpuData
->
softIrqTime
);
assert
(
steal
>=
cpuData
->
stealTime
);
assert
(
virtalltime
>=
cpuData
->
guestTime
);
// Since we do a subtraction (usertime - guest) and cputime64_to_clock_t()
// used in /proc/stat rounds down numbers, it can lead to a case where the
// integer overflow.
cpuData
->
userPeriod
=
(
usertime
>
cpuData
->
userTime
)
?
usertime
-
cpuData
->
userTime
:
0
;
cpuData
->
nicePeriod
=
(
nicetime
>
cpuData
->
niceTime
)
?
nicetime
-
cpuData
->
niceTime
:
0
;
cpuData
->
systemPeriod
=
systemtime
-
cpuData
->
systemTime
;
cpuData
->
systemAllPeriod
=
systemalltime
-
cpuData
->
systemAllTime
;
cpuData
->
idleAllPeriod
=
idlealltime
-
cpuData
->
idleAllTime
;
cpuData
->
idlePeriod
=
idletime
-
cpuData
->
idleTime
;
cpuData
->
ioWaitPeriod
=
ioWait
-
cpuData
->
ioWaitTime
;
cpuData
->
irqPeriod
=
irq
-
cpuData
->
irqTime
;
cpuData
->
softIrqPeriod
=
softIrq
-
cpuData
->
softIrqTime
;
cpuData
->
stealPeriod
=
steal
-
cpuData
->
stealTime
;
cpuData
->
guestPeriod
=
virtalltime
-
cpuData
->
guestTime
;
cpuData
->
totalPeriod
=
totaltime
-
cpuData
->
totalTime
;
#define WRAP_SUBTRACT(a,b) (a > b) ? a - b : 0
cpuData
->
userPeriod
=
WRAP_SUBTRACT
(
usertime
,
cpuData
->
userTime
);
cpuData
->
nicePeriod
=
WRAP_SUBTRACT
(
nicetime
,
cpuData
->
niceTime
);
cpuData
->
systemPeriod
=
WRAP_SUBTRACT
(
systemtime
,
cpuData
->
systemTime
);
cpuData
->
systemAllPeriod
=
WRAP_SUBTRACT
(
systemalltime
,
cpuData
->
systemAllTime
);
cpuData
->
idleAllPeriod
=
WRAP_SUBTRACT
(
idlealltime
,
cpuData
->
idleAllTime
);
cpuData
->
idlePeriod
=
WRAP_SUBTRACT
(
idletime
,
cpuData
->
idleTime
);
cpuData
->
ioWaitPeriod
=
WRAP_SUBTRACT
(
ioWait
,
cpuData
->
ioWaitTime
);
cpuData
->
irqPeriod
=
WRAP_SUBTRACT
(
irq
,
cpuData
->
irqTime
);
cpuData
->
softIrqPeriod
=
WRAP_SUBTRACT
(
softIrq
,
cpuData
->
softIrqTime
);
cpuData
->
stealPeriod
=
WRAP_SUBTRACT
(
steal
,
cpuData
->
stealTime
);
cpuData
->
guestPeriod
=
WRAP_SUBTRACT
(
virtalltime
,
cpuData
->
guestTime
);
cpuData
->
totalPeriod
=
WRAP_SUBTRACT
(
totaltime
,
cpuData
->
totalTime
);
#undef WRAP_SUBTRACT
cpuData
->
userTime
=
usertime
;
cpuData
->
niceTime
=
nicetime
;
cpuData
->
systemTime
=
systemtime
;
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help