From patchwork Sat Oct 26 06:52:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liusirui X-Patchwork-Id: 1184557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106361-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="B7bhuLYU"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 470WqZ4DtTz9sP4 for ; Sat, 26 Oct 2019 17:51:54 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type; q=dns; s=default; b=UoYzo1Lynms2wq8e BcD+T/ArXqlWQfb8bs6AINQCOoCzPBcsLKsZnpunptCL/8T2vi2jWBT/NzvJ/3zu qh8mjXgmJU+CVn1EtA3uc0mxs65Q77CAsswMNjYMAP3gWAxwUGHfO7fe/0n42c/c kPPqvnmDHovTgvEFaFyqVs6Dh9g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type; s=default; bh=lM8DU8ucVKM6Ft9QoYCKMc RNDTo=; b=B7bhuLYU4KUXjro1hLrV17sM6fEd44JgY9mOTUdG0ET144DrCelQFl /eqQPv14oNfVpl8178B1SIPxlRKZYxtyON9PMKfe3p6gH7riHYIBDtoX9MH78wfF a6jylGxrcNbNYmdNCg/2RPTdZZagZ2BxjykRxqGNw6McbXo2HHcAg= Received: (qmail 98623 invoked by alias); 26 Oct 2019 06:51:48 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 98606 invoked by uid 89); 26 Oct 2019 06:51:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.8 required=5.0 tests=AWL, BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=49656 X-HELO: huawei.com From: l00420122 To: CC: Subject: [PATCH 1/2] malloc: malloc_stats print all heaps except heaps Date: Sat, 26 Oct 2019 14:52:05 +0800 Message-ID: <1572072726-2197-1-git-send-email-liusirui@huawei.com> MIME-Version: 1.0 From: liusirui An arena may have several heaps, and only the last heap contains top chunk. malloc_stats only print the heap which contains top chunk. Now the function prints all heaps of an arena. --- malloc/malloc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 5d3e82a..351e95f 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4965,6 +4965,7 @@ __malloc_stats (void) { int i; mstate ar_ptr; + heap_info *heap_ptr; unsigned int in_use_b = mp_.mmapped_mem, system_b = in_use_b; if (__malloc_initialized < 0) @@ -4984,7 +4985,13 @@ __malloc_stats (void) fprintf (stderr, "in use bytes = %10u\n", (unsigned int) mi.uordblks); #if MALLOC_DEBUG > 1 if (i > 0) - dump_heap (heap_for_ptr (top (ar_ptr))); + { + for (heap_ptr = heap_for_ptr (top (ar_ptr)); heap_ptr->ar_ptr != (mstate) (heap_ptr + 1); heap_ptr = heap_ptr->prev) + { + dump_heap (heap_ptr); + } + dump_heap (heap_ptr); + } #endif system_b += mi.arena; in_use_b += mi.uordblks;