linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: kmemleak: Track the page allocations for struct request
@ 2015-09-14 17:16 Catalin Marinas
  2015-09-14 17:21 ` Jens Axboe
  0 siblings, 1 reply; 5+ messages in thread
From: Catalin Marinas @ 2015-09-14 17:16 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Christoph Hellwig, Bart Van Assche

The pages allocated for struct request contain pointers to other slab
allocations (via ops->init_request). Since kmemleak does not track/scan
page allocations, the slab objects will be reported as leaks (false
positives). This patch adds kmemleak callbacks to allow tracking of such
pages.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: Bart Van Assche <bart.vanassche@sandisk.com>
Tested-by: Bart Van Assche<bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
---

Jens,

I just realised that no-one has picked this patch up for -rc1. It was
discussed here previously:

http://lkml.kernel.org/r/20150803104309.GB4033@e104818-lin.cambridge.arm.com

Since it touches the block layer, are you fine with merging it?

Thanks,

Catalin

 block/blk-mq.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index f2d67b4047a0..2077f0d2f95f 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -9,6 +9,7 @@
 #include <linux/backing-dev.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/kmemleak.h>
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -1438,6 +1439,11 @@ static void blk_mq_free_rq_map(struct blk_mq_tag_set *set,
 	while (!list_empty(&tags->page_list)) {
 		page = list_first_entry(&tags->page_list, struct page, lru);
 		list_del_init(&page->lru);
+		/*
+		 * Remove kmemleak object previously allocated in
+		 * blk_mq_init_rq_map().
+		 */
+		kmemleak_free(page_address(page));
 		__free_pages(page, page->private);
 	}
 
@@ -1510,6 +1516,11 @@ static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
 		list_add_tail(&page->lru, &tags->page_list);
 
 		p = page_address(page);
+		/*
+		 * Allow kmemleak to scan these pages as they contain pointers
+		 * to additional allocations like via ops->init_request().
+		 */
+		kmemleak_alloc(p, order_to_size(this_order), 1, GFP_KERNEL);
 		entries_per_page = order_to_size(this_order) / rq_size;
 		to_do = min(entries_per_page, set->queue_depth - i);
 		left -= to_do * rq_size;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: kmemleak: Track the page allocations for struct request
  2015-09-14 17:16 [PATCH] block: kmemleak: Track the page allocations for struct request Catalin Marinas
@ 2015-09-14 17:21 ` Jens Axboe
  2015-11-25 11:04   ` William Dauchy
  0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2015-09-14 17:21 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: linux-kernel, Christoph Hellwig, Bart Van Assche

On 09/14/2015 11:16 AM, Catalin Marinas wrote:
> The pages allocated for struct request contain pointers to other slab
> allocations (via ops->init_request). Since kmemleak does not track/scan
> page allocations, the slab objects will be reported as leaks (false
> positives). This patch adds kmemleak callbacks to allow tracking of such
> pages.
>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Reported-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Tested-by: Bart Van Assche<bart.vanassche@sandisk.com>
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> ---
>
> Jens,
>
> I just realised that no-one has picked this patch up for -rc1. It was
> discussed here previously:
>
> http://lkml.kernel.org/r/20150803104309.GB4033@e104818-lin.cambridge.arm.com
>
> Since it touches the block layer, are you fine with merging it?

Yeah looks simple enough for me, not sure why it got missed. I'll add it 
for 4.4-rc1, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: kmemleak: Track the page allocations for struct request
  2015-09-14 17:21 ` Jens Axboe
@ 2015-11-25 11:04   ` William Dauchy
  2015-11-25 16:45     ` Jens Axboe
  0 siblings, 1 reply; 5+ messages in thread
From: William Dauchy @ 2015-11-25 11:04 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Catalin Marinas, linux-kernel@vger.kernel.org, Christoph Hellwig,
	Bart Van Assche

Hi Jens,

