From patchwork Fri Jul 28 05:00:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13331188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC0A2C001DF for ; Fri, 28 Jul 2023 04:48:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D492D6B0078; Fri, 28 Jul 2023 00:48:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAAA46B007B; Fri, 28 Jul 2023 00:48:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A12426B007D; Fri, 28 Jul 2023 00:48:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8EEC96B0078 for ; Fri, 28 Jul 2023 00:48:35 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5C33C8058B for ; Fri, 28 Jul 2023 04:48:35 +0000 (UTC) X-FDA: 81059789790.17.254CF64 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf06.hostedemail.com (Postfix) with ESMTP id ECC86180004 for ; Fri, 28 Jul 2023 04:48:32 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690519713; h=from:from:sender: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: in-reply-to:in-reply-to:references:references; bh=D/rLs7gASsjHAy2ZfI3q4nMacggGm1PsNeI9gnyVH3Y=; b=enVqalb9vRAZ+cofPrwBkJOeamOi4hZ0zCaN3Ee+kAc57s4TJnkz6cJS0MqLVucLYcpFss N1gVHk88psLZeLTE/NVLBOHjqs3Wk/rgp54HWE+nnAteU71w6/eIiX1/wDw+rOkoM8MyF3 itbhJrgWP6z8VWbVBlWrV6TUuWcxcj4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690519713; a=rsa-sha256; cv=none; b=RTc6pLJuwYhq0PyaRJdeXeSKQkHQh/Fe3z2lB4sdZAkXL79qz4fH4mt+XGH7NOriC0Vmv+ kzcz3Fng2pTAFtc1Xs6LIWkReSXSc6FhZ4qZAO8y8+4c3WweBJSVNVxPl0QYoZdBN0WwCG ISPG17dCi5hl46ZCiOG5CHBYYGf2Q2k= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RBw6T19T8zNm4t; Fri, 28 Jul 2023 12:45:05 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 28 Jul 2023 12:48:27 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , , , =?utf-8?q?Christian_G=C3=B6ttsche?= , David Hildenbrand , Felix Kuehling , Alex Deucher , , , , , , , , , , Kefeng Wang Subject: [PATCH v3 4/4] perf/core: use vma_is_initial_stack() and vma_is_initial_heap() Date: Fri, 28 Jul 2023 13:00:43 +0800 Message-ID: <20230728050043.59880-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230728050043.59880-1-wangkefeng.wang@huawei.com> References: <20230728050043.59880-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: ECC86180004 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 96tkwuauie89jseamo7phkbs8zsz6hxz X-HE-Tag: 1690519712-218862 X-HE-Meta: U2FsdGVkX1/qi5GZ7Y0A6wfwKAirqN78EyAGiR29zByQlQtw6akdWtUu4+0DlvOU2n0yd0eEsTSFjjtTdH1eClZ+Wt07OEfQYmO2y1x6uhUw/0UZ6gWleqzFndSmzP8HoE7uAd5mPLyfUjYiDaH0jExHjXEtAPrz/I/1qx99qUCyf/ZlZN5JyUgn8WDjA6X8xtZYsdNbUWLg/Zhf+uWD5H4eV7+HixOVc6VAgOiPcE96ZpFkC0hd8gZxQopk9Z+ta8nMwhfOeDSPDN6qpM/XeUYnh/OwyXN97FeHKLWLHGEKd7JtnXEt2CmyQoDZtd3Xd+6KFEIVFruXTXLf3ur1/6hPXFkZwhOtRQw9bVn/RLTYavT2wbDLzESwwT27e/FP3ZbvvM9Lb1vw24qwTDn1lyYtP5oq/OV/nGMpz8oTrItBd1tcBFyYgViqbVZAldJHm7kCuhLG97tDMnFyKDkWtnDL456noNZStsNENLYoTocFIyA/rL2UBYsn9UvaiO49rcFQM1SP6DlBGuMKbBu87iJkUAx1dJrUxDJFoGHaUnUKPLkb3Jt8nwgl/cvd967D/+5FGEvICDC61S3MHXiR+Chew47pNvU0Dwj8K82wHwovyFa1LQBh3M/4v8slhBTc9/WNdVQ1wtV8KzLy11ldDfPLvT1YhUrL4ZO+wTF+62m2IzpB9ST7t52awBg90/UezspMt/DafkgKqvF0WaQMRSOFnnwdguLbvFUCG5cLC7w0LfVWqO9UFjsMp7Qz4ggtVsgOKtGVQdQyN9NtfG24MO9fCd4L/L1lpbtinHrdA5qYx5cREAI6Xr7tlvXK7uANwpDCnxlBBPxyZ//nVxtDOw48K7xWvns0VNmrgeEJG5yRSLo0jO+vnbuKjowBVpPWMcTOGn7MB3R2PANv+NtMvyhM1M7mmEpIbLDTya6QJu+a8lX4t//2BS5mJwRLNf+2Iu56s/ETbKc1eyZwyvO mJr7Zdo9 4HGzYr1Ko9cF3zNJ4ubz1x1S1Rg/8dcLV4JYATCZ2AHyV8nuMbofO4wRhBP+1LUx/2Tax/ClE0s+38zq+5TyfXCLbLKo+KFISYY41zqX9DX2KDbdGrVY/DEJAGT4A82KgEEp708RPdoGqTKvND9a7zAw13bXa/pQm5/YCkzdC/pHcm0Z2I9G4dofKagAK+rfLfSLnCXD7kFKdIrnZT5Fi0zQjz8sX7OxGpbBsef4+DLeCAjJdkTg1U8fZaFfJkjzOFYxZWpxuzLbryiY3+QdTxd9gEZvW9672SAFyyuErD089rmZ6jDYPIy7oV91MT4ehR5kWwS0S96PfRfHchFVvA/pVgfewhgNuUgmorjLFBlTa7QR7/6/cilmHYeuny7KwOPdjQuoFsxQrv0ob35NYBTm9Sw== 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: Use the helpers to simplify code, also kill unneeded goto cpy_name. Cc: Peter Zijlstra Cc: Arnaldo Carvalho de Melo Reviewed-by: David Hildenbrand Signed-off-by: Kefeng Wang --- kernel/events/core.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index f84e2640ea2f..b36d0823ff33 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -8631,7 +8631,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) unsigned int size; char tmp[16]; char *buf = NULL; - char *name; + char *name = NULL; if (vma->vm_flags & VM_READ) prot |= PROT_READ; @@ -8678,29 +8678,18 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) goto got_name; } else { - if (vma->vm_ops && vma->vm_ops->name) { + if (vma->vm_ops && vma->vm_ops->name) name = (char *) vma->vm_ops->name(vma); - if (name) - goto cpy_name; + if (!name) + name = (char *)arch_vma_name(vma); + if (!name) { + if (vma_is_initial_heap(vma)) + name = "[heap]"; + else if (vma_is_initial_stack(vma)) + name = "[stack]"; + else + name = "//anon"; } - - name = (char *)arch_vma_name(vma); - if (name) - goto cpy_name; - - if (vma->vm_start <= vma->vm_mm->start_brk && - vma->vm_end >= vma->vm_mm->brk) { - name = "[heap]"; - goto cpy_name; - } - if (vma->vm_start <= vma->vm_mm->start_stack && - vma->vm_end >= vma->vm_mm->start_stack) { - name = "[stack]"; - goto cpy_name; - } - - name = "//anon"; - goto cpy_name; } cpy_name: