From patchwork Mon Sep 14 17:16:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 53599 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 7858C22B17 for ; Mon, 14 Sep 2015 17:16:17 +0000 (UTC) Received: by lagj9 with SMTP id j9sf53869979lag.0 for ; Mon, 14 Sep 2015 10:16:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=rnCZvk7b/zzxZC3cu+1R1D+gNImFldPgLMnapc1nMDY=; b=aP4YU3wntWJHE+JbDnQ2MZ2to0h5DLX4oVH37pUSLPUrRtM7sCtazCEC1HpmH4zLp1 +DXb1dQHB4iPAzxIUnYduNpZUaHe1yGal4T9TFDJ/hcaAXMKfcSbLtxN05WPipeilex1 a1ivGSr86CrXaa6hV4bk/DLvEpWSvmkLqsfpLLvmrZ1uVz5F1uX3ebI06cfIZBHscJoF I6Ld4CqBYx+AIMGmLnesOHA4cqisFpfj++CIP1Q2ZZ2w7xhrAhIcPkYuK0J87LEVjUig h/KsF0iWYYDG3rbcT22w6PtxCS0R/9xW9t8lcy8tmq3VAr0fVhI0QWPzfjcA2KRMnrhE qpbw== X-Gm-Message-State: ALoCoQlgG1SJh0UMd/lFqciTyE9JrrIqeHSlZYqhcW68UwxXGVMzF4R5fuIglzfRbywwdGjnDxLc X-Received: by 10.112.130.41 with SMTP id ob9mr2546997lbb.17.1442250976432; Mon, 14 Sep 2015 10:16:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.163 with SMTP id wr3ls559309lac.105.gmail; Mon, 14 Sep 2015 10:16:16 -0700 (PDT) X-Received: by 10.152.21.9 with SMTP id r9mr9095107lae.1.1442250976244; Mon, 14 Sep 2015 10:16:16 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id x3si10447331lae.20.2015.09.14.10.16.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2015 10:16:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lagj9 with SMTP id j9so92504382lag.2 for ; Mon, 14 Sep 2015 10:16:15 -0700 (PDT) X-Received: by 10.112.129.202 with SMTP id ny10mr15604453lbb.112.1442250975648; Mon, 14 Sep 2015 10:16:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1315899lbq; Mon, 14 Sep 2015 10:16:14 -0700 (PDT) X-Received: by 10.68.220.226 with SMTP id pz2mr37576639pbc.115.1442250974491; Mon, 14 Sep 2015 10:16:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kw9si24798048pab.114.2015.09.14.10.16.12; Mon, 14 Sep 2015 10:16:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755829AbbINRQK (ORCPT + 29 others); Mon, 14 Sep 2015 13:16:10 -0400 Received: from foss.arm.com ([217.140.101.70]:47370 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755539AbbINRQI (ORCPT ); Mon, 14 Sep 2015 13:16:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD5FB5E4; Mon, 14 Sep 2015 10:16:22 -0700 (PDT) Received: from e104818-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7441D3F318; Mon, 14 Sep 2015 10:16:07 -0700 (PDT) From: Catalin Marinas To: Jens Axboe Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Bart Van Assche Subject: [PATCH] block: kmemleak: Track the page allocations for struct request Date: Mon, 14 Sep 2015 18:16:02 +0100 Message-Id: <1442250962-9906-1-git-send-email-catalin.marinas@arm.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: catalin.marinas@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Reported-by: Bart Van Assche Tested-by: Bart Van Assche Cc: Christoph Hellwig Cc: Jens Axboe --- 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(+) -- 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/ 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 #include #include +#include #include #include #include @@ -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;