Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp105670lqe; Tue, 9 Apr 2024 16:33:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU0Bj3Fer2Vkrd68eA7l+JxlDmUH7hS17M4HALdd7wH1fEuOWGUO5F7fITCJxfV3lHRDO7gOdwOAorCDR/XxSoiPgPooTSpyHMnVT29yQ== X-Google-Smtp-Source: AGHT+IGKwVWorKpps3NemyQN51YUyQgrT3HWNuG3FWc/BZV/W115jZtnRYKh6pKtjLNHRaOMLd+7 X-Received: by 2002:a05:6870:961f:b0:21f:1705:d5b0 with SMTP id d31-20020a056870961f00b0021f1705d5b0mr1210389oaq.52.1712705591375; Tue, 09 Apr 2024 16:33:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712705591; cv=pass; d=google.com; s=arc-20160816; b=euccPyoF7E5butsAoioNikcOLcBcZ5LjaPyvw8PuPp7UvXyYQ7BPOEOcuWSAlXRQ9H HJE0XKm2zViohQ5sIT5LdHNDkirwHTTrqnrYDVZQb+5dVbjYz1fE/BvLroiZ3nalj/aF sckjj1f201MsAjiAO6o++4MJf3Yzn7iZ7QVNs5PYLeFQdAq/cN3a/0bV4eMP185YU6lU 4pqqJYbKIJXtBFrLSF0KpIgwP2bsTn0LEdZeH2ypcL79bx3h9plRFv3cFNfWs2KQ2Lqb CS8zQSCzUyCDeL+YKuP8HC+ksbz9toEnkoPMzkn7mp5TVcAL79EK0EoRqfxcm7j3M0Yv goOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=txAzNccQpB/N8Q5x5o8g15P5MWmrHzoG0VO7jB4WhWM=; fh=GP8T5Xg3x4Ch7y1BpjtPYByWgNixxWh4aZ7QjiWLrGc=; b=owye0vvbW7UdnYzO8ZSjs+aOFD8GYNyvD9NPcI68PNSTv2RcTYc6D7JhXrv93jkCWc 58nsQb7bOZeiu88KKM28fxG0A1Yh8cHjyESLfavC+HqCHyNly4pZBzTCHkSKdFv3PGho LSE/LT45eeIbTmAgn4Ji854bAi5hnmxWHnPSSjhYLi15SZGzHPgZ+lVWYMez9X4XCKUk Co6B10aUz6a1hal9GgqH/pDSjHh80T+Xj53qvcn2PLs/0S42ylMal5ug5o8NJFqwqxy8 SY3htBCN4S8KH6ZGMpzDNxBHuw099UMho5huUR6B8XHseeWHh76LDJCbuxyUmwCwndGJ g+KA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-137694-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l7-20020a633e07000000b005dcbb9cf3a4si9550462pga.129.2024.04.09.16.33.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 16:33:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137694-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-137694-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137694-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3CA4DB21771 for ; Tue, 9 Apr 2024 23:33:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B14B158DC8; Tue, 9 Apr 2024 23:33:01 +0000 (UTC) Received: from mail-vk1-f179.google.com (mail-vk1-f179.google.com [209.85.221.179]) (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 89E6E158DB6; Tue, 9 Apr 2024 23:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712705581; cv=none; b=e3fk3fS5Hbmnu3VkvjHoRcO0OmuWsnyUwdbnlkUnup6MlllBriVouKfwLvsdSkNeKJZt3Eg3wlBqwVYS+zkMMdL52YrYLVOjvMjGfQ08tELrh03D086flM/GsZL2T+rmX6w66MTE3qEOnRFxwefBgkJ6QqAhK0gf/N5sJEky2U8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712705581; c=relaxed/simple; bh=txAzNccQpB/N8Q5x5o8g15P5MWmrHzoG0VO7jB4WhWM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XwRNMiCl3+L9uawtH9P1RKandV+HajJi63FFOyeKsHIblhupfsNVdM3Y16YyvuXhpv6zZYE+gzVfg4hymedPKWH7PbET6wE7g6ms6UH5m8a4vhpecZhoHnIe1zCNfXorVtqVzCdiIK5oxmIq/oRVljlrjZ5syZe/f2Sp0c08T6g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f179.google.com with SMTP id 71dfb90a1353d-4dac19aa9b5so1296630e0c.2; Tue, 09 Apr 2024 16:32:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712705578; x=1713310378; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=txAzNccQpB/N8Q5x5o8g15P5MWmrHzoG0VO7jB4WhWM=; b=sxmFAROBFI9ngDOxs34O/tR+54uA9FoVZvxDv3Tj3JcKiTCzhILQFm8zOed8QOYP/m Dv63gmTDlsQ90glWckZxLSFri+T3Mmn5ALw5sFJdptiFJYF6IXpH3uAdJQ8x4xF7S4+1 9DKGTfA5m7TBpSRf2+CVFY4ywEKnU7oK2Oz5shW0ItJYT/YbL6agmsWqJZtVdCc9PkdC OS7C5Mzj2zmh2q1N0aC1O5sPZJNdw5xjipDY2JJWlyfjNQHQXCwyLZHjUR2J7JxUEuXV QrQbPZNRuVec/+QC3g18IB/Ba3I/AY+p2X2ms2wRQ/TAxSYH9UKvoJjY18BoQRXzSLmB xl7A== X-Forwarded-Encrypted: i=1; AJvYcCV22xN44uUAQZhEng6GIb/S9XYtzDZV3FXMLdSI9QPzzMWFTPpMrv7ikK7kM57PxEHr7jmamBVseZuas1afVRi8tWSKhpBEQAekGIwxglEmmRSfqHccV4N6ZfjNP+EZabld4F706yYgbtq35FOH5L/V X-Gm-Message-State: AOJu0Yzh24ZpWvN3vQHetdvKQdETowZn8+9Gd35wl6qITMezrK0jbXoM YNuBMFRJlP1NjDgvieB3kmGayxiUIG50OX7J65aN9qjX8YTpgkqEf4Og8SUOl0kgLryJLWsU9Ih RrQIrvUz/SpsJ14JOtTJnwuFLeb0= X-Received: by 2002:a05:6122:901:b0:4d4:2398:51a2 with SMTP id j1-20020a056122090100b004d4239851a2mr1433844vka.8.1712705578423; Tue, 09 Apr 2024 16:32:58 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240404192641.GA2628-beaub@linux.microsoft.com> In-Reply-To: <20240404192641.GA2628-beaub@linux.microsoft.com> From: Namhyung Kim Date: Tue, 9 Apr 2024 16:32:46 -0700 Message-ID: Subject: Re: Copying TLS/user register data per perf-sample? To: Beau Belgrave Cc: Masami Hiramatsu , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, On Thu, Apr 4, 2024 at 12:26=E2=80=AFPM Beau Belgrave wrote: > > Hello, > > I'm looking into the possibility of capturing user data that is pointed > to by a user register (IE: fs/gs for TLS on x86/64) for each sample via > perf_events. > > I was hoping to find a way to do this similar to PERF_SAMPLE_STACK_USER. > I think it could even use roughly the same ABI in the perf ring buffer. > Or it may be possible by some kprobe linked to the perf sample function. > > This would allow a profiler to collect TLS (or other values) on x64. In > the Open Telemetry profiling SIG [1], we are trying to find a fast way > to grab a tracing association quickly on a per-thread basis. The team > at Elastic has a bespoke way to do this [2], however, I'd like to see a > more general way to achieve this. The folks I've been talking with seem > open to the idea of just having a TLS value for this we could capture > upon each sample. We could then just state, Open Telemetry SDKs should > have a TLS value for span correlation. However, we need a way to sample > the TLS value(s) when a sampling event is generated. > > Is this already possible via some other means? It'd be great to be able > to do this directly at the perf_event sample via the ABI or a probe. I don't think the current perf ABI allows capturing %fs/%gs + offset. IIRC kprobes/uprobes don't have that too but I could be wrong. Thanks, Namhyung > > 1. https://opentelemetry.io/blog/2024/profiling/ > 2. https://www.elastic.co/blog/continuous-profiling-distributed-tracing-c= orrelation