From patchwork Fri May 2 13:41:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 29542 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 359A6203F3 for ; Fri, 2 May 2014 13:42:04 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id i4sf21120795oah.5 for ; Fri, 02 May 2014 06:42:03 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=wNisrqrknTflq3w5c4FNZlqkg8o/SfFQdEfdGGVx1Hw=; b=l/vgyioOHUfsC9PE81nKiwHLBRok/X2GGrnTlVfgB6D/OQsQAgHfqj0WbEFtOeuxff o78+wYmiLFWwzhDTEpLdUr/3R5+cagcoWEHcCLXmYAUzNNIG53ZP9W2oxKncRAU84Ea+ FI0gl9NBaTYKHWWSYPmj+YNZiU9RVXHf4Ts0KMJ7dNDXGgM26FJTGhpzPCKfiCI/JPpe RbU3K8cwFjQXVP9o2Y9xTIBatqR256Lwma3+/nGlFauiKBJ8NMxJoRyep6oN6eBZ8yW/ 7raWYP2uye/fT5hdKHplCd9OtAOBiyG6EUCGUbikfIHW7VOqApRC/zHeKg4JbZprr3b9 SjwQ== X-Gm-Message-State: ALoCoQmSTctgIpechHBHcVV9kf8JqFB11U+N99C7LxZ8M3PEDOcYlildA4qq/GPtu4kAYElGTb8V X-Received: by 10.182.70.106 with SMTP id l10mr9051619obu.7.1399038123631; Fri, 02 May 2014 06:42:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.100 with SMTP id o91ls1549186qgd.30.gmail; Fri, 02 May 2014 06:42:03 -0700 (PDT) X-Received: by 10.52.38.5 with SMTP id c5mr65004vdk.85.1399038123518; Fri, 02 May 2014 06:42:03 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id iz10si6715846vec.6.2014.05.02.06.42.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 May 2014 06:42:03 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id lf12so5463342vcb.13 for ; Fri, 02 May 2014 06:42:03 -0700 (PDT) X-Received: by 10.52.2.229 with SMTP id 5mr11352150vdx.24.1399038123355; Fri, 02 May 2014 06:42:03 -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.220.221.72 with SMTP id ib8csp103815vcb; Fri, 2 May 2014 06:42:02 -0700 (PDT) X-Received: by 10.66.65.204 with SMTP id z12mr4574372pas.60.1399038122579; Fri, 02 May 2014 06:42:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pn4si24248874pac.175.2014.05.02.06.42.01; Fri, 02 May 2014 06:42:01 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752316AbaEBNlx (ORCPT + 28 others); Fri, 2 May 2014 09:41:53 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:52187 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751990AbaEBNlt (ORCPT ); Fri, 2 May 2014 09:41:49 -0400 Received: from e102109-lin.cambridge.arm.com (e102109-lin.cambridge.arm.com [10.1.203.182]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id s42Dfg2l030889; Fri, 2 May 2014 14:41:43 +0100 From: Catalin Marinas To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton Subject: [PATCH 5/6] mm: Call kmemleak directly from memblock_(alloc|free) Date: Fri, 2 May 2014 14:41:09 +0100 Message-Id: <1399038070-1540-6-git-send-email-catalin.marinas@arm.com> X-Mailer: git-send-email 1.7.12.3 In-Reply-To: <1399038070-1540-1-git-send-email-catalin.marinas@arm.com> References: <1399038070-1540-1-git-send-email-catalin.marinas@arm.com> 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=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=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: , Kmemleak could ignore memory blocks allocated via memblock_alloc() leading to false positives during scanning. This patch adds the corresponding callbacks and removes kmemleak_free_* calls in mm/nobootmem.c to avoid duplication. The kmemleak_alloc() in mm/nobootmem.c is kept since __alloc_memory_core_early() does not use memblock_alloc() directly. Signed-off-by: Catalin Marinas Cc: Andrew Morton --- mm/memblock.c | 9 ++++++++- mm/nobootmem.c | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) -- 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/mm/memblock.c b/mm/memblock.c index e9d6ca9a01a9..8813a31d7fbd 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -681,6 +681,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size) (unsigned long long)base + size - 1, (void *)_RET_IP_); + kmemleak_free_part(__va(base), size); return __memblock_remove(&memblock.reserved, base, size); } @@ -985,8 +986,14 @@ static phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size, align = SMP_CACHE_BYTES; found = memblock_find_in_range_node(size, align, 0, max_addr, nid); - if (found && !memblock_reserve(found, size)) + if (found && !memblock_reserve(found, size)) { + /* + * The min_count is set to 0 so that memblock allocations are + * never reported as leaks. + */ + kmemleak_alloc(__va(found), size, 0, 0); return found; + } return 0; } diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 04a9d94333a5..7ed58602e71b 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c @@ -197,7 +197,6 @@ unsigned long __init free_all_bootmem(void) void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, unsigned long size) { - kmemleak_free_part(__va(physaddr), size); memblock_free(physaddr, size); } @@ -212,7 +211,6 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr, */ void __init free_bootmem(unsigned long addr, unsigned long size) { - kmemleak_free_part(__va(addr), size); memblock_free(addr, size); }