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
1b5025e6
Commit
1b5025e6
authored
Feb 12, 2016
by
Juan Francisco Cantero Hurtado
Browse files
Add support for cachedMem and fix usedMem on OpenBSD.
parent
1bedac1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
openbsd/OpenBSDProcessList.c
View file @
1b5025e6
...
...
@@ -10,18 +10,19 @@ in the source distribution for its full text.
#include "OpenBSDProcessList.h"
#include "OpenBSDProcess.h"
#include <unistd.h>
#include <stdlib.h>
#include <err.h>
#include <errno.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/user.h>
#include <
fcntl
.h>
#include <
stdlib
.h>
#include <string.h>
#include <
sys/resource
.h>
#include <
unistd
.h>
/*{
...
...
@@ -95,16 +96,28 @@ void ProcessList_delete(ProcessList* this) {
static
inline
void
OpenBSDProcessList_scanMemoryInfo
(
ProcessList
*
pl
)
{
static
int
uvmexp_mib
[]
=
{
CTL_VM
,
VM_UVMEXP
};
struct
uvmexp
uvmexp
;
size_t
size
=
sizeof
(
uvmexp
);
size_t
size
_uvmexp
=
sizeof
(
uvmexp
);
if
(
sysctl
(
uvmexp_mib
,
2
,
&
uvmexp
,
&
size
,
NULL
,
0
)
<
0
)
{
if
(
sysctl
(
uvmexp_mib
,
2
,
&
uvmexp
,
&
size
_uvmexp
,
NULL
,
0
)
<
0
)
{
err
(
1
,
"uvmexp sysctl call failed"
);
}
//kb_pagesize = uvmexp.pagesize / 1024;
pl
->
usedMem
=
uvmexp
.
active
*
pageSizeKb
;
pl
->
totalMem
=
uvmexp
.
npages
*
pageSizeKb
;
// Taken from OpenBSD systat/iostat.c, top/machine.c and uvm_sysctl(9)
static
int
bcache_mib
[]
=
{
CTL_VFS
,
VFS_GENERIC
,
VFS_BCACHESTAT
};
struct
bcachestats
bcstats
;
size_t
size_bcstats
=
sizeof
(
bcstats
);
if
(
sysctl
(
bcache_mib
,
3
,
&
bcstats
,
&
size_bcstats
,
NULL
,
0
)
<
0
)
{
err
(
1
,
"cannot get vfs.bcachestat"
);
}
pl
->
cachedMem
=
bcstats
.
numbufpages
*
pageSizeKb
;
pl
->
freeMem
=
uvmexp
.
free
*
pageSizeKb
;
pl
->
usedMem
=
(
uvmexp
.
npages
-
uvmexp
.
free
-
uvmexp
.
paging
)
*
pageSizeKb
;
/*
const OpenBSDProcessList* opl = (OpenBSDProcessList*) pl;
...
...
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