From: Wladislav Wiebe <wladislav.kw@gmail.com>
To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org
Subject: seq_file: procfs: kmalloc_slab WARNING
Date: Tue, 06 Aug 2013 15:26:23 +0200 [thread overview]
Message-ID: <5200F97F.50204@gmail.com> (raw)
Hello FS community,
on a PPC 32-Bit board with a Linux Kernel v3.10.0 I see that seq_read tries to allocate
for a procfs entry 8 MB (max. should be 4 MB). It's basically a Device Tree entry (/proc/device-tree/localbus@5000/flash@0/partition@1/reg)
and why it needs 8 MB now, I don't know - the same Device Tree works fine on previous Kernel releases.
When it's happen it throw warnings from with kmalloc_slab.
I added some debug functions to seq_read, to see when allocating 8 MB or more
(Marked "DEBUG xxx ...")
..
UBI: background thread "ubi_bgt0d" started, PID 895
DEBUG xxx seq_read: m->size = 8388608
DEBUG xxx seq_read: path = /proc/device-tree/localbus@5000/flash@0/partition@1/reg
------------[ cut here ]------------
WARNING: at /var/fpwork/wiebe/newfsm/bld/bld-kernelsources-linux/results/linux/mm/slab_common.c:377
Modules linked in: ubi mddg_post(O) mddg_rpram(O) mddg_system_driver(O) mddg_watchdog(O)
CPU: 0 PID: 903 Comm: hexdump Tainted: G O 3.10.0-0-sampleversion-fcmd #60
task: cf97c230 ti: cfbf0000 task.ti: cfbf0000
NIP: c0098d98 LR: c00acf1c CTR: 00000000
REGS: cfbf1da0 TRAP: 0700 Tainted: G O (3.10.0-0-sampleversion-fcmd)
MSR: 00029000 <CE,EE,ME> CR: 22008444 XER: 00000000
GPR00: c00d2100 cfbf1e50 cf97c230 00800000 000000d0 00000000 ce7ffffc 00000000
GPR08: 00400000 c0380000 00000001 cfbf1e50 22008444 100a24dc 00000001 c030e2d0
GPR16: cfacac88 c030e2b0 007fffff fffff000 c028c80c 00000000 cfbf1e80 00000400
GPR24: 4801c000 cfbdf4e0 00000000 00000000 c00d2100 00000000 000000d0 cfacac80
NIP [c0098d98] kmalloc_slab+0x24/0xb0
LR [c00acf1c] __kmalloc+0x1c/0x154
Call Trace:
[cfbf1e50] [c00ac4d0] kfree+0x6c/0x120 (unreliable)
[cfbf1e70] [c00d2100] seq_read+0x328/0x5d4
[cfbf1ee0] [c00fb8b8] proc_reg_read+0x5c/0x90
[cfbf1ef0] [c00b27b8] vfs_read+0xa4/0x150
[cfbf1f10] [c00b29a8] SyS_read+0x4c/0x84
[cfbf1f40] [c000be3c] ret_from_syscall+0x0/0x3c
--- Exception: c01 at 0xfe63934
LR = 0xfe1a6a8
Instruction dump:
7c631910 7c6300d0 4e800020 3d200040 7f834840 409d003c 708a0200 39200000
40a20094 3d20c038 8949fe89 694a0001 <0f0a0000> 2f8a0000 39200000 41be0078
---[ end trace d2ede23251d61cd0 ]---
DEBUG xxx seq_read: m->size = 8388608
DEBUG xxx seq_read: path = /proc/device-tree/localbus@5000/flash@0/partition@1/reg
UBIFS: recovery needed
..
Basically we discussed this a bit with MM guys,
at the end there was a proposal from Christoph Lameter <cl@linux.com> of using kmalloc_large instead of kmalloc.
####################
There is no point in using the slab allocation functions for
large page order allocation. Use kmalloc_large().
This fixes the warning about large allocs but it will still cause
large contiguous allocs that could fail because of memory fragmentation.
Signed-off-by: Christoph Lameter <cl@linux.com>
Index: linux/fs/seq_file.c
===================================================================
--- linux.orig/fs/seq_file.c 2013-07-31 10:39:03.050472030 -0500
+++ linux/fs/seq_file.c 2013-07-31 10:39:03.050472030 -0500
@@ -136,7 +136,7 @@ static int traverse(struct seq_file *m,
Eoverflow:
m->op->stop(m, p);
kfree(m->buf);
- m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
+ m->buf = kmalloc_large(m->size <<= 1, GFP_KERNEL);
return !m->buf ? -ENOMEM : -EAGAIN;
}
@@ -232,7 +232,7 @@ ssize_t seq_read(struct file *file, char
goto Fill;
m->op->stop(m, p);
kfree(m->buf);
- m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
+ m->buf = kmalloc_large(m->size <<= 1, GFP_KERNEL);
if (!m->buf)
goto Enomem;
m->count = 0;
####################
What do you think about this, or do we have other alternatives?
Because with current Kernel releases is this kmalloc_large function not accessible in a easy "include and use" way.
you can follow the MM thread here:
http://linuxppc.10917.n7.nabble.com/mm-slab-ppc-ubi-kmalloc-slab-WARNING-PPC-UBI-driver-td74404.html
Thanks & BR,
Wladislav Wiebe
next reply other threads:[~2013-08-06 13:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-06 13:26 Wladislav Wiebe [this message]
2013-08-12 11:07 ` seq_file: procfs: kmalloc_slab WARNING Wladislav Wiebe
2013-08-29 21:54 ` Andrew Morton
2013-08-30 7:10 ` Wladislav Wiebe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5200F97F.50204@gmail.com \
--to=wladislav.kw@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.