Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4028603ybd; Tue, 25 Jun 2019 12:44:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3C+K8WicLkid4fz1imewo+6tLSVAekRCfXStJRaE3F7KoZJ32ehywzPoboYzGBWKjG2zp X-Received: by 2002:a17:902:968c:: with SMTP id n12mr445749plp.59.1561491857383; Tue, 25 Jun 2019 12:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561491857; cv=none; d=google.com; s=arc-20160816; b=0flcI5p7QyGIa80zHp7jQbBPoxAoHtWi4bRj5P1mx7/veiVZ+5tu0+BtBxfynbzV0G f46LMpXxN2uSL4hjULU0wjSkujs1NGGVB2/pTb+chC8PWQm4HAGBj/MPzX1l6sKUBH5P FOk3RQvtCMmcqjSTGODbG4/oAB9Z2pwLqs0WZlNL7hcJsRruSDCNzSo9mWqY0ob6UA+e MLQzmV6K4uN8deb1ok3YXX/jd7P28UGW5EmVrfDL0k/Jqkcey7OeJSLTlBoR6YwlnkAs GdocFllOZuzeBw3Srn5b1vnG3XbDM2fzgMFR+dPJfJ1dOfpjfNcHgSN7fPfQRddazM6e xQig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rIEg9mImdLbOPWr5JcAO9mpGaP6d2/FlgncwQFfkJdw=; b=ZaBhbxl4P2KhpXiDQ2rLCOAJ5MDH4MNGSE84nm3mcscGJpkmpSKQnE5Kt++/YdD4xE i1CJh7zdxjIi9qzNbmSN/CMx/IJLHkCX3oNNN25p4lvuoFL7qKlmnROg1a0ddwMbSU8z 2vXcWlzYDBegqWkfaxKo7VK5xuAtLlHTV0m9WXBFsXQUIIBbu4k+YeJ4qsPogU+fkyQY x4BJtKCeucDE9U2s4+J2+v+aqsLVFml75eKYOUDe+CZTFu0qp8g0yrpzmR0ZaBWCBH+W 9329H7N/K68c6+rEW+tcjU53wygAof5tU6gOPKNQWp70FoQ6LESvZE8qvvhRYZIFHVbS Do5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iFw/1dYY"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si72343pjr.47.2019.06.25.12.44.01; Tue, 25 Jun 2019 12:44:17 -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; dkim=pass header.i=@linaro.org header.s=google header.b="iFw/1dYY"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731188AbfFYRON (ORCPT + 99 others); Tue, 25 Jun 2019 13:14:13 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:37753 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727540AbfFYROM (ORCPT ); Tue, 25 Jun 2019 13:14:12 -0400 Received: by mail-io1-f66.google.com with SMTP id e5so1928591iok.4 for ; Tue, 25 Jun 2019 10:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rIEg9mImdLbOPWr5JcAO9mpGaP6d2/FlgncwQFfkJdw=; b=iFw/1dYYVqRHgcAh1TpJFGK77tujLxqxZtyDQdAChfPK8J2o5Z35qj7HlPTvAoJDh0 0LUe8zRzcBUHlMIsII05VrtML3UOjVu/FQEjIrmezQ6XDdecyYt7zJPA5fpXIGdpt63p DHUgZqIHhAHn5Y29772IQWcGUWCAZyj5Z2xwo8VQFeDUCFWyvp8tluEdpnBnrkD63QQv TQwDL87DoNOU7cDCAPKgC+e7rxUyug338krujNQfqkEtiqWde1T1kd0ZNcLYKO+v1JaY zr5Ga8ex+w/NpqHgnMXiK+QpBeUCEVe1JKHl6CYdS6u3bHTHx1BMwcVsbzZ5dFI0KiG1 qqsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rIEg9mImdLbOPWr5JcAO9mpGaP6d2/FlgncwQFfkJdw=; b=XcQX5jUImrylgOH8xA/TaNfmsEVShnGBdT2Fzoxx0mi/l6k2cggfgrXbpkV36DRK2B jz32CBJRxkKOqLPJVKQGgOpIMUL6UA5b3ETrLnmY66O/bQnAbYuuVFdnRa5kpZbBqvw2 1X+NW6A5u9Yxhbca03HJzKm5lpy8cU4C7EniJUm5wBXvF5pks8i5etGlxwayRO/Vc1I2 cONEKzkjc2xz1WsGfk4fuD6JNYKHXVvVVA4FwwBpm59ta2kkwPU52PYhDvsNMDT2DcI0 +tFuccYbTcZw8MGeu5NKvWbZP/tclo9VCIkBdyetU6xgeleNrpUFbCJwfnRZ+VpEn8zf rC8Q== X-Gm-Message-State: APjAAAVY902yIDpVOrS30a6xooyvO+XbrPew9U92qdoJvkK4ykeQ6njo /bC1g73dJPupCsyJMd28vXYXU+GZQAjqx4zMvx1jGQ== X-Received: by 2002:a05:6638:3d6:: with SMTP id r22mr457862jaq.71.1561482851619; Tue, 25 Jun 2019 10:14:11 -0700 (PDT) MIME-Version: 1.0 References: <20190617150024.11787-1-leo.yan@linaro.org> <20190620005829.GH24549@leoy-ThinkPad-X240s> <20190624190009.GE4181@kernel.org> In-Reply-To: <20190624190009.GE4181@kernel.org> From: Mathieu Poirier Date: Tue, 25 Jun 2019 11:14:00 -0600 Message-ID: Subject: Re: [PATCH] perf cs-etm: Improve completeness for kernel address space To: Arnaldo Carvalho de Melo Cc: Leo Yan , Linux Kernel Mailing List , linux-arm-kernel , netdev@vger.kernel.org, bpf@vger.kernel.org, Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , Coresight ML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Jun 2019 at 13:00, Arnaldo Carvalho de Melo wrote: > > Em Thu, Jun 20, 2019 at 08:58:29AM +0800, Leo Yan escreveu: > > Hi Mathieu, > > > > On Wed, Jun 19, 2019 at 11:49:44AM -0600, Mathieu Poirier wrote: > > > > [...] > > > > > > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config > > > > index 51dd00f65709..4776c2c1fb6d 100644 > > > > --- a/tools/perf/Makefile.config > > > > +++ b/tools/perf/Makefile.config > > > > @@ -418,6 +418,30 @@ ifdef CORESIGHT > > > > endif > > > > LDFLAGS += $(LIBOPENCSD_LDFLAGS) > > > > EXTLIBS += $(OPENCSDLIBS) > > > > + ifneq ($(wildcard $(srctree)/arch/arm64/kernel/vmlinux.lds),) > > > > + # Extract info from lds: > > > > + # . = ((((((((0xffffffffffffffff)) - (((1)) << (48)) + 1) + (0)) + (0x08000000))) + (0x08000000))) + 0x00080000; > > > > + # ARM64_PRE_START_SIZE := (0x08000000 + 0x08000000 + 0x00080000) > > > > + ARM64_PRE_START_SIZE := $(shell egrep ' \. \= \({8}0x[0-9a-fA-F]+\){2}' \ > > > > + $(srctree)/arch/arm64/kernel/vmlinux.lds | \ > > > > + sed -e 's/[(|)|.|=|+|<|;|-]//g' -e 's/ \+/ /g' -e 's/^[ \t]*//' | \ > > > > + awk -F' ' '{print "("$$6 "+" $$7 "+" $$8")"}' 2>/dev/null) > > > > + else > > > > + ARM64_PRE_START_SIZE := 0 > > > > + endif > > > > + CFLAGS += -DARM64_PRE_START_SIZE="$(ARM64_PRE_START_SIZE)" > > > > + ifneq ($(wildcard $(srctree)/arch/arm/kernel/vmlinux.lds),) > > > > + # Extract info from lds: > > > > + # . = ((0xC0000000)) + 0x00208000; > > > > + # ARM_PRE_START_SIZE := 0x00208000 > > > > + ARM_PRE_START_SIZE := $(shell egrep ' \. \= \({2}0x[0-9a-fA-F]+\){2}' \ > > > > + $(srctree)/arch/arm/kernel/vmlinux.lds | \ > > > > + sed -e 's/[(|)|.|=|+|<|;|-]//g' -e 's/ \+/ /g' -e 's/^[ \t]*//' | \ > > > > + awk -F' ' '{print "("$$2")"}' 2>/dev/null) > > > > + else > > > > + ARM_PRE_START_SIZE := 0 > > > > + endif > > > > + CFLAGS += -DARM_PRE_START_SIZE="$(ARM_PRE_START_SIZE)" > > > > $(call detected,CONFIG_LIBOPENCSD) > > > > ifdef CSTRACE_RAW > > > > CFLAGS += -DCS_DEBUG_RAW > > > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > > > > index 0c7776b51045..ae831f836c70 100644 > > > > --- a/tools/perf/util/cs-etm.c > > > > +++ b/tools/perf/util/cs-etm.c > > > > @@ -613,10 +613,34 @@ static void cs_etm__free(struct perf_session *session) > > > > static u8 cs_etm__cpu_mode(struct cs_etm_queue *etmq, u64 address) > > > > { > > > > struct machine *machine; > > > > + u64 fixup_kernel_start = 0; > > > > + const char *arch; > > > > > > > > machine = etmq->etm->machine; > > > > + arch = perf_env__arch(machine->env); > > > > > > > > - if (address >= etmq->etm->kernel_start) { > > > > + /* > > > > + * Since arm and arm64 specify some memory regions prior to > > > > + * 'kernel_start', kernel addresses can be less than 'kernel_start'. > > > > + * > > > > + * For arm architecture, the 16MB virtual memory space prior to > > > > + * 'kernel_start' is allocated to device modules, a PMD table if > > > > + * CONFIG_HIGHMEM is enabled and a PGD table. > > > > + * > > > > + * For arm64 architecture, the root PGD table, device module memory > > > > + * region and BPF jit region are prior to 'kernel_start'. > > > > + * > > > > + * To reflect the complete kernel address space, compensate these > > > > + * pre-defined regions for kernel start address. > > > > + */ > > > > + if (!strcmp(arch, "arm64")) > > > > + fixup_kernel_start = etmq->etm->kernel_start - > > > > + ARM64_PRE_START_SIZE; > > > > + else if (!strcmp(arch, "arm")) > > > > + fixup_kernel_start = etmq->etm->kernel_start - > > > > + ARM_PRE_START_SIZE; > > > > > > I will test your work but from a quick look wouldn't it be better to > > > have a single define name here? From looking at the modifications you > > > did to Makefile.config there doesn't seem to be a reason to have two. > > > > Thanks for suggestion. I changed to use single define > > ARM_PRE_START_SIZE and sent patch v2 [1]. > > > > If possible, please test patch v2. > > > > Thanks, > > Leo Yan > > So just for the record, I'm waiting for Mathieu on this one, i.e. for > him to test/ack v3. Right, please give me some time to test this. As Leo indicated the procedure is time consuming. Thanks, Mathieu > > - Arnaldo > > > [1] https://lore.kernel.org/linux-arm-kernel/20190620005428.20883-1-leo.yan@linaro.org/T/#u > > > > > > + > > > > + if (address >= fixup_kernel_start) { > > > > if (machine__is_host(machine)) > > > > return PERF_RECORD_MISC_KERNEL; > > > > else > > > > -- > > > > 2.17.1 > > > > > > -- > > - Arnaldo