From patchwork Fri Feb 12 12:37:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: thermal-bot for Stanislaw Gruszka X-Patchwork-Id: 12085233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83083C433E0 for ; Fri, 12 Feb 2021 12:37:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1E2DF60C41 for ; Fri, 12 Feb 2021 12:37:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E2DF60C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 719288D0015; Fri, 12 Feb 2021 07:37:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DC498D0054; Fri, 12 Feb 2021 07:37:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33FF58D0015; Fri, 12 Feb 2021 07:37:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 1519D8D0053 for ; Fri, 12 Feb 2021 07:37:07 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C701D180ACEEC for ; Fri, 12 Feb 2021 12:37:06 +0000 (UTC) X-FDA: 77809565652.28.robin79_23149e027621 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id AD1216C13 for ; Fri, 12 Feb 2021 12:37:06 +0000 (UTC) X-HE-Tag: robin79_23149e027621 X-Filterd-Recvd-Size: 5905 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 12 Feb 2021 12:37:05 +0000 (UTC) Date: Fri, 12 Feb 2021 12:37:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1613133424; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Wm3+/ZioKwWoQFRQO8xdr1aYgVij0tuadky7iNPDJvk=; b=KdLSE5uZa0+fWqeypEylwVaW1fctaSCHbGDJn8LJcXZ9UQSQNp12XZM0HZsXL192gWgmQx FLsA8HG1aJ1h9EZyN7WeqxcF5bTcPpUBmpJ9O+Pv7TCTSRhg/bT9cLH0JMUBZaSVQ7TG0x WTzOGv86zL3WRpb4i/3hFKyf2lwpGIGfXO1QNuzbcrzloRAEEbMnoEjmKU/vC9UYwfif6b qxp+0Gi2jYtqi9++OPet50Nv22NBFR/jEZYDtPeARTm8TW+r6Voo0/y4C9uIx31sV9Q8Ow ycpqQGP3CAXEXSTCBhdNa0w+wce5hDIgTh8FoF8lclTqj/Fri02T5WIGKh3KOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1613133424; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Wm3+/ZioKwWoQFRQO8xdr1aYgVij0tuadky7iNPDJvk=; b=nHhoL9zC5QaFNLo0UMluLeV1FkHyD5zItr80kKUaNv/9CW0iC+y+x/jyZXmyUirdjPHG9A v67fv9wSGGcE0BBQ== From: "tip-bot2 for Paul E. McKenney" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/rcu] mm: Make mem_dump_obj() handle vmalloc() memory Cc: Andrew Morton , Joonsoo Kim , , Andrii Nakryiko , Vlastimil Babka , Naresh Kamboju , "Paul E. McKenney" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <161313342375.23325.18336254972948855257.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The following commit has been merged into the core/rcu branch of tip: Commit-ID: 98f180837a896ecedf8f7e12af22b57f271d43c9 Gitweb: https://git.kernel.org/tip/98f180837a896ecedf8f7e12af22b57f271d43c9 Author: Paul E. McKenney AuthorDate: Tue, 08 Dec 2020 16:13:57 -08:00 Committer: Paul E. McKenney CommitterDate: Fri, 22 Jan 2021 15:24:04 -08:00 mm: Make mem_dump_obj() handle vmalloc() memory This commit adds vmalloc() support to mem_dump_obj(). Note that the vmalloc_dump_obj() function combines the checking and dumping, in contrast with the split between kmem_valid_obj() and kmem_dump_obj(). The reason for the difference is that the checking in the vmalloc() case involves acquiring a global lock, and redundant acquisitions of global locks should be avoided, even on not-so-fast paths. Note that this change causes on-stack variables to be reported as vmalloc() storage from kernel_clone() or similar, depending on the degree of inlining that your compiler does. This is likely more helpful than the earlier "non-paged (local) memory". Cc: Andrew Morton Cc: Joonsoo Kim Cc: Reported-by: Andrii Nakryiko Acked-by: Vlastimil Babka Tested-by: Naresh Kamboju Signed-off-by: Paul E. McKenney --- include/linux/vmalloc.h | 6 ++++++ mm/util.c | 14 ++++++++------ mm/vmalloc.c | 12 ++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 80c0181..c18f475 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -246,4 +246,10 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) int register_vmap_purge_notifier(struct notifier_block *nb); int unregister_vmap_purge_notifier(struct notifier_block *nb); +#ifdef CONFIG_MMU +bool vmalloc_dump_obj(void *object); +#else +static inline bool vmalloc_dump_obj(void *object) { return false; } +#endif + #endif /* _LINUX_VMALLOC_H */ diff --git a/mm/util.c b/mm/util.c index 92f23d2..5487022 100644 --- a/mm/util.c +++ b/mm/util.c @@ -996,18 +996,20 @@ int __weak memcmp_pages(struct page *page1, struct page *page2) */ void mem_dump_obj(void *object) { + if (kmem_valid_obj(object)) { + kmem_dump_obj(object); + return; + } + if (vmalloc_dump_obj(object)) + return; if (!virt_addr_valid(object)) { if (object == NULL) pr_cont(" NULL pointer.\n"); else if (object == ZERO_SIZE_PTR) pr_cont(" zero-size pointer.\n"); else - pr_cont(" non-paged (local) memory.\n"); - return; - } - if (kmem_valid_obj(object)) { - kmem_dump_obj(object); + pr_cont(" non-paged memory.\n"); return; } - pr_cont(" non-slab memory.\n"); + pr_cont(" non-slab/vmalloc memory.\n"); } diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 4d88fe5..c274ea4 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3448,6 +3448,18 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) } #endif /* CONFIG_SMP */ +bool vmalloc_dump_obj(void *object) +{ + struct vm_struct *vm; + void *objp = (void *)PAGE_ALIGN((unsigned long)object); + + vm = find_vm_area(objp); + if (!vm) + return false; + pr_cont(" vmalloc allocated at %pS\n", vm->caller); + return true; +} + #ifdef CONFIG_PROC_FS static void *s_start(struct seq_file *m, loff_t *pos) __acquires(&vmap_purge_lock)