Unfortunately it isn't that simple.
"swap" is really considered to be "non-resident anonymous pages". That is, pages which are not backed by any disc file (not mmap'd file-backed pages).
When the kernel gets a bit short of memory, it tends to discard pages which haven't been used much recently. It might choose to discard file-backed pages, or anonymous pages. If it does the latter, that uses "swap".
However, there isn't a single process which triggers it, it's just general memory pressure.
Moreover, you can't even measure page usage very accurately. There are two counts per process, which are (vaguely) useful. These are VSIZE (or vm size) which is the total number of pages that a process has allocated - but this tends to be a big overestimate of how much is actually "used", as it can count pages twice, and count pages not being used at all (mapped but not used).
The other is RSS, or "resident set size", which is the amount of memory in pages which are currently resident. However this isn't really the true picture either:
- The same page is not necessarily used by exactly one process - they can be shared.
- Some pages are used internally by the kernel and hence not charged to any one process
I am not aware of any tools which attempt to make a better estimate than this, but it is theoretically feasible to do a bit better with the new diagnostics available in /proc in recent kernels.
There are some good answers on this StackOverflow question: http://stackoverflow.com/questions/479953/how-to-find-out-which-processes-are-swapping-in-linux
– Andy Triggs – 2013-02-25T20:49:52.243