Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1434952ybi; Wed, 19 Jun 2019 20:52:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxC3dBxqmEuRpYinceThQxQKE/vFqAboQLQWI8Q/ZurU9igylJwbDgugdSmMp11xZphHsUP X-Received: by 2002:a17:90a:206a:: with SMTP id n97mr826758pjc.10.1561002742497; Wed, 19 Jun 2019 20:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561002742; cv=none; d=google.com; s=arc-20160816; b=W4UFvRswlafnXoc25l8jTt4MU4OZQ6xNHxk2oeU24drO28yQ7RRhddvG56WqaRhTl7 /aRQCqRIoHz3d9JaXH2AdTqX3aEumY0DnX7+nHd4WOb7RhGk7GRfPg4SLPvc3vI1lS4j oCuVZkg1YMIEijqr+e4Si9KJ5LkOts6TjEV4VIce9BpfH15ZqNedVY3T7lTYhjqCWUHT dCFBxar7KEOxhGNUMQPJ1adBkihdFgRdAU0IohlEReB9bxiwBb5jMC0caV4ZA6+LgoxT J9ehX8KTia0x+LjGXob2e7z14Kww/LJaNShtW61IRKhKTsOgsMn+L9lKVJHmPu9g3PXs +zbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=o7v/MxKerkj9lXOy7XckOwr/I7Upmu6TOve4Yqn6x4Q=; b=q9tooUGtb/aHuX6hFnfrFrIvnn1qsWQdiLWYh7jt5BjKob1J8s//Ah3f4Xoqiso6Eh bW5P3eIIKpZZzNzWHs7g0xHHn2ermUHs4yojJ2Ox4PliWdAC7mg6LC4AD4aHpRY7vLj0 F6M0WyLg7twSxuMntLEn33vsJ8I6+BeQm/2vU70RoN3rEuI8PUzsl+ULoVasVohZr/Gw 7hfRPSKUMaNOfmAGhyItn9IIX3bbfC5fndf4aMZb6Z8rAmM6fJ0G9jXF+CJxOoyoqGA4 d9+PHF94O0EYGX2IKJ8pTmyaT39bDHHwOBoWcEms4sGtckODVNs5kKaRiWm2Z+LGOqRN MH6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VMhEP5fi; 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 h7si4680378pgk.379.2019.06.19.20.52.04; Wed, 19 Jun 2019 20:52:22 -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=VMhEP5fi; 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 S1726419AbfFTDwA (ORCPT + 99 others); Wed, 19 Jun 2019 23:52:00 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:38016 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731066AbfFTDv7 (ORCPT ); Wed, 19 Jun 2019 23:51:59 -0400 Received: by mail-ot1-f67.google.com with SMTP id d17so1346451oth.5 for ; Wed, 19 Jun 2019 20:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=o7v/MxKerkj9lXOy7XckOwr/I7Upmu6TOve4Yqn6x4Q=; b=VMhEP5fif4wABtZ6fnhcX8LomnG6o9Ke1/iYLehVNCBc8CTXCY6eAYQs95V+lPrYD4 q817yFJ4ckKp6fqb88youV+TDnjPo7BiqKfPBeqzsSvtKdbPb+d8Fj1fht8vuavCWuzA hw8uhFcFrQIKaMrVz2BbaWH3SiA86F+RQIoh/vJzKbvs9vQdB8teIqKMKwRhJIj6ZbxR nLuR86Ld4v3e0QHOvVX+iMQi06lQFl0ye7NEFsUrORYgDA30i6jfRXstlUWpJpqCwbHa SKqQkqUpuftwbTzQG+NW2ctVxgdCNqPvVlcsTVMj5Ab7fFqX5VooKynidrx4++vY6YvO l6pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=o7v/MxKerkj9lXOy7XckOwr/I7Upmu6TOve4Yqn6x4Q=; b=PN3qcVfsglbD6AO6ptX9HyyRnL8m1r3rr3uuXAEJ8x67WHxsuH34eQIH8wU6FxT58W h0g8l4zu5aMx/U69nqPp3bizQzaSZp9gG6MiB1SWqPlg/ZDXgQmciiLTTbZmlYnYTDLb LW1q64IyKWRCf5D7kwunGRaU+v0rMDpS8WvSPyXKXFTIXwx5kTQ3lts2nJM1ECiRyc75 Y2JnMURY+4elDW8ExR8nrbhjyI73D1mNRQtuCDNFoR7GcpK47F5QyoMiaPbp0JcPztNk 9ODT8EXs7aKtRcQegqpZgDR3ybuZKN5W0WgmyHPUbLSDCquQ8ENURVvQnZbFL0XDm6wx 1dNw== X-Gm-Message-State: APjAAAVx3x1+lM0JC5DLKqqacQyGMSDiRfZXxmhUTzkj+W4HLwd1g0W8 0TuDTqineRzLQV+KSbjae3zbGA== X-Received: by 2002:a9d:62d2:: with SMTP id z18mr5979346otk.7.1561002718547; Wed, 19 Jun 2019 20:51:58 -0700 (PDT) Received: from leoy-ThinkPad-X240s (li964-79.members.linode.com. [45.33.10.79]) by smtp.gmail.com with ESMTPSA id g10sm8033999otg.81.2019.06.19.20.51.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Jun 2019 20:51:57 -0700 (PDT) Date: Thu, 20 Jun 2019 11:51:46 +0800 From: Leo Yan To: Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Peter Zijlstra , coresight@lists.linaro.org Subject: Re: [PATCH v2] perf cs-etm: Improve completeness for kernel address space Message-ID: <20190620035146.GJ24549@leoy-ThinkPad-X240s> References: <20190620005428.20883-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190620005428.20883-1-leo.yan@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, On Thu, Jun 20, 2019 at 08:54:28AM +0800, Leo Yan wrote: [...] > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config > index 51dd00f65709..cf5906d667aa 100644 > --- a/tools/perf/Makefile.config > +++ b/tools/perf/Makefile.config > @@ -418,6 +418,26 @@ ifdef CORESIGHT > endif > LDFLAGS += $(LIBOPENCSD_LDFLAGS) > EXTLIBS += $(OPENCSDLIBS) > + ARM_PRE_START_SIZE := 0 > + ifeq ($(SRCARCH),arm64) > + # Extract info from lds: > + # . = ((((((((0xffffffffffffffff)) - (((1)) << (48)) + 1) + (0)) + (0x08000000))) + (0x08000000))) + 0x00080000; > + # ARM_PRE_START_SIZE := (0x08000000 + 0x08000000 + 0x00080000) > + ARM_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) > + endif > + ifeq ($(SRCARCH),arm) > + # 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) > + endif > + CFLAGS += -DARM_PRE_START_SIZE="$(ARM_PRE_START_SIZE)" I did testing for building perf with this patch, this patch is fragile and easily introduce the building warning: : error: "ARM_PRE_START_SIZE" redefined [-Werror] : note: this is the location of the previous definition To dismiss this error, I need to change the macro define as below: + CFLAGS += -DARM_PRE_START_SIZE=$(ARM_PRE_START_SIZE) So I sent patch v3 to address this issue and please directly reivew patch v3. Sorry for spamming. Thanks, Leo Yan > $(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..5fa0be3a3904 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -613,10 +613,27 @@ 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; > > machine = etmq->etm->machine; > > - 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. > + */ > + fixup_kernel_start = etmq->etm->kernel_start - ARM_PRE_START_SIZE; > + > + if (address >= fixup_kernel_start) { > if (machine__is_host(machine)) > return PERF_RECORD_MISC_KERNEL; > else > -- > 2.17.1 >