From patchwork Fri Feb 4 15:24:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12735225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 375F8C433F5 for ; Fri, 4 Feb 2022 15:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3ZUSFNdxelrweEVtBTV3SrFaqmGpC6zjToSW9idBLFI=; b=LTgaZW0xeIKEMC t9yXZGq92oR1piIpCjsJ3hgwXStk5smgy1CjGv+nRx0yij5NP13OuZko9xejcMrUjrc5B/bMvvSmo XGdm9TywHnq8RqMkuuLehGF11AyWwz+rJD+LKJqWS571hs/QFTY6qBsjv73jVSysuytjYBRbteQIU cTiU0MBvcaWNtnf0Fk+j6Ow21xyBE6+yHOtQhVYkqbj1oWWVGyGVH3PnrNm/OX0oLcvKyfAgTcTO/ I40r0HJ7KUQu/RjENwWF1pzFu81J1ak1bIkLCugnnhVPMlGT7XkBAOrny336h4llLepOk223QQE4n 7oGH4xLU1d5LADZ00/jw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG0SV-004j1a-FO; Fri, 04 Feb 2022 15:25:11 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG0Rx-004ioz-Hc for linux-arm-kernel@lists.infradead.org; Fri, 04 Feb 2022 15:24:38 +0000 Received: by mail-pj1-x102d.google.com with SMTP id s2-20020a17090ad48200b001b501977b23so13410515pju.2 for ; Fri, 04 Feb 2022 07:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CP130Joo5LnzHA5fd0JPgyy8qzQq4QiMmlbo4WSc/bc=; b=L/e7pgEILiyjVuGqBatpNWgdA2j6VCihnfihFatdCHPNmoY4xviCPf/nQm5bMBlzQP amlIOx/kyvPnSQj3m3GWhXKXIOA+a/ixQAcJmr78Hq0YtpO6MTDE9lX1FHMNfagK3HZS XjSYynqpHruY90Hlo5PWLIx6f3OaLgcF+xp/gx70H19rIuwS8nNLlUni73WYe46gynsG GURGyJRD/1DK7xxK8+9xaFuK/UxXPHwEdbr7m0QPU4ZzfG6x2YUMobaPHbjmceMXl+o4 su3bKwuXugi2Zt041Hk8OVTR0IWnW6yhOqS7WJa0hv89TPcSkQUhXdwGspZn8M5cugwX kjXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CP130Joo5LnzHA5fd0JPgyy8qzQq4QiMmlbo4WSc/bc=; b=6UDqroYarednxiUixLt0fiQInWcfRUW9P3LHf+ahK8AJ5MxfB0smAqlbsl+3sKknlB 8q/q3/8ogpQMHJFE7NkuP5PC8v+kHPjT2DfDL84gHFvHe/jIor4u4ukLzIYfenHfDvYu rjdyjRBP+fIdX5DBw3gqN0lDL6rVOhGgIiu1BKu0qvPiqPnAmIeWV0Ul4sLNFu+pbOHi wBB6xYqKuzXh0tUABrSrBG/3J/pGbxZiM1CMsotPvNi2bW7GyYoY7LDR7O9+RlD0klxy UAby6azPFIktLMpaX/DZkno9KUQONplK7/pDulX/s5WKBr+t0nk4QLM6HV3pkKXcvj/Z SOoA== X-Gm-Message-State: AOAM532+xT61t5PX8fb9ISCE8L8yQUywBIGuKioDo4Zv7lZepG+lsAmE kKAYBkee2bQ2w59z7do8difBjA== X-Google-Smtp-Source: ABdhPJxbU+TPetYDwGr0juHAkGQdM/jc+JJ+Gtz12pEMdxQWIytSegOUq1HgGsra7H1qWC6d1uqoag== X-Received: by 2002:a17:902:ec81:: with SMTP id x1mr3384394plg.109.1643988276332; Fri, 04 Feb 2022 07:24:36 -0800 (PST) Received: from localhost.localdomain ([134.195.101.46]) by smtp.gmail.com with ESMTPSA id me4sm14237079pjb.26.2022.02.04.07.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 07:24:35 -0800 (PST) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 RESEND 4/4] coresight: etm3x: Don't trace PID for non-root PID namespace Date: Fri, 4 Feb 2022 23:24:03 +0800 Message-Id: <20220204152403.71775-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220204152403.71775-1-leo.yan@linaro.org> References: <20220204152403.71775-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220204_072437_616704_28A8AF7E X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ETMv3 driver enables PID tracing by directly using perf config from userspace, this means the tracer will capture PID packets from root namespace but the profiling session runs in non-root PID namespace. Finally, the recorded packets can mislead perf reporting with the mismatched PID values. This patch changes to only enable PID tracing for root PID namespace. Note, the hardware supports VMID tracing from ETMv3.5, but the driver never enables VMID trace, this patch doesn't handle VMID trace (bit 30 in ETMCR register) particularly. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm3x-core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c index cf64ce73a741..7d413ba8b823 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -340,6 +340,10 @@ static int etm_parse_event_config(struct etm_drvdata *drvdata, config->ctrl = attr->config; + /* Don't trace contextID when runs in non-root PID namespace */ + if (!task_is_in_init_pid_ns(current)) + config->ctrl &= ~ETMCR_CTXID_SIZE; + /* * Possible to have cores with PTM (supports ret stack) and ETM * (never has ret stack) on the same SoC. So if we have a request