From: Daniel Walker <dwalker@mvista.com>
To: linux-kernel@vger.kernel.org
Subject: kfree(NULL)
Date: Fri, 21 Apr 2006 00:03:31 -0700 [thread overview]
Message-ID: <200604210703.k3L73VZ6019794@dwalker1.mvista.com> (raw)
I included a patch , not like it's needed . Recently I've been
evaluating likely/unlikely branch prediction .. One thing that I found
is that the kfree function is often called with a NULL "objp" . In fact
it's so frequent that the "unlikely" branch predictor should be inverted!
Or at least on my configuration.
Here are some examples of the warnings that I observed ..
printk: 66 messages suppressed.
BUG: warning at mm/slab.c:3384/kfree()
<c01043d3> show_trace+0x13/0x20 <c01043fe> dump_stack+0x1e/0x20
<c015e334> kfree+0xa4/0xc0 <c032584b> make_request+0x36b/0x670
<c0210305> generic_make_request+0x175/0x240 <c02107d7> submit_bio+0x57/0x100
<c01648f6> submit_bh+0x106/0x160 <c0165a62> __block_write_full_page+0x222/0x3f0
<c0165d28> block_write_full_page+0xf8/0x100 <c016a4b1> blkdev_writepage+0x21/0x30
<c0188c1e> mpage_writepages+0x1ae/0x3d0 <c016a46e> generic_writepages+0x1e/0x20
<c0148f9d> do_writepages+0x2d/0x50 <c0186b70> __writeback_single_inode+0xa0/0x400
<c018716b> sync_sb_inodes+0x1bb/0x2a0 <c01877bf> writeback_inodes+0xaf/0xe5
<c0148d53> wb_kupdate+0x83/0x100 <c0149ab2> pdflush+0x102/0x1c0
<c0131fa4> kthread+0xc4/0xf0 <c0100ed5> kernel_thread_helper+0x5/0x10
printk: 157 messages suppressed.
BUG: warning at mm/slab.c:3384/kfree()
<c01043d3> show_trace+0x13/0x20 <c01043fe> dump_stack+0x1e/0x20
<c015e334> kfree+0xa4/0xc0 <c0140405> audit_syscall_exit+0x405/0x430
<c0106a56> do_syscall_trace+0x1d6/0x245 <c010320a> syscall_exit_work+0x16/0x1c
Daniel
Index: linux-2.6.16/mm/slab.c
===================================================================
--- linux-2.6.16.orig/mm/slab.c
+++ linux-2.6.16/mm/slab.c
@@ -3380,8 +3380,10 @@ void kfree(const void *objp)
struct kmem_cache *c;
unsigned long flags;
- if (unlikely(!objp))
+ if (unlikely(!objp)){
+ WARN_ON(printk_ratelimit());
return;
+ }
local_irq_save(flags);
kfree_debugcheck(objp);
c = virt_to_cache(objp);
next reply other threads:[~2006-04-21 7:03 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-21 7:03 Daniel Walker [this message]
2006-04-21 7:22 ` kfree(NULL) James Morris
2006-04-21 8:54 ` kfree(NULL) Andrew Morton
2006-04-21 13:56 ` kfree(NULL) Vernon Mauery
2006-04-21 14:07 ` kfree(NULL) Dmitry Fedorov
2006-04-21 15:07 ` kfree(NULL) Jan Engelhardt
2006-04-21 19:22 ` kfree(NULL) Adrian Bunk
2006-04-21 20:30 ` kfree(NULL) Vernon Mauery
2006-04-21 20:54 ` kfree(NULL) Steven Rostedt
2006-04-21 21:38 ` kfree(NULL) Adrian Bunk
2006-04-22 11:56 ` kfree(NULL) Jörn Engel
2006-04-21 23:55 ` kfree(NULL) Paul Mackerras
2006-04-22 7:43 ` kfree(NULL) Pekka Enberg
2006-04-22 8:48 ` kfree(NULL) Paul Mackerras
2006-04-22 15:02 ` kfree(NULL) Pekka Enberg
2006-04-22 18:57 ` kfree(NULL) Hua Zhong
2006-04-22 19:05 ` kfree(NULL) Nick Piggin
2006-04-22 19:22 ` kfree(NULL) Hua Zhong
2006-04-22 19:25 ` kfree(NULL) Nick Piggin
2006-04-22 20:18 ` kfree(NULL) Jan Engelhardt
2006-04-23 16:50 ` kfree(NULL) Steven Rostedt
2006-04-22 11:34 ` kfree(NULL) Jesper Juhl
2006-04-21 14:06 ` kfree(NULL) Daniel Walker
[not found] <63XWg-1IL-5@gated-at.bofh.it>
[not found] ` <63YfP-26I-11@gated-at.bofh.it>
[not found] ` <63ZEY-45n-27@gated-at.bofh.it>
2006-04-21 15:25 ` kfree(NULL) Tilman Schmidt
2006-04-21 16:03 ` kfree(NULL) Daniel Walker
2006-04-21 17:48 ` kfree(NULL) Jörn Engel
2006-04-21 18:00 ` kfree(NULL) Steven Rostedt
2006-04-21 18:42 ` kfree(NULL) Daniel Walker
2006-04-21 18:56 ` kfree(NULL) Steven Rostedt
2006-04-21 19:26 ` kfree(NULL) Andrew Morton
2006-04-21 21:02 kfree(NULL) Hua Zhong
2006-04-21 21:11 ` kfree(NULL) Daniel Walker
2006-04-21 21:36 ` kfree(NULL) Michael Buesch
2006-04-21 21:42 ` kfree(NULL) Andrew Morton
2006-04-21 21:48 ` kfree(NULL) Andrew Morton
2006-04-21 22:53 ` kfree(NULL) Hua Zhong
2006-04-21 22:58 ` kfree(NULL) Daniel Walker
2006-04-21 23:03 ` kfree(NULL) Hua Zhong
2006-04-21 23:25 ` kfree(NULL) Andrew Morton
2006-04-21 23:27 ` kfree(NULL) Andrew Morton
2006-04-22 11:18 ` kfree(NULL) Jan Engelhardt
2006-04-22 12:05 kfree(NULL) linux
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=200604210703.k3L73VZ6019794@dwalker1.mvista.com \
--to=dwalker@mvista.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®