I recently had the same problem, and created this to clean the swap out quickly:
#Single-proc function to core-dump swapped ranges > 1M to /dev/null
unswap(){ (awk -F'[ \t-]+' '/^[a-f0-9]*-[a-f0-9]* /{recent="0x"$1" 0x"$2}/Swap:/&&$2>1000{print recent}' /proc/$1/smaps | while read astart aend; do gdb --batch --pid $1 -ex "dump memory /dev/null $astart $aend" &>/dev/null; done&)2>/dev/null;};
#Loop to run unswap on the top 20 swap-consuming processes
grep VmSwap /proc/*/status 2>/dev/null | sort -nk2 | tail -n20 | cut -d/ -f3 | while read line; do unswap $line; done;
#Observe the number of core dumps currently running, along with free swap, over time.
echo "Dumps Free(m)"; rcount=10; while [[ $rcount -gt 0 ]]; do rcount=$(ps fauxww | grep "dump memory" | grep -v grep | wc -l); echo "$rcount $(free -m | awk '/Swap/{print $4}')"; sleep 1; done
If this doesn't work in your specific environment, the process is as follows:
1. Get a list of the processes consuming the most swap.
In my case, I'm checking /proc/$pid/status, with the swap use in the VmSwap row.
# grep VmSwap /proc/*/status 2>/dev/null | sort -nk2 | tail -n5
/proc/22457/status:VmSwap: 3780 kB
/proc/22684/status:VmSwap: 4260 kB
/proc/7408/status:VmSwap: 4396 kB
/proc/31992/status:VmSwap: 9176 kB
/proc/2967/status:VmSwap: 60840 kB
2. For the high-swap procs, I find the memory address ranges which are contributing the most swap use.
I get this from /proc/$pid/smaps:
7f2fd1bc4000-7f2fd1d24000 rw-p 00000000 00:00 0 <<< Address range
Size: 1408 kB
Rss: 900 kB
Pss: 900 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 900 kB
Referenced: 4 kB
Anonymous: 900 kB
AnonHugePages: 0 kB
Swap: 508 kB << Swap used
KernelPageSize: 4 kB
MMUPageSize: 4 kB
3. I use gdb to do core dumps of those address ranges straight to /dev/null
This forces the system to access that memory and pull it out of swap. Going to /dev/null avoids unnecessary IO.
gdb --batch --pid $pid -ex "dump memory /dev/null $astart $aend"
The process I mentioned originally omits any memory regions using less than 1M of swap in order to get the majority of the swap with considerably fewer core dumps, but this is not mandatory.