[Bug 1215513] Re: System locks up, requires hard reset

2013-10-01 Thread Mel Dee
I stand corrected - maybe. I wrote a program that allocates, sets, and
moves around more memory than my RAM. I added the zram0 as a swap, with
the bad sector included ('mkswap' without '-c'), and with higher
priority than the disk swap. I ran the program once only, because it
takes half an hour when it starts moving pages around. The program
itself did not crash. I saw several 'Write error on swap device'
messages in /var/log/kern.log. I don't know if anything else (like, a
background program) crashed.

So it's possible the kernel now detects bad pages on swap devices and
does not crash when it encounters them. I don't know how to test this
assertion, though. The /dev/zram0 device still contains a bad 4K block
at the end, but maybe it no longer matters.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1215513

Title:
  System locks up, requires hard reset

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1215513/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1217189] Re: Buffer I/O error on device zram0

2013-10-01 Thread Mel Dee
IMO, this bug *is* a duplicate of #1215513. The real problem is that the
zram kernel module creates a block device with a bad sector at the end.
When you try to swap on it, anything can happen, from system lockdowns
to program crashes to nothing (e.g., if you have so much RAM you never
get to use the last sector of /dev/zram0).

I posted detailed findings at #55 on the other bug's page.

Kenneth (#51): 'mkswap' run on the entire block device /dev/zram0 DOES
NOT create a visible swap partition for you to see with 'fdisk -l'. The
fact that you don't see a swap partition on it DOES NOT mean /dev/zram0
is not being swapped on. Check this with 'swapon -s' (and disable it if
it's there!) To see this, and also the bad 4KB sector, try this (first
swapoff and rmmod):

$ sudo modprobe zram
$ echo '1024^3' | bc | sudo tee /sys/block/zram0/disksize   
  
1073741824  

  
$ sudo mkswap -c /dev/zram0
one bad page

  
Setting up swapspace version 1, size = 1048568 KiB
no label, UUID=487d15c0-07ce-46d1-b632-492611e2a13a
$ sudo mkswap /dev/zram0
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=9fa2c2df-d69c-4282-87ad-7c3219e50832
$ sudo fdisk -l /dev/zram0
Note: sector size is 4096 (not 512)

Disk /dev/zram0: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 16 cylinders, total 262144 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x

Disk /dev/zram0 doesn't contain a valid partition table

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1217189

Title:
  Buffer I/O error on device zram0

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1217189/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1215513] Re: System locks up, requires hard reset

2013-10-01 Thread Mel Dee
For 1a, also uninstall zram-config if present.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1215513

Title:
  System locks up, requires hard reset

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1215513/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs


[Bug 1215513] Re: System locks up, requires hard reset

2013-10-01 Thread Mel Dee
Posts #51 and #53 are wrong: this bug is NOT FIXED in either 3.2.0-54.82
or 3.8.0-31.46 from the 12.04 (precise) repositories. There might be
something fixed about zram in there (as suggested by the changelog), but
the last sector of /dev/zram0 is still bad (as reported in #43), and
this will lead to crashes if /dev/zram0 is used 'blindly' to create a
swap partition.

NOTE1: Before all, if you're running one of these kernels ('uname -a',
last number is shown later in the line) and if 'swapon -s' shows
/dev/zram0, do immediately a 'sudo swapoff /dev/zram0'. Otherwise your
machine can crash at any time.

NOTE2: Potentially all 12.04 & derivative installations that include the
package lupin-casper (and have not altered the zram configuration) will
experience the bug.

I performed a clean install of Mint 13, followed by a switch to the 12.04.3 
stack (as explained here: https://wiki.ubuntu.com/Kernel/LTSEnablementStack). I 
also switched an Ubuntu 12.04.2 to 12.04.3. Here are my findings. If you only 
want a summary of workarounds, scroll to the bottom. Ref:
http://askubuntu.com/questions/346545/how-to-detect-which-init-script-starts-zram

FINDINGS:

1. Package versions: A Mint 13 clean install is based on 12.04.(0 or 1).
Using updates only gets you up to 3.2.0-54.82. A Mint 13 switched to the
12.04.3 stack gets you up to 3.8.0-31.46. An Ubuntu 12.04.2 switched to
12.04.3 get you up to 3.8.0-31.46 as well.

2. zram is broken in both 3.2.0-54.82 and 3.8.0-31.46, as explained in
#43: the last sector of /dev/zram0 is bad. However, you might not notice
this because zram is not always used by default (see 3 below). To check
zram is broken, first make sure it's loaded (but not for swapping!! see
NOTE1 above):

  lsmod | grep zram