On Mon, Sep 14, 2015 at 7:21 PM, Jens Axboe <axboe@kernel.dk> wrote:
> On 09/14/2015 11:16 AM, Catalin Marinas wrote:
>>
>> The pages allocated for struct request contain pointers to other slab
>> allocations (via ops->init_request). Since kmemleak does not track/scan
>> page allocations, the slab objects will be reported as leaks (false
>> positives). This patch adds kmemleak callbacks to allow tracking of such
>> pages.
>>
>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
>> Reported-by: Bart Van Assche <bart.vanassche@sandisk.com>
>> Tested-by: Bart Van Assche<bart.vanassche@sandisk.com>
>> Cc: Christoph Hellwig <hch@infradead.org>
>> Cc: Jens Axboe <axboe@kernel.dk>
>> ---
>>
>> Jens,
>>
>> I just realised that no-one has picked this patch up for -rc1. It was
>> discussed here previously:
>>
>>
>> http://lkml.kernel.org/r/20150803104309.GB4033@e104818-lin.cambridge.arm.com
>>
>> Since it touches the block layer, are you fine with merging it?
>
>
> Yeah looks simple enough for me, not sure why it got missed. I'll add it for
> 4.4-rc1, thanks.

I saw the related kmemleaks reports on my v4.1.x kernel. Since it's
actually fixing these wrong reports, do you think it could be a good
candidate for -stable tree?

Thanks,
-- 
William

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: kmemleak: Track the page allocations for struct request
  2015-11-25 11:04   ` William Dauchy
@ 2015-11-25 16:45     ` Jens Axboe
  2015-11-25 17:07       ` William Dauchy
  0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2015-11-25 16:45 UTC (permalink / raw)
  To: William Dauchy
  Cc: Catalin Marinas, linux-kernel@vger.kernel.org, Christoph Hellwig,
	Bart Van Assche

On 11/25/2015 04:04 AM, William Dauchy wrote:
> Hi Jens,
>
> On Mon, Sep 14, 2015 at 7:21 PM, Jens Axboe <axboe@kernel.dk> wrote:
>> On 09/14/2015 11:16 AM, Catalin Marinas wrote:
>>>
>>> The pages allocated for struct request contain pointers to other slab
>>> allocations (via ops->init_request). Since kmemleak does not track/scan
>>> page allocations, the slab objects will be reported as leaks (false
>>> positives). This patch adds kmemleak callbacks to allow tracking of such
>>> pages.
>>>
>>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
>>> Reported-by: Bart Van Assche <bart.vanassche@sandisk.com>
>>> Tested-by: Bart Van Assche<bart.vanassche@sandisk.com>
>>> Cc: Christoph Hellwig <hch@infradead.org>
>>> Cc: Jens Axboe <axboe@kernel.dk>
>>> ---
>>>
>>> Jens,
>>>
>>> I just realised that no-one has picked this patch up for -rc1. It was
>>> discussed here previously:
>>>
>>>
>>> http://lkml.kernel.org/r/20150803104309.GB4033@e104818-lin.cambridge.arm.com
>>>
>>> Since it touches the block layer, are you fine with merging it?
>>
>>
>> Yeah looks simple enough for me, not sure why it got missed. I'll add it for
>> 4.4-rc1, thanks.
>
> I saw the related kmemleaks reports on my v4.1.x kernel. Since it's
> actually fixing these wrong reports, do you think it could be a good
> candidate for -stable tree?

I'd say it's borderline. It's fixing a tracking bug. Unless others feel 
strongly otherwise, I don't think it's stable material.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block: kmemleak: Track the page allocations for struct request
  2015-11-25 16:45     ` Jens Axboe
@ 2015-11-25 17:07       ` William Dauchy
  0 siblings, 0 replies; 5+ messages in thread
From: William Dauchy @ 2015-11-25 17:07 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Catalin Marinas, linux-kernel@vger.kernel.org, Christoph Hellwig,
	Bart Van Assche

On Wed, Nov 25, 2015 at 5:45 PM, Jens Axboe <axboe@kernel.dk> wrote:
> I'd say it's borderline. It's fixing a tracking bug. Unless others feel
> strongly otherwise, I don't think it's stable material.

ok thanks for your feedback.

-- 
William

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-25 17:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-14 17:16 [PATCH] block: kmemleak: Track the page allocations for struct request Catalin Marinas
2015-09-14 17:21 ` Jens Axboe
2015-11-25 11:04   ` William Dauchy
2015-11-25 16:45     ` Jens Axboe
2015-11-25 17:07       ` William Dauchy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).