From mboxrd@z Thu Jan 1 00:00:00 1970 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=-0.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_HTML_ONLY,SPF_HELO_NONE,SPF_PASS autolearn=no 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 83BC1C433E0 for ; Wed, 3 Feb 2021 03:50:40 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 902DB64E08 for ; Wed, 3 Feb 2021 03:50:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 902DB64E08 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DVnlK68w2zDwww for ; Wed, 3 Feb 2021 14:50:37 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=atrajeev@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=UrZ1sVuG; dkim-atps=neutral Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DVLk76vySzDqZq for ; Tue, 2 Feb 2021 21:33:03 +1100 (AEDT) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 112AWDS0020085; Tue, 2 Feb 2021 05:32:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : mime-version : content-type : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=pp1; bh=eeHEOfylBqj+cp8cYTXBgNExeuhTme5LvIAKbE1M0qk=; b=UrZ1sVuGRzSbml/KBM3GBarcAJ6PkFqNf+FKIB+HMxwisW9HB0eesMr5LRWcb4vddtfo Y06M0nhlNlvXA87XtodPp6aUAEkzTVfSzGMGtUj4E2m4MA5/rtgm3O5+HNgBXZE32paP uodCG08H48Yh8O0/Hmb1JK4mp47BCdIGQbHvZnpcpsj/hyB4o655PC6xSu6MZLp3np1h 2klXi43GHQS0dbWhPN1aKoW8N8fj42VY50Hw6c0vzLjEOC5G0hKltAMfOKygvi3faALc 5SVEm6okMdnEkX2ONmlelQL3nY/rG5rxYgYMajO3yKTBlUFU3HEJ8KeN6T+5xjCLeZtD fQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 36f4sd0j1t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Feb 2021 05:32:59 -0500 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 112AWYDv021479; Tue, 2 Feb 2021 05:32:58 -0500 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 36f4sd0j15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Feb 2021 05:32:58 -0500 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 112ANXAj009083; Tue, 2 Feb 2021 10:32:57 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03fra.de.ibm.com with ESMTP id 36cy389e1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Feb 2021 10:32:56 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 112AWr0r8323372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Feb 2021 10:32:54 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D59CAA4055; Tue, 2 Feb 2021 10:32:53 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52D9BA4051; Tue, 2 Feb 2021 10:32:52 +0000 (GMT) Received: from [9.79.254.227] (unknown [9.79.254.227]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 2 Feb 2021 10:32:52 +0000 (GMT) Subject: Re: [PATCH] tools/perf: Fix powerpc gap between kernel end and module start Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Content-Type: text/html; charset=us-ascii X-Apple-Auto-Saved: 1 X-Apple-Mail-Plain-Text-Draft: yes From: Athira Rajeev X-Apple-Mail-Remote-Attachments: YES X-Apple-Base-Url: x-msg://9/ In-Reply-To: X-Apple-Windows-Friendly: 1 Date: Tue, 2 Feb 2021 16:02:36 +0530 X-Apple-Mail-Signature: SKIP_SIGNATURE Content-Transfer-Encoding: quoted-printable Message-Id: <1D564116-5FAC-4775-BEB2-4D5B837080D6@linux.vnet.ibm.com> References: <1609208054-1566-1-git-send-email-atrajeev@linux.vnet.ibm.com> <20210112093811.GA1272772@krava> X-Uniform-Type-Identifier: com.apple.mail-draft To: Arnaldo Carvalho de Melo X-Mailer: Apple Mail (2.3608.120.23.2.4) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.737 definitions=2021-02-02_05:2021-02-02, 2021-02-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 suspectscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102020067 X-Mailman-Approved-At: Wed, 03 Feb 2021 14:49:16 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev , Madhavan Srinivasan , Jiri Olsa , Jiri Olsa , Kajol Jain Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev"


On = 18-Jan-2021, at 3:51 PM, kajoljain <kjain@linux.ibm.com> = wrote:



On 1/12/21 3:08 PM, Jiri Olsa = wrote:
On Mon, Dec 28, 2020 at 09:14:14PM = -0500, Athira Rajeev wrote:

SNIP

c000000002799370 b backtrace_flag
c000000002799378 B = radix_tree_node_cachep
c000000002799380 B = __bss_stop
c0000000027a0000 B _end
c008000003890000 t = icmp_checkentry =      [ip_tables]
c008000003890038 t = ipt_alloc_initial_table =      [ip_tables]
c008000003890468 T = ipt_do_table [ip_tables]
c008000003890de8 T = ipt_unregister_table_pre_exit =        [ip_tables]
...

Perf = calls function symbols__fixup_end() which sets the end of symbol
to = 0xc008000003890000, which is the next address and this is the = start
address of first module (icmp_checkentry in above) which will = make the
huge symbol size of 0x80000010f0000.

After = symbols__fixup_end:
symbols__fixup_end: sym->name: _end, = sym->start: 0xc0000000027a0000,
sym->end: = 0xc008000003890000

On powerpc, kernel text segment is located at = 0xc000000000000000
whereas the modules are located at very high = memory addresses,
0xc00800000xxxxxxx. Since the gap between end of = kernel text segment
and beginning of first module's address is high, = histogram allocation
using calloc fails.

Fix this by detecting = the kernel's last symbol and limiting
the range of last kernel symbol = to pagesize.

Patch looks good to = me.

Tested-By: Kajol = Jain<kjain@linux.ibm.com>

Thanks,
Kajol = Jain

Signed-off-by: Athira = Rajeev<atrajeev@linux.vnet.ibm.com>

I can't = test, but since the same approach works for arm and s390,
this also = looks ok

Acked-by: Jiri Olsa = <jolsa@redhat.com>

thanks,
jirka

Hi Arnaldo,

Can you please help review this patch and = merge if this looks good..

Thanks
Athira


---
tools/perf/arch/powerpc/util/Build =     |  1 = +
tools/perf/arch/powerpc/util/machine.c | 24 = ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
create = mode 100644 tools/perf/arch/powerpc/util/machine.c

diff --git = a/tools/perf/arch/powerpc/util/Build = b/tools/perf/arch/powerpc/util/Build
index e86e210bf514..b7945e5a543b = 100644
--- a/tools/perf/arch/powerpc/util/Build
+++ = b/tools/perf/arch/powerpc/util/Build
@@ -1,4 +1,5 @@
perf-y +=3D = header.o
+perf-y +=3D machine.o
perf-y +=3D kvm-stat.o
perf-y = +=3D perf_regs.o
perf-y +=3D mem-events.o
diff --git = a/tools/perf/arch/powerpc/util/machine.c = b/tools/perf/arch/powerpc/util/machine.c
new file mode = 100644
index 000000000000..c30e5cc88c16
--- /dev/null
+++ = b/tools/perf/arch/powerpc/util/machine.c
@@ -0,0 +1,24 @@
+// = SPDX-License-Identifier: GPL-2.0
+
+#include = <stdio.h>
+#include <string.h>
+#include = <internal/lib.h> // page_size
+#include "debug.h"
+#include = "symbol.h"
+
+/* On powerpc kernel text segment start at memory = addresses, 0xc000000000000000
+ * whereas the modules are located at = very high memory addresses,
+ * for example 0xc00800000xxxxxxx. The = gap between end of kernel text segment
+ * and beginning of first = module's text segment is very high.
+ * Therefore do not fill this = gap and do not assign it to the kernel dso map.
+ */
+
+void = arch__symbols__fixup_end(struct symbol *p, struct symbol = *c)
+{
+ = if (strchr(p->name, '[') =3D=3D NULL && = strchr(c->name, '['))
+ /* Limit the range of last kernel = symbol */
+ = = p->end +=3D page_size;
+ else
+ p->end = =3D c->start;
+ pr_debug4("%s sym:%s end:%#lx\n", = __func__, p->name, p->end);
+}
-- =
1.8.3.1

=