âvmstatâ says there is paging activity - how to identify the swapping process?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a scenario where I can see there is paging activity on my Ubuntu 16.04 laptop using vmstat 1 100
.
Due to the sheer size of the current load it is expected that processes are more or less swapped out to disk which is fine. I would, however, like to identify those that cause pages to swapped in all the time (as identified by vmstat
) as this might indicate that memory allocation could be improved.
My sysadmin skills are a bit rusty but I am comfortable in a root shell.
What commands should I use to identify the processes which are causing swapping activity?
linux ubuntu swap
add a comment |Â
up vote
1
down vote
favorite
I have a scenario where I can see there is paging activity on my Ubuntu 16.04 laptop using vmstat 1 100
.
Due to the sheer size of the current load it is expected that processes are more or less swapped out to disk which is fine. I would, however, like to identify those that cause pages to swapped in all the time (as identified by vmstat
) as this might indicate that memory allocation could be improved.
My sysadmin skills are a bit rusty but I am comfortable in a root shell.
What commands should I use to identify the processes which are causing swapping activity?
linux ubuntu swap
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a scenario where I can see there is paging activity on my Ubuntu 16.04 laptop using vmstat 1 100
.
Due to the sheer size of the current load it is expected that processes are more or less swapped out to disk which is fine. I would, however, like to identify those that cause pages to swapped in all the time (as identified by vmstat
) as this might indicate that memory allocation could be improved.
My sysadmin skills are a bit rusty but I am comfortable in a root shell.
What commands should I use to identify the processes which are causing swapping activity?
linux ubuntu swap
I have a scenario where I can see there is paging activity on my Ubuntu 16.04 laptop using vmstat 1 100
.
Due to the sheer size of the current load it is expected that processes are more or less swapped out to disk which is fine. I would, however, like to identify those that cause pages to swapped in all the time (as identified by vmstat
) as this might indicate that memory allocation could be improved.
My sysadmin skills are a bit rusty but I am comfortable in a root shell.
What commands should I use to identify the processes which are causing swapping activity?
linux ubuntu swap
edited Feb 1 at 7:31
galoget
36319
36319
asked Jan 31 at 9:46
Thorbjørn Ravn Andersen
821714
821714
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
With performance problems (e.g. high CPU iowait times) it's generally best to monitor these things over time rather than after the fact, especially when short-lived processes might be the culprit. On Linux one tool you can use interactively is iotop
(fixed link) (see also the answers to this question about tracking disk I/O). You can script this (batch mode) or run it interactively like top
, use the cursor keys to sort by SWAPIN, or use the -o
option so the output isn't so cluttered. You will need Python âÂÂ¥2.7 and various kernel configuration parameters enabled (see iotop
's README
or man page).
Rather than use only data from /proc
like vmstat
, iotop
uses taskstats
, this uses netlink IPC to efficiently provide process accounting directly from the kernel to user space.
On most flavours of Linux with the default "swappiness" setting of 60, it's fairly normal to see paging activity when the system is moderately busy: the kernel is pre-emptively writing little-used process pages to swap instead of purging more recently used disk cache pages. (There's a related parameter vfs_cache_pressure
to tune some cacheing behaviour.) If you observe persistent ongoing paging, then there is likely more to it than just this.
Otherwise, if you are concerned about swap use right now rather than over time: the kernel keeps track of swap use per process in /proc/PID/status
. You can do something quick with gawk
(âÂÂ¥v4.0):
gawk '/^Name:/nm=$2 /^Pid:/pid=$2 /^VmSwap:/sw=$2
ENDFILEprintf("%-24s %6i %6ikiBn",nm,pid,sw)' /proc/[0-9]*/status |
sort -h -k 3
According to the documentation shmem (shared memory) that's swapped out is not counted here, but you hopefully won't need to care about that. Eric Ljungstrom's getswap.sh
script can also be used, there's a more advanced version of it in this answer.
Just to be clear - I am not seeing swap usage increased but that apparently some processes are reading in pages all the time. I want to identify these. Can iotop do that?
â Thorbjørn Ravn Andersen
Feb 1 at 23:43
Yes, it will show swapin (as a %), apologies I linked to the wrong iotop (there are it seems at least four different ones...) Fixed link. The kernel does not "blame" a process for page out, they are not accounted for per PID.
â mr.spuratic
Feb 2 at 10:19
add a comment |Â
up vote
-1
down vote
Try the command:
ps -eo pid,cmd,vsz
This will list process in the format process id, command executed, and virtual memory size of the process in KiB
From "man ps": _vsz VSZ virtual memory size of the process in KiB (1024-byte units). _ I need the activity, not the total size. These are page-ins. The total size will not change.
â Thorbjørn Ravn Andersen
Jan 31 at 10:24
You would need to run something like "find /proc -maxdepth 2 -name stat -exec cat '' ;" then and parse the output.
â Raman Sailopal
Jan 31 at 10:46
Did you actually try this?
â Thorbjørn Ravn Andersen
Jan 31 at 12:23
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
With performance problems (e.g. high CPU iowait times) it's generally best to monitor these things over time rather than after the fact, especially when short-lived processes might be the culprit. On Linux one tool you can use interactively is iotop
(fixed link) (see also the answers to this question about tracking disk I/O). You can script this (batch mode) or run it interactively like top
, use the cursor keys to sort by SWAPIN, or use the -o
option so the output isn't so cluttered. You will need Python âÂÂ¥2.7 and various kernel configuration parameters enabled (see iotop
's README
or man page).
Rather than use only data from /proc
like vmstat
, iotop
uses taskstats
, this uses netlink IPC to efficiently provide process accounting directly from the kernel to user space.
On most flavours of Linux with the default "swappiness" setting of 60, it's fairly normal to see paging activity when the system is moderately busy: the kernel is pre-emptively writing little-used process pages to swap instead of purging more recently used disk cache pages. (There's a related parameter vfs_cache_pressure
to tune some cacheing behaviour.) If you observe persistent ongoing paging, then there is likely more to it than just this.
Otherwise, if you are concerned about swap use right now rather than over time: the kernel keeps track of swap use per process in /proc/PID/status
. You can do something quick with gawk
(âÂÂ¥v4.0):
gawk '/^Name:/nm=$2 /^Pid:/pid=$2 /^VmSwap:/sw=$2
ENDFILEprintf("%-24s %6i %6ikiBn",nm,pid,sw)' /proc/[0-9]*/status |
sort -h -k 3
According to the documentation shmem (shared memory) that's swapped out is not counted here, but you hopefully won't need to care about that. Eric Ljungstrom's getswap.sh
script can also be used, there's a more advanced version of it in this answer.
Just to be clear - I am not seeing swap usage increased but that apparently some processes are reading in pages all the time. I want to identify these. Can iotop do that?
â Thorbjørn Ravn Andersen
Feb 1 at 23:43
Yes, it will show swapin (as a %), apologies I linked to the wrong iotop (there are it seems at least four different ones...) Fixed link. The kernel does not "blame" a process for page out, they are not accounted for per PID.
â mr.spuratic
Feb 2 at 10:19
add a comment |Â
up vote
1
down vote
With performance problems (e.g. high CPU iowait times) it's generally best to monitor these things over time rather than after the fact, especially when short-lived processes might be the culprit. On Linux one tool you can use interactively is iotop
(fixed link) (see also the answers to this question about tracking disk I/O). You can script this (batch mode) or run it interactively like top
, use the cursor keys to sort by SWAPIN, or use the -o
option so the output isn't so cluttered. You will need Python âÂÂ¥2.7 and various kernel configuration parameters enabled (see iotop
's README
or man page).
Rather than use only data from /proc
like vmstat
, iotop
uses taskstats
, this uses netlink IPC to efficiently provide process accounting directly from the kernel to user space.
On most flavours of Linux with the default "swappiness" setting of 60, it's fairly normal to see paging activity when the system is moderately busy: the kernel is pre-emptively writing little-used process pages to swap instead of purging more recently used disk cache pages. (There's a related parameter vfs_cache_pressure
to tune some cacheing behaviour.) If you observe persistent ongoing paging, then there is likely more to it than just this.
Otherwise, if you are concerned about swap use right now rather than over time: the kernel keeps track of swap use per process in /proc/PID/status
. You can do something quick with gawk
(âÂÂ¥v4.0):
gawk '/^Name:/nm=$2 /^Pid:/pid=$2 /^VmSwap:/sw=$2
ENDFILEprintf("%-24s %6i %6ikiBn",nm,pid,sw)' /proc/[0-9]*/status |
sort -h -k 3
According to the documentation shmem (shared memory) that's swapped out is not counted here, but you hopefully won't need to care about that. Eric Ljungstrom's getswap.sh
script can also be used, there's a more advanced version of it in this answer.
Just to be clear - I am not seeing swap usage increased but that apparently some processes are reading in pages all the time. I want to identify these. Can iotop do that?
â Thorbjørn Ravn Andersen
Feb 1 at 23:43
Yes, it will show swapin (as a %), apologies I linked to the wrong iotop (there are it seems at least four different ones...) Fixed link. The kernel does not "blame" a process for page out, they are not accounted for per PID.
â mr.spuratic
Feb 2 at 10:19
add a comment |Â
up vote
1
down vote
up vote
1
down vote
With performance problems (e.g. high CPU iowait times) it's generally best to monitor these things over time rather than after the fact, especially when short-lived processes might be the culprit. On Linux one tool you can use interactively is iotop
(fixed link) (see also the answers to this question about tracking disk I/O). You can script this (batch mode) or run it interactively like top
, use the cursor keys to sort by SWAPIN, or use the -o
option so the output isn't so cluttered. You will need Python âÂÂ¥2.7 and various kernel configuration parameters enabled (see iotop
's README
or man page).
Rather than use only data from /proc
like vmstat
, iotop
uses taskstats
, this uses netlink IPC to efficiently provide process accounting directly from the kernel to user space.
On most flavours of Linux with the default "swappiness" setting of 60, it's fairly normal to see paging activity when the system is moderately busy: the kernel is pre-emptively writing little-used process pages to swap instead of purging more recently used disk cache pages. (There's a related parameter vfs_cache_pressure
to tune some cacheing behaviour.) If you observe persistent ongoing paging, then there is likely more to it than just this.
Otherwise, if you are concerned about swap use right now rather than over time: the kernel keeps track of swap use per process in /proc/PID/status
. You can do something quick with gawk
(âÂÂ¥v4.0):
gawk '/^Name:/nm=$2 /^Pid:/pid=$2 /^VmSwap:/sw=$2
ENDFILEprintf("%-24s %6i %6ikiBn",nm,pid,sw)' /proc/[0-9]*/status |
sort -h -k 3
According to the documentation shmem (shared memory) that's swapped out is not counted here, but you hopefully won't need to care about that. Eric Ljungstrom's getswap.sh
script can also be used, there's a more advanced version of it in this answer.
With performance problems (e.g. high CPU iowait times) it's generally best to monitor these things over time rather than after the fact, especially when short-lived processes might be the culprit. On Linux one tool you can use interactively is iotop
(fixed link) (see also the answers to this question about tracking disk I/O). You can script this (batch mode) or run it interactively like top
, use the cursor keys to sort by SWAPIN, or use the -o
option so the output isn't so cluttered. You will need Python âÂÂ¥2.7 and various kernel configuration parameters enabled (see iotop
's README
or man page).
Rather than use only data from /proc
like vmstat
, iotop
uses taskstats
, this uses netlink IPC to efficiently provide process accounting directly from the kernel to user space.
On most flavours of Linux with the default "swappiness" setting of 60, it's fairly normal to see paging activity when the system is moderately busy: the kernel is pre-emptively writing little-used process pages to swap instead of purging more recently used disk cache pages. (There's a related parameter vfs_cache_pressure
to tune some cacheing behaviour.) If you observe persistent ongoing paging, then there is likely more to it than just this.
Otherwise, if you are concerned about swap use right now rather than over time: the kernel keeps track of swap use per process in /proc/PID/status
. You can do something quick with gawk
(âÂÂ¥v4.0):
gawk '/^Name:/nm=$2 /^Pid:/pid=$2 /^VmSwap:/sw=$2
ENDFILEprintf("%-24s %6i %6ikiBn",nm,pid,sw)' /proc/[0-9]*/status |
sort -h -k 3
According to the documentation shmem (shared memory) that's swapped out is not counted here, but you hopefully won't need to care about that. Eric Ljungstrom's getswap.sh
script can also be used, there's a more advanced version of it in this answer.
edited Feb 2 at 10:20
answered Feb 1 at 18:26
mr.spuratic
6,4711027
6,4711027
Just to be clear - I am not seeing swap usage increased but that apparently some processes are reading in pages all the time. I want to identify these. Can iotop do that?
â Thorbjørn Ravn Andersen
Feb 1 at 23:43
Yes, it will show swapin (as a %), apologies I linked to the wrong iotop (there are it seems at least four different ones...) Fixed link. The kernel does not "blame" a process for page out, they are not accounted for per PID.
â mr.spuratic
Feb 2 at 10:19
add a comment |Â
Just to be clear - I am not seeing swap usage increased but that apparently some processes are reading in pages all the time. I want to identify these. Can iotop do that?
â Thorbjørn Ravn Andersen
Feb 1 at 23:43
Yes, it will show swapin (as a %), apologies I linked to the wrong iotop (there are it seems at least four different ones...) Fixed link. The kernel does not "blame" a process for page out, they are not accounted for per PID.
â mr.spuratic
Feb 2 at 10:19
Just to be clear - I am not seeing swap usage increased but that apparently some processes are reading in pages all the time. I want to identify these. Can iotop do that?
â Thorbjørn Ravn Andersen
Feb 1 at 23:43
Just to be clear - I am not seeing swap usage increased but that apparently some processes are reading in pages all the time. I want to identify these. Can iotop do that?
â Thorbjørn Ravn Andersen
Feb 1 at 23:43
Yes, it will show swapin (as a %), apologies I linked to the wrong iotop (there are it seems at least four different ones...) Fixed link. The kernel does not "blame" a process for page out, they are not accounted for per PID.
â mr.spuratic
Feb 2 at 10:19
Yes, it will show swapin (as a %), apologies I linked to the wrong iotop (there are it seems at least four different ones...) Fixed link. The kernel does not "blame" a process for page out, they are not accounted for per PID.
â mr.spuratic
Feb 2 at 10:19
add a comment |Â
up vote
-1
down vote
Try the command:
ps -eo pid,cmd,vsz
This will list process in the format process id, command executed, and virtual memory size of the process in KiB
From "man ps": _vsz VSZ virtual memory size of the process in KiB (1024-byte units). _ I need the activity, not the total size. These are page-ins. The total size will not change.
â Thorbjørn Ravn Andersen
Jan 31 at 10:24
You would need to run something like "find /proc -maxdepth 2 -name stat -exec cat '' ;" then and parse the output.
â Raman Sailopal
Jan 31 at 10:46
Did you actually try this?
â Thorbjørn Ravn Andersen
Jan 31 at 12:23
add a comment |Â
up vote
-1
down vote
Try the command:
ps -eo pid,cmd,vsz
This will list process in the format process id, command executed, and virtual memory size of the process in KiB
From "man ps": _vsz VSZ virtual memory size of the process in KiB (1024-byte units). _ I need the activity, not the total size. These are page-ins. The total size will not change.
â Thorbjørn Ravn Andersen
Jan 31 at 10:24
You would need to run something like "find /proc -maxdepth 2 -name stat -exec cat '' ;" then and parse the output.
â Raman Sailopal
Jan 31 at 10:46
Did you actually try this?
â Thorbjørn Ravn Andersen
Jan 31 at 12:23
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
Try the command:
ps -eo pid,cmd,vsz
This will list process in the format process id, command executed, and virtual memory size of the process in KiB
Try the command:
ps -eo pid,cmd,vsz
This will list process in the format process id, command executed, and virtual memory size of the process in KiB
answered Jan 31 at 10:16
Raman Sailopal
1,18117
1,18117
From "man ps": _vsz VSZ virtual memory size of the process in KiB (1024-byte units). _ I need the activity, not the total size. These are page-ins. The total size will not change.
â Thorbjørn Ravn Andersen
Jan 31 at 10:24
You would need to run something like "find /proc -maxdepth 2 -name stat -exec cat '' ;" then and parse the output.
â Raman Sailopal
Jan 31 at 10:46
Did you actually try this?
â Thorbjørn Ravn Andersen
Jan 31 at 12:23
add a comment |Â
From "man ps": _vsz VSZ virtual memory size of the process in KiB (1024-byte units). _ I need the activity, not the total size. These are page-ins. The total size will not change.
â Thorbjørn Ravn Andersen
Jan 31 at 10:24
You would need to run something like "find /proc -maxdepth 2 -name stat -exec cat '' ;" then and parse the output.
â Raman Sailopal
Jan 31 at 10:46
Did you actually try this?
â Thorbjørn Ravn Andersen
Jan 31 at 12:23
From "man ps": _vsz VSZ virtual memory size of the process in KiB (1024-byte units). _ I need the activity, not the total size. These are page-ins. The total size will not change.
â Thorbjørn Ravn Andersen
Jan 31 at 10:24
From "man ps": _vsz VSZ virtual memory size of the process in KiB (1024-byte units). _ I need the activity, not the total size. These are page-ins. The total size will not change.
â Thorbjørn Ravn Andersen
Jan 31 at 10:24
You would need to run something like "find /proc -maxdepth 2 -name stat -exec cat '' ;" then and parse the output.
â Raman Sailopal
Jan 31 at 10:46
You would need to run something like "find /proc -maxdepth 2 -name stat -exec cat '' ;" then and parse the output.
â Raman Sailopal
Jan 31 at 10:46
Did you actually try this?
â Thorbjørn Ravn Andersen
Jan 31 at 12:23
Did you actually try this?
â Thorbjørn Ravn Andersen
Jan 31 at 12:23
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420888%2fvmstat-says-there-is-paging-activity-how-to-identify-the-swapping-process%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password