From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7CE81DED42 for ; Tue, 28 Jul 2026 15:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785250863; cv=none; b=Ir1OTUwplQaZiTrIaj5pnr8frSogWgNVa8YxQa5h1IBmlkZcVQZoIsrBKdODt9cfhh6IDyp4MCpOXYr2EdjZOVc3hafknz0rgWfMW3qeh0PUECSZd3p+XTEvD1PasKQMS4Sm0LQSSyGo/0jOM+uRc/jqfgjvmXXXgOIXR+aWL+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785250863; c=relaxed/simple; bh=Hfef0AHR1iFX6BvO7xZe6KNvyDg7wHn7IVC92N0DWDY=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=QH6liTgEE72bGkGYHUQsSz1DsLv6Q+aO8bXc5/ytiT1kdHmWOjKPQLXeOrMePwA/mFdMvtk/qVP8jXID5kCWNVGgIas6L7nBzMAvoMKRTLESHvGP2kooGCKwyUR8ch3v2p+ZBkOM3R8062NZ1H35WH1PIyQzUNbtAPIIgi4Eztg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=xjfNXiVe; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xjfNXiVe" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-47db714766aso667316f8f.0 for ; Tue, 28 Jul 2026 08:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1785250860; x=1785855660; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=qWoF0fB5PNOKYnD+A4X5y/pBZZyCEll/MQB77HbZLNU=; b=xjfNXiVe5m1ddTF6/I3r7ckg5nO9LqyG4BTCCUD/u5vop/v1RWa4WpU6Gv8MSwP6Qo 9yxE8FUKDc68sCZeJ6cnQ0+1xmnVYMRNjFK61KH2XBaAva3gB8aKEDXZWGTkLHtGtvtb h7hZ7iz3cPjxZWdMKht2z0wFuXzm1Tmd6R5zsCoJOmemtmElo7BJBGobcJ+oms3Ahum1 v0lay3jGqXtYUWtYxI4jlhn/p0mZd4WEdE/gMBUIzHClZy+WCrOUCpfLOD6OKIoBKlyt cWxunkQ0OKrRa8MsowboYI1YZhA1o+rV5T7LrUh4tOXMLcko5zQ3iPqOiAz7BwYyPtMx LxCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785250860; x=1785855660; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=qWoF0fB5PNOKYnD+A4X5y/pBZZyCEll/MQB77HbZLNU=; b=A+PmI5hYAwmatBKeBOQCbEzPqQ8A4fCTqmXw3jawwqkqZmnPQF4TwIT1vwc+xrdZ61 xsYxWsiKkGficPX4sUcHmWmuOA81ZaHS31/fwxbESJs+5xceSSvxm+37RcCGfQP49tf2 JKRpI0tL6BMUOZttYU+kgbrOAsIaCuCTEn164NGdDGpnfEESHNEJLkChbKaLK4uE+6tZ YmRm0lMSQEDQ6/ETPoSJU1DdmsTAL/W40PIjHXEBKpQ252jyDkwDS1k7rM0lrUDw3Qcq LDt93RC0zQPxizAoD2/N4kY3+U3aS8Hnn0+O2lBExZjelv8TrSr3+hUc/JpnxmU4p5/s YwhQ== X-Forwarded-Encrypted: i=1; AHgh+RqpS1h0O+wEDtOxAHY72BL6TZAtoaC9NlECxuNnlpUKim8eVAtmPKDoP9u2sCC3bbe/N5CtTpdwF4a12ao=@vger.kernel.org X-Gm-Message-State: AOJu0YxO9mFG+G2YzZpcJyOWzZJAhL/qxpmc0MC75NXcNLOfdtYtZbgt Pn8WRdo0naelArq2DAozeHGViQFBPcj6oGlmDOFYH+Z3kfLyg+wBEzEwn28j+YKCFk0= X-Gm-Gg: AR+sD10oC26plgqPmXEF3lawLeTkNDcz9QeRcj2h04stmQBD9snrD/0F7XFtQe8CIpU zfMv1qHaQJzN/RdJ05p6chH7CT1w00fneHt11lf8YoYyIl+5EHMAUZW9LF46K1j0eWBtAjxf5wq rs/HtZHMk0dlxgHMv1TMzb+tskw8/JlhehksfRkjDxG8hZ+tJ1wbH8Vuo7p61k84HSPiPJpxzJn 9xGF/WnP25Ly8ianfGbPzj3xKRClfIj0OB15QNcaHVvlENqZ80HBsoGGGIP8S6rDIVIGAZ7tJZS YjZaIuLJhbX5noTtu9RZY0dA1PhKP50uln4+DO69GxTJvELR3IjALGmD1h162GO24i5TCFcGCnA BgUZhLA+HBkgqrrRK61Cu1l4po1kWgJaNfjcVW5Cbz5P3jMpbjoUqIcVtQF+5BYOgoz4pHPyCxC OmSTtmbkU= X-Received: by 2002:a05:6000:2212:b0:46b:70db:2113 with SMTP id ffacd0b85a97d-47fb1e1d7f5mr3445185f8f.0.1785250860087; Tue, 28 Jul 2026 08:01:00 -0700 (PDT) Received: from [192.168.1.3] ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85c52fa9sm61036324f8f.20.2026.07.28.08.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2026 08:00:59 -0700 (PDT) From: James Clark Subject: [PATCH v3 0/8] coresight: Prevent per-thread events from sharing a sink Date: Tue, 28 Jul 2026 16:00:12 +0100 Message-Id: <20260728-james-cs-multiple-per-threads-v3-0-6aee7579f1dc@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAP3DaGoC/5XNsQ6CMBDG8VchnT3TFqTo5HsYh9oeUAOUXLHRE N7dQuLgZFwu+d/w+2YWkBwGdspmRhhdcH5Ike8yZlo9NAjOpmaSy5IrXsFd9xjABOgf3eTGDmF Egqkl1DYAWmHlIV2VFywZI2Htnpt/uaZuXZg8vba5KNbvRz7+kKMADjavCixtoZQ2584NmvzeU 8NWOsq/OJk4wbVJUqlrfvvilmV5A+BnR8oaAQAA To: Suzuki K Poulose , Mike Leach , Leo Yan , Suyash Mahar , Yeoreum Yun Cc: Greg Kroah-Hartman , Qi Liu , Junhao He , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, James Clark , Jonathan Cameron , sashiko-bot X-Mailer: b4 0.14.0 Concurrent per-thread events results in a WARN on N1SDP which leads to the realization that per-thread events shouldn't have been sharing sinks in the first place. This slips through because different per-thread events will have the same PID if owned by the same process, and we only check the PID and nothing else. That results in unexpected WARNs because it looks like we assumed it couldn't happen (although exclusive PMU rules allow it). But even if it was supported it would result in trace from the wrong thread in another event's per-thread buffer, so we should disallow it. Fix it everywhere the same PID checking logic was copy pasted. Then the PIDs can be dropped from a few structs as they are now unused. Signed-off-by: James Clark --- Changes in v3: - Storing and accessing event owners at runtime causes problems due to various scenarios of: events (and sibling events) exiting, children inheriting event FDs, PID reuse, CPU affine events that also have a target process set but different inherit settings. Fix it by creating a session ID in etm_setup_aux() and holding the references in it for the duration of the whole session. (Leo) - Make the ETR buffer allocator consistent with sink sharing rules by not doing numeric PID comparisons there either. - Fix up some Sashiko reports that it sees after interacting with cscfg and taking extra references to tasks and PIDs. - Link to v2: https://lore.kernel.org/r/20260709-james-cs-multiple-per-threads-v2-0-10ac7ac6af0b@linaro.org Changes in v2: - Fix inherited events by following event->parent - Link to v1: https://lore.kernel.org/r/20260709-james-cs-multiple-per-threads-v1-0-d384e6d477ac@linaro.org --- James Clark (8): coresight: tmc-etr: Don't stop Perf cleanup for active sysfs reads coresight: configfs: Don't assume active until cscfg_mgr is set coresight: etm-perf: Flush workqueue before unloading module coresight: tmc-etr: Prevent per-thread events from sharing a sink coresight: tmc-etr: Use session ID for buffer ownership coresight: tmc-etf: Prevent per-thread events from sharing a sink coresight: etb10: Prevent per-thread events from sharing a sink coresight: ultrasoc-smb: Prevent per-thread events from sharing a sink drivers/hwtracing/coresight/coresight-core.c | 28 +-- drivers/hwtracing/coresight/coresight-etb10.c | 33 ++-- drivers/hwtracing/coresight/coresight-etm-perf.c | 79 ++++++++- drivers/hwtracing/coresight/coresight-etm-perf.h | 15 ++ drivers/hwtracing/coresight/coresight-priv.h | 2 - drivers/hwtracing/coresight/coresight-syscfg.c | 6 +- drivers/hwtracing/coresight/coresight-tmc-core.c | 6 +- drivers/hwtracing/coresight/coresight-tmc-etf.c | 44 ++--- drivers/hwtracing/coresight/coresight-tmc-etr.c | 207 +++++++++++++---------- drivers/hwtracing/coresight/coresight-tmc.h | 30 ++-- drivers/hwtracing/coresight/coresight-trbe.c | 3 +- drivers/hwtracing/coresight/ultrasoc-smb.c | 25 +-- drivers/hwtracing/coresight/ultrasoc-smb.h | 6 +- include/linux/coresight.h | 5 +- 14 files changed, 294 insertions(+), 195 deletions(-) --- base-commit: 98495b5a4d77dd22e106f462b76e1093a55b29a7 change-id: 20260708-james-cs-multiple-per-threads-ed1d25ed1734 Best regards, -- James Clark