From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796334754; b=TivjiCfzKwq8+0kb/+V0ocV+1Rcwvx8j8wmsa40zfRtpsUGGxXQm28OFiwYsk+h2/RIb yWpTF4SN1yWjI3ifiXtPHrxNAAqCzZJBfWgaoXWlCmib+w3mGtBEgFkxVRumAkfwqaKGA p0Zh7edYr8B0CSc4mU3ro6KAwm7DqYwY9fb55tMaokvp16p7ZmZByJbTUQJ9b1GmFjK5Q xaia/rpG3ArkkwBviuy4/JV7G+jv/W01Z2XkkUB8h3RyTc47pY6+vtkM7mq4X32pDWLY8 u63fNLBAqYmBdxt+yOEqAFOGyNDaJTbXYb3/5Fk0WqzxjFpptwwPTIbavC5wsUcEw2Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796334754; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=PpEfHScA6HL4AjcTvy+NgjWUqmpnuU1rIeMEIjscWyk=; b=Vk3cAey9Imn+lbWdBDKmDYKctBfuF3RGozL5vqpLCG5QkYWE42SlUR176EOsvP1PU63l DH60RL/HNnWOwLn20f12tFsw5xyyjrAIfUYiOnCXam4bvYZ3UaizJV1bzzlT7teKhSsCo Jt+UUeYgx3BNPWBgwKXY4ff34m7givQ+xQUOzfVUJDL+dnMvVGZrCHbH6ZEyslILhv6Ne d/9gVQqWYN9Hhyo5TOaUU44fN2U0OOSqH+WUgv2oAZ2gEkvc2flfFicrYKv9TMx3vkO+j MDTckmrQSW6482OY886XMWUpNOmMUyxgkjJAF1MScDr6QBhiTj+YI/o4Cfe9zCUdFdQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=RPMTkFnb; arc=none smtp.remote-ip=209.85.210.69 Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8834C606A690 for ; Thu, 3 Dec 2026 21:52:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8834C606A690 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=RPMTkFnb Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-8520e83f715so408098a34.2 for ; Thu, 03 Dec 2026 13:52:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796334753; x=1796939553; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PpEfHScA6HL4AjcTvy+NgjWUqmpnuU1rIeMEIjscWyk=; b=RPMTkFnbXpSBg7Rx1gy3m5QgC/g+K9Zdk/bKywByCUo1b10BGGUv6tRORK3nSU/riu 6VwzJmGqcVM5gDCcpO57XZTFyKxnQ+JSqQRvYXkfAHKjmPgTVVSopfCAG2wn/lgpz/mU tZRm0A6w9x8L5HP7x/qChNZYQua2D856vFqru4O2Q1pm2oeskplg0kMyTVLD3SLwp9w0 zxJ+LlCa69+ISlVmsHws+kUVfPRPt+JawCrp+Aspo8ICQFTl7d6sTziqFEpVliETwlue c+2i7+94n/UxSlcVlV5ea4T9MYgrmJRFaizgnE0yErIA+wnKYbSeBbyNlYRmSzm0WSne g/Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796334753; x=1796939553; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PpEfHScA6HL4AjcTvy+NgjWUqmpnuU1rIeMEIjscWyk=; b=17zWNRbiMPi9aR1j5PaO1FgDPv2Av2QWOTggdnGh+7PiOVpYH5yk3cgGQzFeEcjEwy W/hWw+ngnyDmGxfe/epF5BGhMNI2DJZrA/jOQH1sgKuahaL1upE5NAhbrLXDUUls3r7Y AE0g7UPynou3ZSkL306E/7qxEOixjVjR/POXf+PqcF5V60jnK/6QSmHSKcshG0OU9QMZ uIplzwpcKJH6UAtPd2CRXNCbi5Yfa4n9qd2ktEbs7Hnkw3RY1XpIOsI1OE/QwuqM1ERE 7ZR90kpKiV6Ahyf8DRHbcPcpY6Jk3JHEfI9/jmbFDsp2BOcwVvZH98tjxP43H5F0NDS1 q66A== X-Forwarded-Encrypted: i=1; AL+hErFMfDS6jZLsF3TUMfRK80EiF8P+QeupfSDlo6yp/15XKVQ+vON1mA0j2FVYSyVPTWvexvpRpZa9SClaC9Y=@vger.kernel.org X-Gm-Message-State: APuU4Z9v8SR/1ROpGuANuAi5+6XMfeo2qy5T/OnQpjAtq4EydIrCxPpJ yth3GlZM9iZVSEAFFEXLXZaTafdhtFeRU6BsmCF9lF3r2NWGqiMh6VFCgMQZ/FK5lVZaSFi2sfC g0u29pdrJkw== X-Received: from oojq5.prod.google.com ([2002:a4a:ec45:0:b0:71b:1b35:a5a8]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:a00a:b0:71a:fa06:4dd7 with SMTP id 006d021491bc7-71b39448c4emr29937798eaf.28.1796334753234; Thu, 03 Dec 2026 13:52:33 -0800 (PST) Date: Thu, 3 Dec 2026 13:52:11 -0800 In-Reply-To: <20261203215222.1392035-1-irogers@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261203215222.1392035-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261203215222.1392035-3-irogers@google.com> Subject: [PATCH v2 02/13] perf off-cpu: Fix swapped PID and TID in direct off_cpu_dump() samples From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark Cc: Athira Rajeev , TAKANO Mitsuhiro , Hang Zhengyang , Howard Chu , Thomas Falcon , Song Liu , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" __set_offcpu_sample() unpacks the first u64 of an off-cpu raw sample as p32[0] = data->pid (process TGID) and p32[1] = data->tid (thread PID), matching off_cpu_write() which packs (u64)key.pid << 32 | key.tgid on little-endian hosts (and kernel BPF matches host endianness). However, off_cpu_dump() packed (u64)key->tgid << 32 | key->pid, swapping PID and TID for multi-threaded direct off-cpu samples exceeding the threshold. Pack (u64)key->pid << 32 | key->tgid to match off_cpu_write() and __set_offcpu_sample(). Fixes: d6948f2af24e ("perf record --off-cpu: Dump off-cpu samples in BPF") Signed-off-by: Ian Rogers --- tools/perf/util/bpf_skel/off_cpu.bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/bpf_skel/off_cpu.bpf.c b/tools/perf/util/bpf_skel/off_cpu.bpf.c index 72763bb8d1de..eeb2cb8ac0d8 100644 --- a/tools/perf/util/bpf_skel/off_cpu.bpf.c +++ b/tools/perf/util/bpf_skel/off_cpu.bpf.c @@ -236,7 +236,7 @@ static int off_cpu_dump(void *ctx, struct offcpu_data *data, struct offcpu_key * { int n = 0, len = 0; - data->array[n++] = (u64)key->tgid << 32 | key->pid; + data->array[n++] = (u64)key->pid << 32 | key->tgid; data->array[n++] = delta; /* data->array[n] is callchain->nr (updated later) */ -- 2.56.1.915.g69d5ec7298-goog