1 Reply Latest reply: Jun 10, 2012 3:33 AM by 941184 RSS

    Swapping LWPs or Process?

      when the machine does swap I thought it swapped out complete processes but the vmstat man says that w column are showing lwps swapped out. Alsochecking with mdb I confirm that for many processes there are lwps swapped and some not.
      Can somebody clarify this? Processes are complete (and therefore all threads) swapped out or only some of them? How it works?

      Thank you very much,
      I searched for information in books and forums and I can not clarify this issue.
        • 1. Re: Swapping LWPs or Process?
          Hello again,
          reading several books I was able to deduce that indeed LWP are swapped out. But the are not very explicit and clear. At least I took a look to the source code of sched.c (swapper) and I can confirm that swapper swaps LWP (its structures only, which its not to much). When all LWPs of a process are swapped out then swaper unload addres space (all private memory of the process, shared but all LWPs). At this time is when you can say the process is swapped out and you have obtained a really important feed of memory.

          You can observe of all this with mdb and ps/pmap in a system swapping:

          # Process name, PID, number of LWPs, number of LWPs swapped out and LWPid of one of the swapped out:
          echo "::walk thread thr |::print kthread_t t_schedflag|::grep .==0 |::eval <thr=K|::print -d kthread_t t_procp->p_user.u_comm t_procp->p_pidp->pid_id t_procp->p_lwpcnt t_procp->p_swapcnt t_tid" | mdb -k

          # Memory of the process in RAM (RSS) and swap disk
          ps -ef_o pid,lwp,nlwp,pcpu,pmem,rss="---RSS----" -o vsz="-----VSZ-----" -o args| grep <PID_of processwith_swapped_out_LWPs>
          pmap -x <PID_of swappedout_process>

          Note that w column of vmstat shows LWPs swapped not process.