Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp48989pxb; Tue, 12 Jan 2021 19:41:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/a64Ue4yIVTeeVz9/z+pjUKvMfuYtIU4UV6w7sbcX0CTZFe+a4nPwPCxgdo+2oSznnmir X-Received: by 2002:a17:906:4146:: with SMTP id l6mr77782ejk.341.1610509280112; Tue, 12 Jan 2021 19:41:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610509280; cv=none; d=google.com; s=arc-20160816; b=vc2GfUlpUXF3YEjLC39S7CdO/8x5EKdU2twE9WJlV5kBDYyPS9xoxRN52T9JE7GxEb hZQtL09rbLWSTcBGYnOWDmicTIBo2SbInEiook/Ko7d7r80G1izRRk5n+R+2JL7UjphZ TDbQhSDcU4w1lXL+1jTW452/dYSgNQSq2z+Iw2kzwRpQoR00Li4pQbNeriObU9mccz41 UxdpcGBb1M6ymG0516lJl7HHM9Z6mwpwJQ2V3hDBqVWpatkIgUimYK4mn9EAW9wAjRhl H9NkQwuqUcFW5ui7lVJEkbdH6Dw6X3dAIoqOntdR57ehsLzg5sAfgwsPEHZ6V3LFioBI imKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=U065/+i85s4JwJu/tEldMSxCzMGg8gNUrqXbwKllSNY=; b=ZD4LcaUnSZBkyibZYxFtrN1ZHXuooI6Oiung9dLYc3+EFCqkStsvLGOk8npDdkpy60 NeOtQsFUBOmKsmYuv+qD78+YOel1n9aqIq/2F0ZWgFMP8KokUy8dE14mgs4XrX4k8vjN 1TM+V+DgfuH9cG8IZ7bA5EZKgkr7I66j3V6oi16ooeIHyXyvbZYRZUJNMZCqGAX9KkGY 625GQQbnDj9w4cXl5PaRX8IGJ8/fM/83migHkVyTURt12IMN994gi0dZvVk4q0xDmn3d 0B9g/2VCZD4/tFESId/JbQXi1ecF5qPcZXotMsLhxJkkLtLnHm5PmXwNBRhBfER07AVX yhbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jluNAwtd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si356106edp.294.2021.01.12.19.40.56; Tue, 12 Jan 2021 19:41:20 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=jluNAwtd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727201AbhAMC2T (ORCPT + 99 others); Tue, 12 Jan 2021 21:28:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbhAMC2T (ORCPT ); Tue, 12 Jan 2021 21:28:19 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25534C061786 for ; Tue, 12 Jan 2021 18:27:39 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id u4so217286pjn.4 for ; Tue, 12 Jan 2021 18:27:39 -0800 (PST) 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; bh=U065/+i85s4JwJu/tEldMSxCzMGg8gNUrqXbwKllSNY=; b=jluNAwtdoClM0rEr3qoU3llqih2zv1urBwcgbXv14wCR4oFEfUJZEWFWgxDXKLqbyB HFtgmlStaGhC/sovVwsD306MLzVd9Z5iYM3V29RyGB0aShzFzTST8ZYdPVF4AI5nsR/v p78rqoqbyOs3awbqfc7R4v7k+6AnMNNBahwlBgq2Bfv6kcUpPZa1mb9Hj0zq8vFnXI/S vuvWgS2pAdI0Iypb6URsCwJ4FABmPx6daBOVSEpfIr0Jfg8+odExQuY5OOwibicH9A/u fwGDKka1qqXqwST2MoocDd39bQoj0B3ytQhiKemgz5iFraN8aEoujhr9IOFCo7Kl22q8 Quyg== 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; bh=U065/+i85s4JwJu/tEldMSxCzMGg8gNUrqXbwKllSNY=; b=R8keBbOpnr9rF4Iopf1WsZyz3K7ko8D1sFJWISK5SIFLOk9U+Dh1E30FiGZ02JCKFa 4QpuWlaPP+CViSLMNR44X+h1y4EOBMwwWlLnEKPDKhmueernz0Kcyd4DElyx405IY03L NcB8M6GmuespNvorUZcoByS2rBj5u184NT5FiQ9Yb0PZHU25EXF+IPUxTqIHP9/oT3x6 BoNFSzUOZYqeDHpiUvHQA1D3k4cIRh1BNuHqGVRibkhye+y5FATE7I7ZZ5w4UbrNJhOp FOvOVV0wk//HNDaDgFuHHr+Ef7CJUPNBl2jdCLk4nh9Kh5f3saKrkDSBnlym25tyV/0g dPPA== X-Gm-Message-State: AOAM530nb2GZOEtYujz/0AVkb9WU2GT5EGShQHL8syT6xjvTAWppM+cd 0pESaSDqviOUtwm7UVn0SKMZ7A== X-Received: by 2002:a17:90b:17c7:: with SMTP id me7mr138574pjb.205.1610504858577; Tue, 12 Jan 2021 18:27:38 -0800 (PST) Received: from leoy-ThinkPad-X240s ([202.155.204.36]) by smtp.gmail.com with ESMTPSA id b5sm384882pga.54.2021.01.12.18.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 18:27:37 -0800 (PST) Date: Wed, 13 Jan 2021 10:27:32 +0800 From: Leo Yan To: Mike Leach Cc: Suzuki K Poulose , Arnaldo Carvalho de Melo , Mathieu Poirier , Alexander Shishkin , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , Daniel Kiss , Denis Nikitin , Coresight ML , linux-arm-kernel , Linux Kernel Mailing List Subject: Re: [PATCH v1 3/7] perf cs-etm: Calculate per CPU metadata array size Message-ID: <20210113022721.GG18965@leoy-ThinkPad-X240s> References: <20210109074435.626855-1-leo.yan@linaro.org> <20210109074435.626855-4-leo.yan@linaro.org> <96ec434e-4103-02ac-a05a-761a9ca8cb0d@arm.com> <20210111150608.GC222747@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mike, On Wed, Jan 13, 2021 at 12:00:10AM +0000, Mike Leach wrote: [...] > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > > index a2a369e2fbb6..edaec57362f0 100644 > > --- a/tools/perf/util/cs-etm.c > > +++ b/tools/perf/util/cs-etm.c > > @@ -2558,12 +2558,19 @@ int cs_etm__process_auxtrace_info(union perf_event *event, > > err = -ENOMEM; > > goto err_free_metadata; > > } > > - for (k = 0; k < CS_ETM_PRIV_MAX; k++) > > + for (k = 0; k < CS_ETM_PRIV_MAX; k++) { > > metadata[j][k] = ptr[i + k]; > > > > + if (ptr[i + k + 1] == __perf_cs_etmv3_magic || > > + ptr[i + k + 1] == __perf_cs_etmv4_magic) { > > + k++; > > + break; > > + } > > + } > > + > > /* The traceID is our handle */ > > idx = metadata[j][CS_ETM_ETMTRACEIDR]; > > - i += CS_ETM_PRIV_MAX; > > + i += k; > > } else if (ptr[i] == __perf_cs_etmv4_magic) { > > metadata[j] = zalloc(sizeof(*metadata[j]) * > > CS_ETMV4_PRIV_MAX); > > @@ -2571,12 +2578,19 @@ int cs_etm__process_auxtrace_info(union perf_event *event, > > err = -ENOMEM; > > goto err_free_metadata; > > } > > - for (k = 0; k < CS_ETMV4_PRIV_MAX; k++) > > + for (k = 0; k < CS_ETMV4_PRIV_MAX; k++) { > > metadata[j][k] = ptr[i + k]; > > > > + if (ptr[i + k + 1] == __perf_cs_etmv3_magic || > > + ptr[i + k + 1] == __perf_cs_etmv4_magic) { > > + k++; > > + break; > > + } > > + } > > + > > /* The traceID is our handle */ > > idx = metadata[j][CS_ETMV4_TRCTRACEIDR]; > > - i += CS_ETMV4_PRIV_MAX; > > + i += k; > > } > > > > /* Get an RB node for this CPU */ > > That would be a spot fix for the read /copy case, but will not fix the > print routine which will still bail out on older versions of the > format. (when using perf report --dump). > > The "self describing" format I have been looking at will add an > NR_PARAMS value to the common block in the CPU metadata parameter > list, increment the header version to '1' and update the format writer > to use the version 1 format while having the reader understand both v0 > and v1 formats. > > i..e in cs-etm.h perf I add: > /* > * Update the version for new format. > * > * New version 1 format adds a param count to the per cpu metadata. > * This allows easy adding of new metadata parameters. > * Requires that new params always added after current ones. > * Also allows client reader to handle file versions that are different by > * checking the number of params in the file vs the number expected. > */ > #define CS_HEADER_CURRENT_VERSION 1 > > /* Beginning of header common to both ETMv3 and V4 */ > enum { > CS_ETM_MAGIC, > CS_ETM_CPU, > CS_ETM_NR_PARAMS, /* number of parameters to follow in this block */ > }; > > where in verison 1, NR_PARAMS indicates the total number of params > that follow - so adding new parameters can be added to the metadata > enums and the tool will automatically adjust, and will handle v0 > files, plus older and newer files that have differing numbers of > parameters, as long as the parameters are only ever added to the end > of the list. > > I have been working on a patch for this today, which took a little > longer than expected as it was a little more complex than expected > (the printing routines in for the --dump command!). > > I will post this tomorrow when tested - and if we agree it works it > could be rolled into your set - it would make adding the PID parameter > easier, and ensure that this new format is available for the upcoming > developments. Thanks for the info. I will look at your patch and see how to fit with it. Thanks, Leo