Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1303195ybi; Wed, 19 Jun 2019 18:00:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqze7q8sGMuEHr+E803hqjD6YnvF3JNgCsopM9cph19zMQE36A4BAWEQEvF2d6BKOE+Me3Mb X-Received: by 2002:a63:2259:: with SMTP id t25mr9683056pgm.298.1560992414010; Wed, 19 Jun 2019 18:00:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560992414; cv=none; d=google.com; s=arc-20160816; b=IsWMAO9kcdHI3NBuSG9tGL1EdmP59bfQs+UtRDiUN5eCzws3gH/85Fph3x/sYX6JYM xsTVv/lFNFyKgRIZOk5jCJlxp/EiWEw8yLxPQzcnafe/TCcOdwnXP1C7cS7RuEMY5Qoy zjKHPPhQS2cCumDxF7WHM06hf6qNlPLSpXzdmMxWjl9gvAD0PgtrPk1GEkjtgEgiVSRi kTXq/VKeISt+Hu9rBAloDqbcmZz9VJb7DJoS1AZs7EdVXxETpDKZ/PKmE4TAuQfEGEYO KYj4pnvsLSVIkBOLuoSyApZst/P+ySHpr/8l5gTN+mmpU/aaQE8N7uAp2Q4ggvabjRW4 3rUQ== 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=Pv6DYs/rgMUhmFVTIlv6mQtmI4/e3SRdgmeYYSiE/gY=; b=wmno/m0/x7kYVJl+kgp/zud86zFWCUjG+Nt2OqMvUvctnnOwTXZuGBPE0F5kJQAnTo tywDHNfcVx5mFMPUjHVMwnGuUEqhe89cFu8AAWm11Osck5Ga9TikPkCU3zY51goWkOZv i4zjZ3xWfI+a5iKkqHxcQFcgH3pWqzn1GTQCjCkgCb86NgzNgG22Z3ackyU6N8XgIbsA A6sb3Z7F/gfaFQRhdbQazamLsg3zmXKMxrrOg1gz9bqJWkxncB10sZ3Wpr3LIT0nigXh ew8YeHAV25Aw5QCTmSHHLnqN8icpbLkPaA0P733o/napMPhuFhRe90Zm/ecofYaJ6H5H /kcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oTUnU1I9; 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 w185si18453091pfb.170.2019.06.19.17.59.57; Wed, 19 Jun 2019 18:00:13 -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=oTUnU1I9; 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 S1730868AbfFTA6i (ORCPT + 99 others); Wed, 19 Jun 2019 20:58:38 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:35210 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbfFTA6i (ORCPT ); Wed, 19 Jun 2019 20:58:38 -0400 Received: by mail-ot1-f65.google.com with SMTP id j19so1032718otq.2 for ; Wed, 19 Jun 2019 17:58:37 -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=Pv6DYs/rgMUhmFVTIlv6mQtmI4/e3SRdgmeYYSiE/gY=; b=oTUnU1I9Q3P6mnwGmSHo8VtVE9FzfceDm8JYzas75iB8Vpe9bONAVPH2S3TkqM2T1F AfMa+uPb+HeX3Uw62WFDmNKu7P8wioRQ2b3H0FBzHxKQnhgOOWvrNf5guNAdwAaDrF/I xpJ/tV30aZvykXO0oOcH6KE4RQNKoOOFP/boZ/cieuj+impdRqlqR+E45fvl9LeIx1Md p91138c9GCF1m2LJIz2xmLR3PzI9z8/c1OIFmPjKktYAjHDR16lNQgi3V8PXARwSA4Tr pDxI9ygK81Mrd5QIssaBJhkHuqk1eXDNVLVe7aTsXm1Oyh8sR7oGawQguh8x4lYDolkK OGhQ== 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=Pv6DYs/rgMUhmFVTIlv6mQtmI4/e3SRdgmeYYSiE/gY=; b=e4BAUltng8PR/7PzhwFTbC+0Yf0fhnmvWy/wkA9+BY2G2dacmVIwXQzaEzZT/G+7QV fhV1VYip0P3gdFj3lNedPeWJW4goey1LEuyHzUuzFeRTbXXBo111UC90CXU3oG8n/Ymo kqXwRZCDyzfDltgu57cjovx5A4hrRkrSqxE5AQX6xpd0GjKw5Hru/DrfG/Jr/D2TJ3h7 9GS0/gazT5Haoy7tiS0t9PKUGnutffRF01tY/RvkDgo//GltceSj7hp5fFsMcw2LIdHH lpJedwRyvU6FMYIj+KvDrdN665E+RH05ZMLPoPW3prGZnq6NuDZdPFwbrwr4Bbaho9PU HsyA== X-Gm-Message-State: APjAAAWN/teoN6GIs/wZFl8N80V1HvF4Kz7AJ0TiF/E43KovuickLqaZ iRvJdZ+jpDq5wKDDUNoRLvj77g== X-Received: by 2002:a9d:7d05:: with SMTP id v5mr8624081otn.245.1560992317485; Wed, 19 Jun 2019 17:58:37 -0700 (PDT) Received: from leoy-ThinkPad-X240s (li964-79.members.linode.com. [45.33.10.79]) by smtp.gmail.com with ESMTPSA id j135sm1940279oib.19.2019.06.19.17.58.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Jun 2019 17:58:36 -0700 (PDT) Date: Thu, 20 Jun 2019 08:58:29 +0800 From: Leo Yan To: Mathieu Poirier Cc: Arnaldo Carvalho de Melo , 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 Subject: Re: [PATCH] perf cs-etm: Improve completeness for kernel address space Message-ID: <20190620005829.GH24549@leoy-ThinkPad-X240s> References: <20190617150024.11787-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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 [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 > >