# Swapping while swap is turned off



## farrokhi (Nov 19, 2010)

I have a few processes swapped out:


```
[root@devbox:~]# ps ax | grep W
   12  ??  WL    61:00.79 [intr]
  161  ??  IWs    0:00.00 adjkerntz -i
32967   1  TWs+   0:00.00 tcsh
33009   3  TWs+   0:00.00 tcsh
33105   4  TWs+   0:00.00 tcsh

[root@devbox:~]# swapinfo 
Device          1K-blocks     Used    Avail Capacity
/dev/da0s1b       1536000    33608  1502392     2%
```

Then I turned off swap space in order to force them to page into RAM:


```
[root@devbox:~]# swapoff -a
swapoff: removing /dev/da0s1b as swap device

[root@devbox:~]# swapinfo
Device          1K-blocks     Used    Avail Capacity
```

And the processes are still swapped!


```
[root@devbox:~]# ps ax | grep W
   12  ??  WL    61:00.98 [intr]
  161  ??  IWs    0:00.00 adjkerntz -i
32967   1  TWs+   0:00.00 tcsh
33009   3  TWs+   0:00.00 tcsh
33105   4  TWs+   0:00.00 tcsh
```

Am I missing something here? How come the processes are still swapped out when there is no swap space available?


----------



## DutchDaemon (Nov 21, 2010)

I'm assuming you turned swap off on a live system, with the processes not even noticing swap was pulled out from under them yet. File descriptors are still open. It's the same as deleting open log files without restarting syslogd.


----------



## farrokhi (Nov 21, 2010)

Yes I actually turned off swapping on a live system when I had enough free/cache/buf memory. When I turned off swap, I noticed system paged in all remaining pages from swap space to physical memory and actually emptied swap space before releasing it.  On the other hand, swaping/paging is not basically visible from a process' standpoint, and this is something managed by VM subsystem. So I don't think it can be compared with "file descriptors being still open", since this should be transparent to the process.
I think the answer is that pages are loaded into physical memory, but pages might not be mapped to the correct address in physical memory, so they need to be mapped.
Maybe someone familiar with internals of FreeBSD VM subsystem may clear this situation.


----------

