From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F9672AE96; Tue, 29 Apr 2025 18:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745949913; cv=none; b=myXKcmsg/sjTh6OlDZ7KpKPpcL0b70guRIOODZ8nLl/XhdcTAHx85eDZ7ni3HBbu8VbEo99L9TA8AutjXuEWOVn4wrgCsuAF5xW7YRBUypS9tuaAchVp0lncPa8kzBETiuOO/FGwqGvbRP9a6TojUe5f9GqlY3dflXM2ZboWrfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745949913; c=relaxed/simple; bh=2DHIkQWn1UrB0B0dKBBLz3SDk90XlSYT7EhtjhmZPC4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uZWwMW3Dc5GKTeDxdIq4kI9/o1vhMs/MtUgmIE0FvCh1op4GB2Lwxl3VxDGhIB4QI1cD/oFrjoeCXD9oaRmA6okPPQqkCtPaKXtMKbedq579RgKY5LNzRLBqz1WtGHqqxBjShGhNsT6lBdnxm5SMSJTF7jGF0iEKnwAtnfI59Ig= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UNbVlecS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UNbVlecS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8803C4CEE3; Tue, 29 Apr 2025 18:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745949913; bh=2DHIkQWn1UrB0B0dKBBLz3SDk90XlSYT7EhtjhmZPC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UNbVlecSdoDkUjlZk+5b+dL+dHibLcLfh8UICRB9lGVPSKgxi9Iktq3PM/8l5l8zW aQiW0kt9zuxl7OpORVT3l4vFSb6u4po1vdBTpvuWJyLKaWo9uesHyS0+FQw2qddyCH KS6C3Z9vZCCU40P/GLGx4oJ62uEbNvunoWnnbwYo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Luo Gengkun , Ingo Molnar , Kan Liang , Alexander Shishkin , Arnaldo Carvalho de Melo , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Ravi Bangoria , Sasha Levin Subject: [PATCH 6.1 057/167] perf/x86: Fix non-sampling (counting) events on certain x86 platforms Date: Tue, 29 Apr 2025 18:42:45 +0200 Message-ID: <20250429161054.074222038@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161051.743239894@linuxfoundation.org> References: <20250429161051.743239894@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luo Gengkun [ Upstream commit 1a97fea9db9e9b9c4839d4232dde9f505ff5b4cc ] Perf doesn't work at perf stat for hardware events on certain x86 platforms: $perf stat -- sleep 1 Performance counter stats for 'sleep 1': 16.44 msec task-clock # 0.016 CPUs utilized 2 context-switches # 121.691 /sec 0 cpu-migrations # 0.000 /sec 54 page-faults # 3.286 K/sec cycles instructions branches branch-misses The reason is that the check in x86_pmu_hw_config() for sampling events is unexpectedly applied to counting events as well. It should only impact x86 platforms with limit_period used for non-PEBS events. For Intel platforms, it should only impact some older platforms, e.g., HSW, BDW and NHM. Fixes: 88ec7eedbbd2 ("perf/x86: Fix low freqency setting issue") Signed-off-by: Luo Gengkun Signed-off-by: Ingo Molnar Reviewed-by: Kan Liang Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Link: https://lore.kernel.org/r/20250423064724.3716211-1-luogengkun@huaweicloud.com Signed-off-by: Sasha Levin --- arch/x86/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index fa07447324445..a8732dd9fedb9 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -623,7 +623,7 @@ int x86_pmu_hw_config(struct perf_event *event) if (event->attr.type == event->pmu->type) event->hw.config |= event->attr.config & X86_RAW_EVENT_MASK; - if (!event->attr.freq && x86_pmu.limit_period) { + if (is_sampling_event(event) && !event->attr.freq && x86_pmu.limit_period) { s64 left = event->attr.sample_period; x86_pmu.limit_period(event, &left); if (left > event->attr.sample_period) -- 2.39.5