From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793333044; b=B7Rb4NVDLsf8CorWnl+nxnCufHolBdEyCB7HfoI6LxdLfSJB7fwIp6zFhkMkk6AbYyon 7qQBcSgTGBI89z6bbLYI+fg7wl0nXE5w9TlzciUhJ3IeOOhPR5lb3GP/70AEEyNnvKUC6 IruOufXeAE02WYcD/dBmeUFUcbUFPllGDhQr/BHPMnB9cjp10vKME0AsxL4P4mEhyGqYY dhWudrHbvG12J2ZThOOFP2a2XytC49WiIOFnDHG/DY4icx6jkBM1XcVYDqBBCkAnxlgSM aCrU0U0yTeQMIjVP+BcHkR+HW0TdZvZzfdH/2gU+JZz3ZpSbNqQf3IaENXGx180g1Jg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793333044; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Subject:Date:Message-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=IGEY7xpKT7BuVDZ492nljPbapi/lh/U71wUYUhMFTsE=; b=d8Ywb015Nr5JPWQ0SMqD0lNrmuxAgfCyhV5F1bXWBmBYQfGUQzFRPUvnyK6NJnx3Pt7C EnEdQovGlCcB3pcFBC4+ZIqJFpy2tzs7lgV/ELVT8MjNVug2bXjFjo3oZmeKUjWIKrXD8 wWifp+ElaXnRM74XWqJE5soO7RzjbVPsEtsRP2s4/CRngrtEnZ/FklRwfnoSi6a6ffEXd 772ZMMAg9Pq1yjpZq8jakntkTW2lOCAXoBObmFIlRhxDECR/nPXMCWXCQrO325QNoug10 IBFc2Gt3mELJMAO/c/2a1A+J2ayuHkuJOKHpTlOcLrpjvyv3qRqwEH/bYq7ulWHBgnQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0CNwkmqf; arc=none smtp.remote-ip=209.85.128.177 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 916B0606A31C for ; Fri, 30 Oct 2026 04:04:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 916B0606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0CNwkmqf Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-8ad98c3fb15so2483047b3.2 for ; Thu, 29 Oct 2026 21:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793333042; x=1793937842; 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=IGEY7xpKT7BuVDZ492nljPbapi/lh/U71wUYUhMFTsE=; b=0CNwkmqfD5WwHRzoOUwCaJebj5k1i01Igxi+rSihQaLeqOZ2Fa0jivzSCjLpFY5X8D ObA3/sn4B9OFOxtT9KTKrJWU3WAiw3BkmMHjndMACeXMhfkKOwph77bbMtR3oKt5fc+f syizFJT2n9dLc3og9eeqmbj59Vjt60Yiu1LNMlSuX8cEDkr4wO04An4TsfgZhEH9Nh1+ S9WG8/TOeoFDmHeujzJAn1yvmEFJpOkWqjZ1Du3b64pcLqxmYNM92Lk/lrYZWR+gisMI 0ECE3Qg9BkEv69/3QbGNFr+pDDcxnZokKKkJH1ZbScmqJpCLk0JXdOdMtVBi6sSBCJ5m fHwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793333042; x=1793937842; 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=IGEY7xpKT7BuVDZ492nljPbapi/lh/U71wUYUhMFTsE=; b=0fsdemR6DvthukCyFmcVbAlq2r7ExMKS7vIVdrILFPfA+ZgO5V4Vbf1PMrZDd4DVvS iwabeUdKdzvgX623kTg6MFXmYMbvXimWAmBX6EcD9AGTHdvqW6JuuVCtnwHAM3JYp/jE 55tml1TOawY2jmN3XDk6idCRmAL3rhbgx17qSHg7SLKysOX7drI8PHKUA31sFrN6U6gK yQzabv1VmF3qiGbBHUBsdgO1CR411tvdrbRIFlbu1wW+EzJ3a2umyjUPADQqFZOpqDOv lijQ3VOV/vjFAzaS23qTrqBiUEn8Vbg6dp2bHwfS1z7VpA94KyCrQA7bGXZ8xvnMYIhu LQHQ== X-Forwarded-Encrypted: i=1; AKwUvBxFDNPFRqlOPpP8xeQ6ff7tzYrZSr+n4vBnlZ+QGm/NTHwzjwF0SryzK5SIkTyoy9pxOr8j1xq9XeBRme0=@vger.kernel.org X-Gm-Message-State: AFq9FYJG0RLFrzhTHTnhBJqFHfABF2wLom5Yp9IAp/Oq/YJVgwE+Ws9J jaD+tXAtxzPpTKJigrKVOxzEcnanz5Rq2bILWyYAIeapWhzRqpB8xRcK X-Gm-Gg: AYBFou398kH+WBSf3IC6uo3Sd5nrhiqKFqDypbBmS6v1MrmG1l9MpBMJaaz3l5PFa/6 4ky71T8KxJVdWIMkZUtrjS+VhsvHHYOyVulbpoMHQ6VntTTiy6na656LJAP6vmx/4Cc7MZv/Wti Zpc0kepnT7ZgMMGpBDuC9V5Dxb0AVt44zrGvwR7KNyM+I6LGgQlMzEXp+TVYTuJj7Zg1Xy+7qMH qm3gC4arNZIyWAJgNfL557trzPBneDAwlKqDBt/ONDbaeua8r8pVekmWmU4sYeUbSV2KWqa1uwS NOJp51gEAjF1hOIbB/y1+hERNe2FuyhpxB5SIE5hxjsQuh6Kes2DSmeljQuzhmJwzQFbLbRT2Pg dYC1UkxQ8tRedqC47C6BQoZAyEt/NODj3frdnMtlxqJv7ABy5KzvkZ3vtLGT7pQRhjOmForGbPq JnyRjCif1abt8z5ce0jG35OnbDb92K4iG1qprzMEfpeVpg7txJTWiuF0da0SIjvW18b96pezFuV ZkOIlajwj6efZR1RhcZqc/Wr0OwW4QBhTPzv4P332/RuObQioFc+3xom2TtEpWNaKYHtPBwPimr S0Osup/BLIOH6tCDFYCgzLdsbaJSv7CMTHiHKJXyLNBLpHCf4Uh7ElTfeQ3+vCpREo73tjM4sL4 ve0er10QirA== X-Received: by 2002:a05:690c:3481:b0:8b0:c71d:2b2b with SMTP id 00721157ae682-8b2b67a315bmr7858347b3.45.1793333042366; Thu, 29 Oct 2026 21:04:02 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71bce56sm3416527b3.44.2026.10.29.21.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2026 21:04:00 -0700 (PDT) From: Matt Turner Subject: [PATCH v2 0/5] alpha/perf: add ProfileMe sampling Date: Fri, 30 Oct 2026 00:03:58 -0400 Message-Id: <20261030-alpha-profileme-v2-0-c702f1c65272@gmail.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/2WNyw6CMBBFf4XM2prStDxc8R+GRVsGGAOUtEg0p P8uYFy5PMm5524Q0BMGuCUbeFwpkJt2EJcEbK+nDhk1O4PgIku5kEwPc6/Z7F1LA47IMiwLXea 5NUrCvpo9tvQ6i/f6y+FpHmiXI3MYPYXF+fd5uaaH96sXf/U1ZZw1UholTCsU51U3ahqu1o1Qx xg/bXSWr8AAAAA= X-Change-ID: 20261024-alpha-profileme-6e98a977cb54 To: Richard Henderson , Magnus Lindholm , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Matt Turner X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4916; i=mattst88@gmail.com; h=from:subject:message-id; bh=tIQ5QTNuAEPX68X7q36sDokkva1R0R1MN8RNpvCC9iM=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLKeiOsf1bBr033W+Lo34lh339Ww85O2TFuv9fkN8zeHC 7+E+5XSOj6yMIhxMcwUU2SJW6/IMqttx1Kf09K/YOawMoEMkRZpYAACFga+3MS8UiMdIz1TbUM9 QyBDxygeIqfHoJFZXFyaWqSbVlDkkJdfkliSmZ9XrJdfkJpXkF6gl5aZVpKRkV9UnAo0Qi8vtcT U1dHNyNDAxNLRwszJwtHUxNnZydDJzdHR2dXJyNLcxMDZ0tHE1dKcgYtTAOaaxeYM/71PX8hwE+ p+47Z6ckh41+MZXKv2Bscp2/5/Yqzz+Yb2pQiGv4JTPy9gyjui87DwbNn/vxf+3z4jv/YHs2zeb OVJobflbzABAA== X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A The 21264 from EV67 on, and the 21364, have a second performance counter mode, ProfileMe, alongside the Aggregate mode that the driver uses today. An Aggregate mode sample reports the PC where the overflow interrupt was taken. On an EV7 that is anywhere from 15 instructions before to 12 after the one that overflowed the counter, which makes perf annotate output close to useless. In ProfileMe mode the CPU picks one fetched instruction, follows it down the pipeline, and reports its PC along with what happened to it: whether it retired, whether it trapped and why, whether it was a mispredicted branch, stalled before map, or was killed on a wrong path, and what PCTR1 counted while it was in flight. Patch 1 fixes a constant passed to the wrong PALcode call, with no functional change. Patch 2 adds the sysfs format and event attributes the perf tool needs to name raw events. Patch 3 adds ProfileMe sampling, selected with precise_ip or a new profileme config bit, so cycles:p and perf record's default event use it. Patch 4 attaches the status registers to each sample as PERF_SAMPLE_RAW data, and patch 5 adds an option to randomize the sampling interval so that it cannot lock onto a loop. A separate series for perf-tools-next adds a decoder for the raw data to perf report -D and perf script -D, and a script that sums the status by symbol or by instruction, in the style of DCPI. The two modes cannot run at the same time, because PCTR_CTL[SL0] sets the mode for both counters. A ProfileMe event is scheduled alone, and perf multiplexes it with any other hardware events. perf stat does not ask for precise events, so it keeps using Aggregate mode. To try it: perf record -e cycles:p -- ./workload perf annotate I tested this on an AlphaServer ES47 (EV7). Samples from a 16-instruction loop land on all 16 instructions rather than on 4 PCs. DTB misses and unaligned traps are attributed to the faulting load. A branch on random data shows up as mispredicted in 21% of its samples, and in 0% with sorted data. A 12 minute perf record -a while building git took 4.45 million samples with no warnings. Sampling every 10000 instructions, which used to wedge the CPU, ran 66 times without a hang. Signed-off-by: Matt Turner --- Changes in v2: - Patch 1: explain why bit 0 clear means all processes, although the Architecture Reference Manual says otherwise. - Patch 3: fix a CPU wedge during high-rate ProfileMe sampling. The ProfileMe counters are now written twice, and a stopped counter is moved away from overflow, as EV67 HRM PALcode restrictions 32 and 38 require. - Patch 3: set the profiled PC in place in the trap frame of the instruction's mode instead of in a pt_regs copy on the stack, so sampled registers and stack values are those of the right frame. A kernel instruction whose interrupt is taken in user mode gets a per-CPU frame holding only its PC, so the user frame is not changed. - Patch 4: drop the reserved field and pack the 64-bit fields of struct alpha_profileme_sample, so they are 8-byte aligned in the sample record and the record needs no padding. This changes the raw data layout. - Patch 5: compute the jitter with mul_u64_u32_shr() and saturate the sum, so that large periods cannot overflow. - Link to v1: https://patch.msgid.link/20261028-alpha-profileme-v1-0-d44b52bf2500@gmail.com To: Richard Henderson To: Matt Turner To: Magnus Lindholm To: Peter Zijlstra To: Ingo Molnar To: Arnaldo Carvalho de Melo To: Namhyung Kim To: Mark Rutland To: Alexander Shishkin To: Jiri Olsa To: Ian Rogers To: Adrian Hunter To: James Clark Cc: linux-alpha@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-perf-users@vger.kernel.org --- Matt Turner (5): alpha/perf: pass PERFMON_CMD_LOGGING_ALL to the logging options call alpha/perf: add sysfs format and event attributes alpha/perf: implement ProfileMe sampling alpha/perf: attach ProfileMe status as PERF_SAMPLE_RAW data alpha/perf: optionally randomize the ProfileMe sampling interval arch/alpha/include/asm/perf_event.h | 2 + arch/alpha/include/asm/wrperfmon.h | 14 ++ arch/alpha/include/uapi/asm/perf_event.h | 31 ++++ arch/alpha/kernel/perf_event.c | 309 +++++++++++++++++++++++++++++-- 4 files changed, 345 insertions(+), 11 deletions(-) --- base-commit: 330517c63aa9b48227b6ab45f01003effac77ae4 change-id: 20261024-alpha-profileme-6e98a977cb54 Best regards, -- Matt Turner