From: Ingo Molnar <mingo@kernel.org>
To: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Kan Liang <kan.liang@linux.intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: [PATCH] perf/x86/intel: Fix and clean up intel_pmu_drain_arch_pebs() type use
Date: Wed, 12 Nov 2025 11:09:14 +0100 [thread overview]
Message-ID: <aRRcyoOobRyam5yD@gmail.com> (raw)
In-Reply-To: <cb49c1be-99a5-4aba-b3da-f902058a4996@linux.intel.com>
* Mi, Dapeng <dapeng1.mi@linux.intel.com> wrote:
>
> On 11/12/2025 12:42 PM, Stephen Rothwell wrote:
> > Hi all,
> >
> > After merging the tip tree, today's linux-next build (i386 defconfig)
> > failed like this:
> >
> > arch/x86/events/intel/ds.c: In function 'intel_pmu_drain_arch_pebs':
> > arch/x86/events/intel/ds.c:2983:24: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
> > 2983 | top = (void *)((u64)cpuc->pebs_vaddr +
> > | ^
> > arch/x86/events/intel/ds.c:2983:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> > 2983 | top = (void *)((u64)cpuc->pebs_vaddr +
> > | ^
> > cc1: all warnings being treated as errors
>
> Thanks for reporting the issue. I suppose the below patch would fix the
> building error. I would post it as an independent patch later.
>
> diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
> index c93bf971d97b..f695de9f7049 100644
> --- a/arch/x86/events/intel/ds.c
> +++ b/arch/x86/events/intel/ds.c
> @@ -2979,7 +2979,7 @@ static void intel_pmu_drain_arch_pebs(struct pt_regs
> *iregs,
> }
>
> base = cpuc->pebs_vaddr;
> - top = (void *)((u64)cpuc->pebs_vaddr +
> + top = (void *)((unsigned long)cpuc->pebs_vaddr +
> (index.wr << ARCH_PEBS_INDEX_WR_SHIFT));
This doesn't really address the core issue: ugly, fragile code due to
type confusion. The proper fix is:
top = cpuc->pebs_vaddr + (index.wr << ARCH_PEBS_INDEX_WR_SHIFT);
which is also much cleaner, see:
60f9f1d43720 ("perf/x86/intel: Fix and clean up intel_pmu_drain_arch_pebs() type use")
(also attached below.)
All this should be resolved in the latest -tip tree.
Thanks,
Ingo
=====================>
From 60f9f1d437201f6c457fc8a56f9df6d8a6d0bea6 Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@kernel.org>
Date: Wed, 12 Nov 2025 10:40:26 +0100
Subject: [PATCH] perf/x86/intel: Fix and clean up intel_pmu_drain_arch_pebs() type use
The following commit introduced a build failure on x86-32:
2721e8da2de7 ("perf/x86/intel: Allocate arch-PEBS buffer and initialize PEBS_BASE MSR")
...
arch/x86/events/intel/ds.c:2983:24: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
The forced type conversion to 'u64' and 'void *' are not 32-bit clean,
but they are also entirely unnecessary: ->pebs_vaddr is 'void *' already,
and integer-compatible pointer arithmetics will work just fine on it.
Fix & simplify the code.
Fixes: 2721e8da2de7 ("perf/x86/intel: Allocate arch-PEBS buffer and initialize PEBS_BASE MSR")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://patch.msgid.link/20251029102136.61364-10-dapeng1.mi@linux.intel.com
---
arch/x86/events/intel/ds.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
index c93bf971d97b..2e170f2093ac 100644
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -2979,8 +2979,7 @@ static void intel_pmu_drain_arch_pebs(struct pt_regs *iregs,
}
base = cpuc->pebs_vaddr;
- top = (void *)((u64)cpuc->pebs_vaddr +
- (index.wr << ARCH_PEBS_INDEX_WR_SHIFT));
+ top = cpuc->pebs_vaddr + (index.wr << ARCH_PEBS_INDEX_WR_SHIFT);
index.wr = 0;
index.full = 0;
next prev parent reply other threads:[~2025-11-12 10:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 4:42 linux-next: build failure after merge of the tip tree Stephen Rothwell
2025-11-12 5:20 ` Mi, Dapeng
2025-11-12 10:09 ` Ingo Molnar [this message]
2025-11-12 10:36 ` [PATCH] perf/x86/intel: Fix and clean up intel_pmu_drain_arch_pebs() type use Mi, Dapeng
2025-11-12 11:14 ` Ingo Molnar
2025-11-12 9:39 ` linux-next: build failure after merge of the tip tree Peter Zijlstra
2025-11-12 10:45 ` Stephen Rothwell
2025-11-12 10:48 ` Peter Zijlstra
2025-11-12 12:31 ` Mi, Dapeng
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=aRRcyoOobRyam5yD@gmail.com \
--to=mingo@kernel.org \
--cc=dapeng1.mi@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=sfr@canb.auug.org.au \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).