Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5730514pxv; Wed, 21 Jul 2021 12:30:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPt/0JhD+mckinYjKj9nFcYJs+HGXl/vDr21CUclTQdjASe+/bpodj5sksPGDUT5CFTvk9 X-Received: by 2002:a02:cc19:: with SMTP id n25mr32258870jap.140.1626895723179; Wed, 21 Jul 2021 12:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626895723; cv=none; d=google.com; s=arc-20160816; b=UQ1JhYdqtgoaDynP2pBBLuuzpzHFmStr+Cu3WCC+hB9VeZiA6S5ygyxpffTQMXvQ/d 08ku1yZmsgdYMQc3D4SKFsK9IkD761Qxa/g3k6wgy+5DliWoIDNy7jnPufrzC2N/9KaV i3jW9Cm+8W9zsPAiAOWHyKf0XYAjufDkQ9sT+ITo/EkjW8FDZw6QgpQS0Pub8nkZ45sY eLXYRURggWhBCP8PRV3y3B+Ulpe/zT8jih8NnInOuRZzJXnR6wIJRjH7klyQ8FecxRbW zfME0auG5sd1HK25sm2gbCogRRNIvxCzFTEHY6Mm9Pp4GlemsC0oTj3qENL3KmYB2IKH flnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=r9hMwfTQWk/MCEhtoyjprzYbj3YC9xkVZqi/gVOl2a8=; b=sUp1JzTL/hFCeiTH0DWLiB7y95fixDvxKXQDM1LIIbgMdqEg68iWDev14hK/IAXuxe 4Zgwr9gd5QFGcml+06tJ4SKDh1zrHdmRRYsBqbeyjLvFYIh0QgUliJjITWDCrhHKCmvT S6NNsB6HpeboVoNpswwX96YBpzKhgqjb8YCHXmberYoiJe9JtTLwdIfOS6vYGJPBU3ZZ bWch1GNrJhDqQt2btSrYTQ8O+iVcFvg5a5cBejJPSREZCNrHy7mMh692tDntSt1rMoh5 /V3fdmqzSdNW5kMGa1llYRw5CSxzzgCNyqHVN1TjHeTsaf3ej6ddMS9nJdx4QLf1ti4w L08w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a16si26476021ilb.149.2021.07.21.12.28.31; Wed, 21 Jul 2021 12:28:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239531AbhGUOXk (ORCPT + 99 others); Wed, 21 Jul 2021 10:23:40 -0400 Received: from foss.arm.com ([217.140.110.172]:56866 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239502AbhGUOVj (ORCPT ); Wed, 21 Jul 2021 10:21:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9CEF531B; Wed, 21 Jul 2021 08:02:13 -0700 (PDT) Received: from e121896.arm.com (unknown [10.57.39.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 01DFC3F73D; Wed, 21 Jul 2021 08:02:10 -0700 (PDT) From: James Clark To: acme@kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org Cc: leo.yan@linaro.org, al.grant@arm.com, suzuki.poulose@arm.com, anshuman.khandual@arm.com, mike.leach@linaro.org, James Clark , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] perf cs-etm: Refactor initialisation of kernel start address Date: Wed, 21 Jul 2021 16:01:57 +0100 Message-Id: <20210721150202.32065-2-james.clark@arm.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210721150202.32065-1-james.clark@arm.com> References: <20210721150202.32065-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel start address is already cached in the machine struct once it is initialised, so storing it in the cs_etm struct is unnecessary. It also depends on kernel maps being available to be initialised. Therefore cs_etm__setup_queues() isn't an appropriate place to call it because it could be called before processing starts. It would be better to initialise it at the point when it is needed, then we can be sure that all the necessary maps are available. Also by calling machine__kernel_start() multiple times it can be initialised at some point, even if it failed to initialise previously due to missing maps. In a later commit cs_etm__setup_queues() will be moved which is the motivation for this change. Reviewed-by: Mathieu Poirier Signed-off-by: James Clark --- tools/perf/util/cs-etm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index bc1f64873c8f..4c69ef391f60 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -62,7 +62,6 @@ struct cs_etm_auxtrace { u64 instructions_sample_period; u64 instructions_id; u64 **metadata; - u64 kernel_start; unsigned int pmu_type; }; @@ -691,7 +690,7 @@ static u8 cs_etm__cpu_mode(struct cs_etm_queue *etmq, u64 address) machine = etmq->etm->machine; - if (address >= etmq->etm->kernel_start) { + if (address >= machine__kernel_start(machine)) { if (machine__is_host(machine)) return PERF_RECORD_MISC_KERNEL; else @@ -901,9 +900,6 @@ static int cs_etm__setup_queues(struct cs_etm_auxtrace *etm) unsigned int i; int ret; - if (!etm->kernel_start) - etm->kernel_start = machine__kernel_start(etm->machine); - for (i = 0; i < etm->queues.nr_queues; i++) { ret = cs_etm__setup_queue(etm, &etm->queues.queue_array[i], i); if (ret) -- 2.28.0