mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hang Zhengyang <hang.zhengyang1010@gmail.com>
To: Zhao Gongyi <zhaogongyi@bytedance.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	namhyung@kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	irogers@google.com, adrian.hunter@intel.com,
	james.clark@linaro.org, tglx@kernel.org, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf/x86/amd: Avoid double-decrementing n_pair on failed transactions
Date: Wed, 11 Nov 2026 14:54:03 +0800	[thread overview]
Message-ID: <20261111065404.3428684-1-hang.zhengyang1010@gmail.com> (raw)
In-Reply-To: <20261109111909.31712-1-zhaogongyi@bytedance.com>

On Mon,  9 Nov 2026 19:19:09 +0800, Zhao Gongyi wrote:
> On a failed PERF_PMU_TXN_ADD commit, x86_schedule_events() releases
> constraints for newly added pair events. The AMD put callback decrements
> n_pair, and x86_pmu_cancel_txn() then subtracts n_txn_pair for the same
> events.

Reproduced in a KVM guest on a Zen 3 host (Ryzen 7 PRO 5850U), kernel
7.3-rc6, with a trace_printk() in x86_schedule_events() and
x86_pmu_cancel_txn().  With four pinned cycles events on CPU 0, each
failed attempt to add a pinned '{fp_ret_sse_avx_ops.all,cycles}' group
leaves n_pair one lower: -1, -2, -3, so gpmax goes 5, 6, 7 on 6
counters.  With this patch n_pair is back to 0 after each attempt and
gpmax stays 5.

Tested-by: Hang Zhengyang <hang.zhengyang1010@gmail.com>

To reproduce:

  perf stat -C 0 -e '{cycles,cycles,cycles,cycles}:D' -- sleep 4 &
  # three times:
  perf stat -C 0 -e '{fp_ret_sse_avx_ops.all,cycles}:D' -- taskset -c 0 <workload>

(Analysis and testing done with an AI assistant; I reproduced the
n_pair drift.)

      reply	other threads:[~2026-11-11  6:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 11:19 Zhao Gongyi
2026-11-11  6:54 ` Hang Zhengyang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261111065404.3428684-1-hang.zhengyang1010@gmail.com \
    --to=hang.zhengyang1010@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=zhaogongyi@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®