Received: by 2002:ac2:48a3:0:0:0:0:0 with SMTP id u3csp563929lfg; Fri, 11 Mar 2022 13:24:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzl68PtKkX9Im8XqS7URjzsIA76irJ1mwkHfrTXdBWVSFEDUDacebSwoLoy9SnoVaNkORE9 X-Received: by 2002:a63:5547:0:b0:374:4ec0:bad0 with SMTP id f7-20020a635547000000b003744ec0bad0mr10043067pgm.169.1647033891347; Fri, 11 Mar 2022 13:24:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647033891; cv=none; d=google.com; s=arc-20160816; b=jwxG2xUNpDOWqQ6gmXlbHiut0Tjtfnd00mkm3K16Z1r2aggecEIGI/PdUW8FETj/e7 sQOZe8vYHZzAE+L1y1rMCo9D5fX9HTE2NpmV6EdIUvAgoc4WEWCSRLPqWrAauNvrJsuZ ViD3wopo9CpW2hBHKUSFc8CYy3zUlb/xD62/yx8V9GE6m4QNM0xEDkrYSJ5LAY2x9mQx aJkgH0w56l0Zi+hm/2wRB0+wX+N0+XQTzgIZBS7hsUOI7Udz3hcL+VCFko+zuKLYq/il L+40PvFdbYlFsw6WkgLpWJzfcaSC5fRbJgw4UIFjW3kRDN7R55893tmkdkbXT+jN6tV3 JsQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=t/+HHt1c39G7ywBZBGDd9qnAziedqgoDMlKoB6IGpeA=; b=gxCP2RSyg6kT+hp8ADus/BGcDOJ1XqzRR+56RtMOdCnCAsUbKkowbOHM4LYe2QMc5x NhAzxaYbXmzKNPeI7VPJp/LQTSJRVGZXdR5qnIM+aadn78Q/gVDiJtu5SQV8zXwiUw4e fWnY9/qagc8zemKTOxRkWSSBpeXMp1jIwOX28Xl4PUAkYppJjjUesJMXtHurydrx5I5v Be+JRRc2VpZ968RYXkUtG8lTLmsYpexssqkTYPkkIDRUuTKQIZqBPcktyyN5UnMz8KA5 oXlpNu5BdvcyOD5Jmt/JRdP9PwvZtXNRWMvgSJPjKrEIsgk+ixkxi0yDZfMj4RRzha+A cdIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nmim9p+X; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v4-20020a1709029a0400b0014af00acf68si8322735plp.177.2022.03.11.13.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:24:51 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nmim9p+X; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 28E5B229CB0; Fri, 11 Mar 2022 12:59:58 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350055AbiCKPzv (ORCPT + 99 others); Fri, 11 Mar 2022 10:55:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350013AbiCKPzW (ORCPT ); Fri, 11 Mar 2022 10:55:22 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6972B151696 for ; Fri, 11 Mar 2022 07:53:47 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id j26so13609420wrb.1 for ; Fri, 11 Mar 2022 07:53:47 -0800 (PST) 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=t/+HHt1c39G7ywBZBGDd9qnAziedqgoDMlKoB6IGpeA=; b=Nmim9p+XStxDNEaAN2FZW4KcwpMbcvvn1QwY/w4Aq1UMFUvc2CXbAeK9pAjDvTZjLr U2Fi3+LTIeGd1AI6eyYr/UdIJN9P4TrMddw/wo0AofryrnTNa8SP0Cu1dHkZIoC0RP8w ctaBGADjWmKJPz5pRxDl8kXK5zOS8CTjKfPtPLAbONBQIv+hSFeuc88KZ49pn8tGn6C/ hVGRFNrvVcHqUGeOz6tcHkx69ycpl8HBNhoZYGNrCSIFzz2h3ksKQepD74eH04iNUy9R ewMueU7+0BL+LoxE98tG+eTHhCUCERkNTr5cgzJiJyDXboi/u6bpCTu+u4kAMHzSxITO nCpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=t/+HHt1c39G7ywBZBGDd9qnAziedqgoDMlKoB6IGpeA=; b=aBENrAsmaqSAz3g/soIAzp4d0SWVzX4oSaFaEj081c96mbvJD8o8Vzd5GFfy2v42xL kLBa+9qHLjrFxeg7LtoR7Y0xU1dvtcU0HC7cQOPCNHXfd9+2le2DcivZK8s50o+GVjd5 LlaQvKRMxUpFeR2GHzPRgFrZodpG63Y5cQf9Q5ih567R69a3moPsQk8+/xFFNMy+2IdY 6HLxX5W/8JLS0jt6V8GQIPeDdl9phqsN/5fVzZksiZ8ThO/b538vuwlU9Bv/pe2g5mus lEanxG/YCpa1roUK/0DeMhGyn3UMHGElVEbgM6SmNeereVPmyl/FYGFRxUasPSc40LyH 265g== X-Gm-Message-State: AOAM532k6meMN1OpfDOHTec9w6Q2F82D9xGhueizOeXHrEPIBg0NybZj z2r5DAX1HvYGjB2i/xbBzN27Q5RH8F0sGWm9JKXjjg== X-Received: by 2002:adf:e108:0:b0:1ef:97ad:5372 with SMTP id t8-20020adfe108000000b001ef97ad5372mr7705296wrz.658.1647014025860; Fri, 11 Mar 2022 07:53:45 -0800 (PST) MIME-Version: 1.0 References: <20220113091056.1297982-1-james.clark@arm.com> <20220113091056.1297982-3-james.clark@arm.com> <50e5ff63-ae00-f04b-fc5b-f294742cb13a@arm.com> <292386ee-cfa8-d849-57ce-156c76680e12@arm.com> In-Reply-To: <292386ee-cfa8-d849-57ce-156c76680e12@arm.com> From: Mike Leach Date: Fri, 11 Mar 2022 15:53:41 +0000 Message-ID: Subject: Re: [PATCH v2 2/6] coresight: Fail to open with return stacks if they are unavailable To: James Clark Cc: Suzuki K Poulose , mathieu.poirier@linaro.org, coresight@lists.linaro.org, leo.yan@linaro.com, Leo Yan , John Garry , Will Deacon , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, 11 Mar 2022 at 14:52, James Clark wrote: > > > > On 28/01/2022 11:24, Suzuki K Poulose wrote: > > Hi James > > > > On 13/01/2022 09:10, James Clark wrote: > >> Maintain consistency with the other options by failing to open when they > >> aren't supported. For example ETM_OPT_TS, ETM_OPT_CTXTID2 and the newly > >> added ETM_OPT_BRANCH_BROADCAST all return with -EINVAL if they are > >> requested but not supported by hardware. > > > > Looking at this again (with similar comment to the Branch Broadcast), > > won't it disable using retstack on all CPUs, even when some of them > > support it ? > > > > i.e., CPU0 - supports retstack, CPU1 - doesn't > > > > A perf run with retstack will fail, as CPU1 doesn't support it (even > > though we advertise it, unconditionally). > > > > So, if we ignore the failure, this would still allow CPU0 to use > > the feature and as long as the OpenCSD is able to decode the trace > > we should ignore the failure ? > > > > I think we may also need to tune the etm4x_enable_hw() to skip > > updating the TRCCONFIGR with features not supported by the ETM > > > > Hi Suzuki, > > I'm picking up this branch broadcast change again after the haitus. > > For this point, do you think it would be worth distinguishing between "no > known CPUs that support the feature" vs "not currently running on a > CPU that supports it but there are others that do"? > > Also would we want to distinguish between per-CPU or per-process events? > For the former it actually is possible to fail to open because all of > the information is known. > > I'm just thinking of the case where someone asks for a load of flags > and thinks that they're getting them but get no feedback that they won't. > But I understand having some complicated solution like I'm suggesting > might be even more surprising to users. > > Maybe the cleanest solution is to ask users to supply a config that > can work on anywhere the event could possibly be scheduled. It doesn't > really make sense to have retstack on a per-process event on big-little > and then getting half of one type of data and half of another. It would > make more sense to fail to open in that case and they have the choice of > either doing per-CPU events or disabling retstacks altogether. > return stack has no effect on the decoder output whatsoever. The only effect is to reduce the amount of traced addresses at the input (leaving more space for other trace), so it is irrelevant if CPU0 supports it but CPU1 doesn't. sequence: BL r0 (return stack is used only on link instructions) ... RET will output trace:- ATOM E (BL r0) ... ADDR_ELEM ATOM E (RET) for no return stack, ATOM E (BL r0) ... ATOM E (RET) fior return stack. In both cases the decoder will push the address after BL r0 onto its return stack. In the first case the decoder will use the supplied address, in the second will pop the top of its return stack. The decode output in both cases will be "branched to r0, ran code, returned via link register" The outcome is identical for the client. So the case for not tracing on a core that does not have return stack if specified is weak. Perhaps a warning will be sufficient? Mike > This seems like a similar problem to the issue causing the Coresight self > test failure where a certain sink was picked that couldn't be reached and > the test failed. > > In that case the change we made doesn't quite match up to my suggestion here: > > * Per-cpu but an unreachable sink -> fail > * Per-process and potentially reachable sink in the future -> pass > > Maybe it would have been better to say that the sink always has to be > reachable otherwise is the outcome predicatable? > > James > > > Suzuki > > > > > >> > >> The consequence of not doing this is that the user may not be > >> aware that they are not enabling the feature as it is silently disabled. > >> > >> Signed-off-by: James Clark > >> --- > >> drivers/hwtracing/coresight/coresight-etm4x-core.c | 13 +++++++++---- > >> 1 file changed, 9 insertions(+), 4 deletions(-) > >> > >> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > >> index 04669ecc0efa..a93c1a5fe045 100644 > >> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > >> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > >> @@ -674,10 +674,15 @@ static int etm4_parse_event_config(struct coresight_device *csdev, > >> } > >> /* return stack - enable if selected and supported */ > >> - if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack) > >> - /* bit[12], Return stack enable bit */ > >> - config->cfg |= BIT(12); > >> - > >> + if (attr->config & BIT(ETM_OPT_RETSTK)) { > >> + if (!drvdata->retstack) { > >> + ret = -EINVAL; > >> + goto out; > >> + } else { > >> + /* bit[12], Return stack enable bit */ > >> + config->cfg |= BIT(12); > >> + } > >> + } > >> /* > >> * Set any selected configuration and preset. > >> * > > -- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK