Received: by 2002:a05:7208:c24f:b0:81:d631:dc8 with SMTP id w15csp408029rbd; Thu, 4 Apr 2024 12:58:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzVyQwWjd193nP/O3zyk5sGUSpVGfP+/8ZYDiHRF2NmHuVtkzBfHWyC134WsnjA8yiaivYAUMaKOdw/oVbD4/eu8Y5Z8+Jk3NPgmI6Tg== X-Google-Smtp-Source: AGHT+IFFXNY/NFhZErHoKe82D74J05h7nKLXN31eZKsoBAqKz9XdFQqLwDYi0TTQ9oF/8iFwOMof X-Received: by 2002:a05:6359:4ca8:b0:183:ddd4:6d63 with SMTP id kk40-20020a0563594ca800b00183ddd46d63mr3939966rwc.4.1712260711202; Thu, 04 Apr 2024 12:58:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712260711; cv=pass; d=google.com; s=arc-20160816; b=TRq6sfR8oQrp+hcdNgrcD5h/OO7XWTVF+cGY6+3Qqftg9WQuyZmSrPo5kBd4+aO/+C BEP8slismoIGsjy9aJeG5A2UXXMa/oJcsKTStnrb9CwRXEdJJ/AljeC70f9ZTLSZixVc y6nPEVP3UCnGKcNciA7kpEXBGhTw1D+yNcGypYjjuq9z6lITscIUCDpjMA0Ify9GkNzP ItZ8LDKNLyozUFOmavNj3smTHo4fQxOHU2DqzXI0kR9UWlEVl/eSwhUdHDqMJgJ6QDBD nKUwo/DjhhDK5WZLoNYD97lZyvAj64WcFzLZMeTggjHwfn9y4+Pjh2oJzU4YNrTwj4J8 YE6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=2lgKxpRtMWH0iH+ihkZown4poVg4tjlTUOWpwf4cYhs=; fh=4ha5oXAnQ4XUsEzIuR4l4rXHcprwRUXRHyRpRR4WBSc=; b=NvgtpYXyaCbYPKgCC6BbgC4iEkYQhuyHb0kL6c2U/mNuV7NrWUqQurqfi4y4vlBrUY Z88I9UVllz3BU6DsScY6FLVLw9S3dzHHmbRGTpJGjpLT+iwUDdoiPknnQu/dccBNQYMR KGuKRWRtamERk0qLgavid2/llot2vy6BDYAH0m2VdzzpX/xVtEWtZGeyaJmCvM0sREMw zYaUTPyKGW3oeiK1hGfwequOPCdFE12qEkOB0lzRUkCyVAebfEWTNOg5roO1QKCLxBYR Qf2umbt3zSYQGZ6r8QTfivqyRctW+j3XG6YvBqXJ8HxAzTSOJfbsdtaaUxv+gHGo1i2r +SmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=eo4MnR9z; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-132032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132032-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q16-20020a632a10000000b005dc41265c15si43197pgq.658.2024.04.04.12.58.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 12:58:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=eo4MnR9z; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-132032-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132032-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com 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 5CD47B29B21 for ; Thu, 4 Apr 2024 19:27:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95CD6134434; Thu, 4 Apr 2024 19:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="eo4MnR9z" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86CBF15EA6; Thu, 4 Apr 2024 19:26:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712258808; cv=none; b=cJuSjmo1kDTs4M7OQkErn3U6IODHiU0P2vFPJ8Fdb53BW96uiPiLR4wcSB7tKYOg0ws3sDnrrr5Mvj38lxQeKtEUTE4pqCP2MUG9UH1epoiS/mM6xpYenW+o1jBtumcCdMH9R3fu8QkuaH+MqdMAwHnvxnkq7fg5K2bucI2hb7M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712258808; c=relaxed/simple; bh=2lgKxpRtMWH0iH+ihkZown4poVg4tjlTUOWpwf4cYhs=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=LmwNI1H3pbzrjobvvQaMpzXEpIdd1/FY/412mXx6khsyfD4ueE996yZPlEELkBg7U06VzTtrR6qo0TOQZhY5IgUpgeSf7iARO3BSVtrygn4c5XA6eis7ofU/YsuL40XrQH8/tW8bObvpPpTlK9dAiWay5frQw2Ltj+gjsFwinds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=eo4MnR9z; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from DESKTOP-4OLSCEK. (c-76-135-27-212.hsd1.wa.comcast.net [76.135.27.212]) by linux.microsoft.com (Postfix) with ESMTPSA id 2B9A820E94A7; Thu, 4 Apr 2024 12:26:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2B9A820E94A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712258807; bh=2lgKxpRtMWH0iH+ihkZown4poVg4tjlTUOWpwf4cYhs=; h=Date:From:To:Cc:Subject:From; b=eo4MnR9zzdAhZBzh1Wo5USgTxP8M+99fhIzMom79fgPkqfOxqqF/ocFwlO0d6p/pa IhtAjk5ikMLuE8uOJCGUtzdsq4ffPf+F2jhW0xpqLFN7Ng0fYS/ok0/UbYcAERZlU0 dIYNJAFl3IMPzLteo+HzKmT5kKuhWZ5UaQgZi+3g= Date: Thu, 4 Apr 2024 12:26:41 -0700 From: Beau Belgrave To: Namhyung Kim , Masami Hiramatsu Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Copying TLS/user register data per perf-sample? Message-ID: <20240404192641.GA2628-beaub@linux.microsoft.com> 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=us-ascii Content-Disposition: inline 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. Thanks, -Beau 1. https://opentelemetry.io/blog/2024/profiling/ 2. https://www.elastic.co/blog/continuous-profiling-distributed-tracing-correlation