Bug 50081

Summary: zram cause unable to handle kernel page request
Product: Memory Management Reporter: Mihail Kasadjikov (hamer.mk)
Component: OtherAssignee: Andrew Morton (akpm)
Status: RESOLVED CODE_FIX    
Severity: normal CC: andrei.mihaila, florian, nitingupta910, sjenning, tomas
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Tree: Mainline
Regression: Yes
Attachments: photo screenshot of crash
dmesg
dmidecode
lspci
SAR report of memory consumption
SAR report of swap consumption
grep zram from syslog
Patch to fix a crash in zram

Description Mihail Kasadjikov 2012-11-05 12:21:08 UTC
Hi!
Some days ago I tried to use zram as a swap space. After big memory consumption I have a crash with message:
BUG: unable to handle kernel paging request at fff7e000

I can't attach a kernel log because system was crashed with kernel bug report in text console. I have only photo screenshot and some sar reports.

The zram swap device was created by this commands in /etc/rc.local:

modprobe -v zram num_devices=1
echo $((2048*1024*1024)) > /sys/block/zram0/disksize
echo 1 > /sys/block/zram0/queue/nomerges
mkswap /dev/zram0
swapon -p 0 /dev/zram0

I have a 4 GB of RAM and use a 32-bit kernel 3.6.
Comment 1 Mihail Kasadjikov 2012-11-05 12:22:33 UTC
Created attachment 85571 [details]
photo screenshot of crash
Comment 2 Mihail Kasadjikov 2012-11-05 12:23:06 UTC
Created attachment 85581 [details]
dmesg
Comment 3 Mihail Kasadjikov 2012-11-05 12:23:22 UTC
Created attachment 85591 [details]
dmidecode
Comment 4 Mihail Kasadjikov 2012-11-05 12:23:39 UTC
Created attachment 85601 [details]
lspci
Comment 5 Mihail Kasadjikov 2012-11-05 12:24:18 UTC
Created attachment 85611 [details]
SAR report of memory consumption
Comment 6 Mihail Kasadjikov 2012-11-05 12:24:39 UTC
Created attachment 85621 [details]
SAR report of swap consumption
Comment 7 Mihail Kasadjikov 2012-11-05 12:25:03 UTC
Created attachment 85631 [details]
grep zram from syslog
Comment 8 sjenning 2012-11-05 20:56:15 UTC
This may already be fixed in v3.7 with this patch:

$ git show --format=full c8f2f0db
commit c8f2f0db1d0294aaf37e8a85bea9bbc4aaf5c0fe
Author: Nitin Gupta <ngupta@vflare.org>
Commit: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    staging: zram: Fix handling of incompressible pages

Please see if incorporating this patch fixes the issue.
Comment 9 Mihail Kasadjikov 2012-11-06 10:11:22 UTC
Unfortunately this patch was already applied.
Comment 10 Mihail Kasadjikov 2012-11-06 13:43:11 UTC
I found previous built kernel 3.5.4 and tested it.
The crash is not occured in this kernel
Comment 11 nitingupta910 2012-11-21 09:27:37 UTC
Created attachment 86831 [details]
Patch to fix a crash in zram

Patch to properly handle incompressible page and partial I/O cases.

Testing done:
 - created zram of size 1200m
 - created ext4 fs on /dev/zram0
 - iozone -a -g 1G
Comment 12 Tomas M 2012-11-21 11:55:43 UTC
I was experiencing very same problem since 3.6.5 - since this version introduced a "fix" for incompressible pages, but the "fix" had problems.

I can confirm that the patch from comment #11 resolves the issue entirely. Tested on 3.6.7.
Comment 13 Mihail Kasadjikov 2012-11-21 14:25:03 UTC
3.6.7. The patch works.
Thanks.
Comment 14 Tomas M 2012-12-17 08:55:11 UTC
The patch from Nitin fixes this critical error but yet it was not accepted to Kernel mainline. What's wrong with the kernel guys? Does anybody know who should I contact from the kernel guys to politely ask him (kick him in the ass) to accept the fix ?? There are people who fix bugs in kernel and the kernel developers simply ignore it, that doesn't seem like a good practice to me.
Comment 15 Andrei Mihăilă 2012-12-23 21:01:06 UTC
The patch from comment #11 works for me too (on 3.7.1). Thank you!
Comment 16 nitingupta910 2013-01-15 23:08:43 UTC
The fix has been accepted and will be present in next stable releases.
Comment 17 Florian Mickler 2013-01-19 22:57:24 UTC
A patch referencing this bug report has been merged in Linux v3.8-rc4:

commit 397c60668aa5ae7130b5ad4e73870d7b8a787085
Author: Nitin Gupta <ngupta@vflare.org>
Date:   Wed Jan 2 08:53:41 2013 -0800

    staging: zram: fix invalid memory references during disk write