Chinaunix首页 | 论坛 | 博客
  • 博客访问: 418785
  • 博文数量: 120
  • 博客积分: 3125
  • 博客等级: 中校
  • 技术积分: 1100
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-29 10:59
文章分类

全部博文(120)

文章存档

2012年(28)

2011年(22)

2010年(34)

2009年(1)

2008年(35)

我的朋友

分类: LINUX

2008-04-30 00:51:46

 
Q: How do I make suspend more verbose?
A: If you want to see any non-error kernel messages on the virtual terminal the kernel switches to during suspend, you have to set the kernel console loglevel to at least 4 (KERN_WARNING), for example by doing
 # save the old loglevel
 read LOGLEVEL DUMMY < /proc/sys/kernel/printk
 # set the loglevel so we see the progress bar.
 # if the level is higher than needed, we leave it alone.
 if [ $LOGLEVEL -lt 5 ]; then echo 5 > /proc/sys/kernel/printk fi
        IMG_SZ=0
        read IMG_SZ < /sys/power/image_size
        echo -n disk > /sys/power/state
        RET=$?
        #
        # the logic here is:
        # if image_size > 0 (without kernel support, IMG_SZ will be zero), # then try again with image_size set to zero. if [ $RET -ne 0 -a $IMG_SZ -ne 0 ]; then # try again with minimal image size echo 0 > /sys/power/image_size
                echo -n disk > /sys/power/state
                RET=$? fi
 # restore previous loglevel
 echo $LOGLEVEL > /proc/sys/kernel/printk
 exit $RET
 
Q: What information is useful for debugging suspend-to-disk problems?
A: Well, last messages on the screen are always useful. If something is broken, it is usually some kernel driver, therefore trying with as little as possible modules loaded helps a lot. I also prefer people to suspend from console, preferably without X running. Booting with init=/bin/bash, then swapon and starting suspend sequence manually usually does the trick. Then it is good idea to try with latest vanilla kernel.
 
Q: Can I suspend to a swap file?
A: Generally, yes, you can.  However, it requires you to use the "resume=" and "resume_offset=" kernel command line parameters, so the resume from a swap file cannot be initiated from an initrd or initramfs image.  See swsusp-and-swap-files.txt for details.
 
Q: What happens to devices during swsusp? They seem to be resumed during system suspend?
A: That's correct. We need to resume them if we want to write image to disk. Whole sequence goes like
      Suspend part
      ~~~~~~~~~~~~
      running system, user asks for suspend-to-disk
      user processes are stopped
      suspend(PMSG_FREEZE): devices are frozen so that they don't interfere with state snapshot
      state snapshot: copy of whole used memory is taken with interrupts disabled
      resume(): devices are woken up so that we can write image to swap
      write image to swap
      suspend(PMSG_SUSPEND): suspend devices so that we can power off
      turn the power off
      Resume part
      ~~~~~~~~~~~
      (is actually pretty similar)
      running system, user asks for suspend-to-disk
      user processes are stopped (in common case there are none, but with resume-from-initrd, noone knows)
      read image from disk
      suspend(PMSG_FREEZE): devices are frozen so that they don't interfere with image restoration
      image restoration: rewrite memory with image
      resume(): devices are woken up so that system can continue
      thaw all user processes
 
Q: After resuming, system is paging heavily, leading to very bad interactivity.
A: Try running
cat `cat /proc/[0-9]*/maps | grep / | sed 's:.* /:/:' | sort -u` > /dev/null
after resume. swapoff -a; swapon -a may also be useful.
 
Q: What is the freezing of tasks and why are we using it?
A: The freezing of tasks is a mechanism by which user space processes and some kernel threads are controlled during hibernation or system-wide suspend (on some architectures).  See freezing-of-tasks.txt for details.
阅读(1042) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~