Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3134002imm; Mon, 13 Aug 2018 06:38:03 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzzQsUWiuNCYJbpBSDPFgfLjdtB8fL8VpCmnrICOq1Scnjbqp6GCmYaURdzN0JbtJ5f9Qv2 X-Received: by 2002:a63:28c1:: with SMTP id o184-v6mr17054357pgo.225.1534167483852; Mon, 13 Aug 2018 06:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534167483; cv=none; d=google.com; s=arc-20160816; b=h3T6O/NPe+fPrGtZbmMOPEJBrcglKNPtMYTduC4yHsmmPwCZdEQzmt7YuZCcXzZSU1 Bn4X5l2jk67RQmlPqlP3tQu/Au1Yq/CYbyPQQkKealLOFTlkdb5DcziErHFFIbfT3EM+ YIhiaL2DQetTI3J0PUVzQblpFausELeayEWYdvZP1y9bMhbJQ/tMjZz+bzobbvrJ+XEs JZy0j2eiOQhuEoHt9D4vQ9iLu91nsFxfp3UqvhnBRRVtGGSHA2MVIs4CkLEBfgIlt065 woGcDvFEqn1b8iC7ICyjQgcQHXa77TcuAbbFO9ZsY3yLpR7GAGi71JkzZmCEm7kCOk+F fcHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :arc-authentication-results; bh=BvLdD+Huagi90lmtalRdx7nwRTOjU+5PI189/HSfats=; b=QK+568nipJ0oZXV44uKttCWJCLsSngKbo5R6gNM7pGkYS8RSUpqehBTCUQeCv7o7ho DvWHMimTr7pQkEB5Ajx/G401aqdHw/ncADbaxBc/mEp5KbshAzlvMZxe9Hf9j9TSdATa Njqp3e7ccrUEPTKvlYgFdHoRJ5aTSCmOtvC4eyT2wSR+yC32tJ2jct+N/5340l7kurFk sHMCD/EiTVdeHARhSnTGGIo/TdGbIyTr5Xg1CFlY19sjU1JEIXoMHFabdqP67wJCIQxE WqPthYSBADbEH3Tj2BrVYVBaZEcOD/xooAMDSAIniQr8S8hkJQbMmiLT0aibMRjO1s7Y 33Fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6-v6si20220935pfe.31.2018.08.13.06.37.48; Mon, 13 Aug 2018 06:38:03 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729714AbeHMQCI (ORCPT + 99 others); Mon, 13 Aug 2018 12:02:08 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:62417 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728547AbeHMQCI (ORCPT ); Mon, 13 Aug 2018 12:02:08 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 41pxCr1Hbcz9tvRK; Mon, 13 Aug 2018 15:19:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 1OxWcrXYM-QL; Mon, 13 Aug 2018 15:19:52 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 41pxCr0qwxz9tvRJ; Mon, 13 Aug 2018 15:19:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B9CEC8B7A7; Mon, 13 Aug 2018 15:19:52 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id UOgeQgf-16L2; Mon, 13 Aug 2018 15:19:52 +0200 (CEST) Received: from pc16082vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.4]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9B7078B752; Mon, 13 Aug 2018 15:19:52 +0200 (CEST) Received: by pc16082vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 5523C7125D; Mon, 13 Aug 2018 13:19:52 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH] powerpc/mm: Don't report hugepage tables as memory leaks when using kmemleak To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 13 Aug 2018 13:19:52 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a process allocates a hugepage, the following leak is reported by kmemleak. This is a false positive which is due to the pointer to the table being stored in the PGD as physical memory address and not virtual memory pointer. unreferenced object 0xc30f8200 (size 512): comm "mmap", pid 374, jiffies 4872494 (age 627.630s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [] huge_pte_alloc+0xdc/0x1f8 [<9e0df1e1>] hugetlb_fault+0x560/0x8f8 [<7938ec6c>] follow_hugetlb_page+0x14c/0x44c [] __get_user_pages+0x1c4/0x3dc [] __mm_populate+0xac/0x140 [<3215421e>] vm_mmap_pgoff+0xb4/0xb8 [] ksys_mmap_pgoff+0xcc/0x1fc [<4fcd760f>] ret_from_syscall+0x0/0x38 See commit a984506c542e2 ("powerpc/mm: Don't report PUDs as memory leaks when using kmemleak") for detailed explanation. To fix that, this patch tells kmemleak to ignore the allocated hugepage table. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/hugetlbpage.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index e87f9ef9115b..7296a42eb62e 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -112,6 +113,8 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, for (i = i - 1 ; i >= 0; i--, hpdp--) *hpdp = __hugepd(0); kmem_cache_free(cachep, new); + } else { + kmemleak_ignore(new); } spin_unlock(ptl); return 0; -- 2.13.3