login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
August
»
10
Re: [PATCH] lib/scatterlist: Hook sg_kmalloc into kmemleak (v2)
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Catalin Marinas
Subject:
Re: [PATCH] lib/scatterlist: Hook sg_kmalloc into kmemleak (v2)
Date: Tuesday, August 10, 2010 - 3:01 pm
Jens, On Tue, 2010-07-27 at 09:44 +0100, Chris Wilson wrote:
quoted text
> kmemleak ignores page_alloc() and so believes the final sub-page > allocation using the plain kmalloc is decoupled and lost. This leads to > lots of false-positives with code that uses scatterlists. > > The options seem to be either to tell kmemleak that the kmalloc is not > leaked or to notify kmemleak of the page allocations. The danger of the > first approach is that we may hide a real leak, so choose the latter > approach (of which I am not sure of the downsides). > > v2: Added comments on the suggestion of Catalin. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tejun Heo <tj@kernel.org> > Cc: Jens Axboe <jaxboe@fusionio.com> > Cc: Catalin Marinas <catalin.marinas@arm.com>
Since you are the author of lib/scatterlist.c would you (or Tejun) mind ack'ing this patch? Thanks.
quoted text
> --- > lib/scatterlist.c | 21 ++++++++++++++++----- > 1 files changed, 16 insertions(+), 5 deletions(-) > > diff --git a/lib/scatterlist.c b/lib/scatterlist.c > index 9afa25b..fc85552 100644 > --- a/lib/scatterlist.c > +++ b/lib/scatterlist.c > @@ -115,17 +115,28 @@ EXPORT_SYMBOL(sg_init_one); > */ > static struct scatterlist *sg_kmalloc(unsigned int nents, gfp_t gfp_mask) > { > - if (nents == SG_MAX_SINGLE_ALLOC) > - return (struct scatterlist *) __get_free_page(gfp_mask); > - else > + if (nents == SG_MAX_SINGLE_ALLOC) { > + /* kmemleak doesn't track page allocations as they are not > + * commonly used (in a raw form) for kernel data structures. > + * As we chain together a list of pages and then a normal > + * kmalloc (tracked by kmemleak), in order to for that last > + * allocation not to become decoupled (and thus a > + * false-positive) we need to inform kmemleak of all the > + * intermediate allocations. > + */ > + void *ptr = (void *) __get_free_page(gfp_mask); > + kmemleak_alloc(ptr, PAGE_SIZE, 1, gfp_mask); > + return ptr; > + } else > return kmalloc(nents * sizeof(struct scatterlist), gfp_mask); > } > > static void sg_kfree(struct scatterlist *sg, unsigned int nents) > { > - if (nents == SG_MAX_SINGLE_ALLOC) > + if (nents == SG_MAX_SINGLE_ALLOC) { > + kmemleak_free(sg); > free_page((unsigned long) sg); > - else > + } else > kfree(sg); > }
-- Catalin --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH] lib/scatterlist: Hook sg_kmalloc into kmemleak
, Chris Wilson
, (Sun Jul 25, 7:21 am)
Re: [PATCH] lib/scatterlist: Hook sg_kmalloc into kmemleak
, Catalin Marinas
, (Mon Jul 26, 1:55 pm)
[PATCH] lib/scatterlist: Hook sg_kmalloc into kmemleak (v2)
, Chris Wilson
, (Tue Jul 27, 1:44 am)
Re: [PATCH] lib/scatterlist: Hook sg_kmalloc into kmemleak ...
, Catalin Marinas
, (Wed Jul 28, 2:32 pm)
Re: [PATCH] lib/scatterlist: Hook sg_kmalloc into kmemleak ...
, Catalin Marinas
, (Tue Aug 10, 3:01 pm)
Re: [PATCH] lib/scatterlist: Hook sg_kmalloc into kmemleak ...
, Jens Axboe
, (Tue Aug 10, 4:56 pm)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Ken Chen
[patch] sched: fix inconsistency when redistribute per-cpu tg->cfs_rq shares.
Ingo Molnar
Re: [PATCH v3] x86: merge the simple bitops and move them to bitops.h
Andi Kleen
Re: - romsignature-checksum-cleanup-2.patch removed from -mm tree
Axel Lin
[PATCH] tc6393xb: fix wrong goto labels for error handling
Matthew Wilcox
Re: 2.6.22-rc3-mm1
git
:
Johannes Schindelin
Re: [PATCH 05/21] Make parse_tag_buffer_internal() handle item == NULL
Johannes Sixt
Re: [PATCH] Fix handle leak in builtin-pack-objects
Linus Torvalds
Re: [PATCH, take 1] Linear-time/space rename logic (exact renames only)
Alex Riesen
Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
Nicolas Pitre
Re: [PATCH 2/2] Implement a simple delta_base cache
git-commits-head
:
Linux Kernel Mailing List
V4L/DVB (8018): Add em2860 chip ID
Linux Kernel Mailing List
PCI: fix kernel oops on bridge removal
Linux Kernel Mailing List
rtl8187: use DMA-aware buffers with usb_control_msg
Linux Kernel Mailing List
Blackfin: use KERN_ALERT in all kgdb_test output
Linux Kernel Mailing List
MIPS: Bonito64: Make Loongson independent from Bonito64 code.
linux-netdev
:
Richard Cochran
Re: [PATCH v3 3/3] ptp: Added a clock that uses the eTSEC found on the MPC85xx.
David Miller
Re: [RFC] bridge: STP timer management range checking
Herbert Xu
Re: [RFC PATCH 00/17] virtual-bus
Lennert Buytenhek
Re: [PATCH 3/6] [NET] dsa: add support for original DSA tagging format
Herbert Xu
Re: [2/2] igb: Replace LRO with GRO
freebsd-current
:
Boris Samorodov
Re: twa + dump = sbwait
Andrey
Re: RELENG_7 and HEAD: bge causes system hang
韓家標 Bill Hacker
Re: ZFS honesty
samira
sata atapi on ich9r
JoaoBR
Re: I like my rc.d boot messages :(
Colocation donated by:
Syndicate