If it doesn't show, do this to create a 1GB zram:

  sudo modprobe zram
  echo '1024^3' | bc | sudo tee /sys/block/zram0/disksize

With zram loaded, run:

  sudo dd if=/dev/zram0 of=/dev/null bs=4096

I get:
dd: reading `/dev/zram0': Input/output error
262143+0 records in
262143+0 records out
1073737728 bytes (1.1 GB) copied, 0.400378 s, 2.7 GB/s

Compare the 262143 above with:

  sudo fdisk -l /dev/zram0 | grep -o "total [0-9]* sectors"

I get:
total 262144 sectors

3. zram usage: The zram-config package is NOT installed by default by either 
Mint 13 or Ubuntu 12.04. Regardless of that(!), in some configurations, zram is 
loaded by the initramfs image. By default, Mint 13 DOES use zram, whereas 
Ubuntu 12.04 DOES NOT use zram.
- check if module loaded: 'lsmod | grep zram'
- check if zram is used for swap: 'swapon -s | grep zram' (if it is, see NOTE1 
above)
- check if zram-config package installed: 'dpkg -l zram-config'

4. If zram is loaded by initramfs, the zram-config package is useless.
By the time /etc/init/zram-config.conf runs, the zram module is already
loaded, so 'modprobe' won't do anything, and setting the size by writing
to /sys/block/zram0/disksize will not work. Thus, the solution in
#43/#45/#49 won't work. If you really want zram-config to take over zram
allocation, you need to add:

  # remove swaps
  for dev in $(swapon -s | grep /dev/zram | cut -d ' ' -f 1); do
swapoff $dev || exit 1
  done
  # remove module
  if lsmod | grep -q zram; then
rmmod zram || exit 1
  fi

just before:

  modprobe zram $MODPROBE_ARGS

Note, the version I have sets up one zram per CPU core. Not sure why
you'd need that. If you don't, also replace:

  NRDEVICES=$(grep -c ^processor /proc/cpuinfo | sed 's/^0$/1/')

by:

  #NRDEVICES=$(grep -c ^processor /proc/cpuinfo | sed 's/^0$/1/')
  NRDEVICES=1

Also, don't forget to add '-c' to mkswap, as explained in #43.

5. The culprit which makes the difference between Mint 13 using zram in 
initramfs and Ubuntu 12.04 not using it is the package lupin-casper. This one 
depends on casper, which contains the file 
/usr/share/initramfs-tools/conf.d/compcache. This file contains only:
COMPCACHE_SIZE="50%"
If this file is absent, the script /usr/share/initramfs-tools/hooks/compcache 
(part of initramfs-tools) won't do anything, because its 'eval' will return 
'number=""; suffix=""', which will trigger early termination just below 'eval'. 
If the COMPCACHE_SIZE setting file is present, the script will add zram to the 
initramfs. Thus, potentially all 12.04 & derivative installations which include 
lupin-casper will experience the bug. Furthermore, you might get the bug by 
installing lupin-casper later on, before the bug is fixed.

WORKAROUNDS: (either one should be enough!)

1. Disable zram.
Pro: Definitely clears the zram bug.
Con: Need to undo changes by hand to re-enable it later on, once the zram bug 
is fixed.

1a. Add at the top of /etc/rc.local:
swapoff /dev/zram0
rmmod zram

1b. Blacklist zram and run 'update-initramfs'.

1c. Find zram.ko and rename it to zram.ko.DONTUSE and run 'update-
initramfs' (thx Dan)

2. Use zram, but avoid the last sector. For this you need to make sure the 
relevant 'mkswap' runs with '-c' (see #43).
Pro: zram still u