public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf/x86/uncore: clean up const mismatch
@ 2025-12-17 12:42 Greg Kroah-Hartman
  2025-12-18  8:55 ` Peter Zijlstra
  2026-01-12  8:03 ` [tip: perf/core] " tip-bot2 for Greg Kroah-Hartman
  0 siblings, 2 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2025-12-17 12:42 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung
  Cc: linux-kernel, Greg Kroah-Hartman, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, linux-perf-users

In some cmp functions, a const pointer is cast out to a non-const
pointer by using container_of() which is not correct.  Fix this up by
properly marking the pointers as const, which preserves the correct
type of the pointer passed into the functions.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/events/intel/uncore_discovery.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c
index 7d57ce706feb..330bca2f14b3 100644
--- a/arch/x86/events/intel/uncore_discovery.c
+++ b/arch/x86/events/intel/uncore_discovery.c
@@ -52,7 +52,7 @@ static int get_device_die_id(struct pci_dev *dev)
 
 static inline int __type_cmp(const void *key, const struct rb_node *b)
 {
-	struct intel_uncore_discovery_type *type_b = __node_2_type(b);
+	const struct intel_uncore_discovery_type *type_b = __node_2_type(b);
 	const u16 *type_id = key;
 
 	if (type_b->type > *type_id)
@@ -115,7 +115,7 @@ get_uncore_discovery_type(struct uncore_unit_discovery *unit)
 
 static inline int pmu_idx_cmp(const void *key, const struct rb_node *b)
 {
-	struct intel_uncore_discovery_unit *unit;
+	const struct intel_uncore_discovery_unit *unit;
 	const unsigned int *id = key;
 
 	unit = rb_entry(b, struct intel_uncore_discovery_unit, node);
@@ -173,7 +173,7 @@ int intel_uncore_find_discovery_unit_id(struct rb_root *units, int die,
 
 static inline bool unit_less(struct rb_node *a, const struct rb_node *b)
 {
-	struct intel_uncore_discovery_unit *a_node, *b_node;
+	const struct intel_uncore_discovery_unit *a_node, *b_node;
 
 	a_node = rb_entry(a, struct intel_uncore_discovery_unit, node);
 	b_node = rb_entry(b, struct intel_uncore_discovery_unit, node);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf/x86/uncore: clean up const mismatch
  2025-12-17 12:42 [PATCH] perf/x86/uncore: clean up const mismatch Greg Kroah-Hartman
@ 2025-12-18  8:55 ` Peter Zijlstra
  2025-12-18  9:59   ` Greg Kroah-Hartman
  2026-01-12  8:03 ` [tip: perf/core] " tip-bot2 for Greg Kroah-Hartman
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2025-12-18  8:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: mingo, acme, namhyung, linux-kernel, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, linux-perf-users

On Wed, Dec 17, 2025 at 01:42:41PM +0100, Greg Kroah-Hartman wrote:
> In some cmp functions, a const pointer is cast out to a non-const
> pointer by using container_of() which is not correct.  Fix this up by
> properly marking the pointers as const, which preserves the correct
> type of the pointer passed into the functions.

How did you find this? My builds do not complain and all that.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf/x86/uncore: clean up const mismatch
  2025-12-18  8:55 ` Peter Zijlstra
@ 2025-12-18  9:59   ` Greg Kroah-Hartman
  2025-12-18 10:11     ` Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2025-12-18  9:59 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, acme, namhyung, linux-kernel, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, linux-perf-users

On Thu, Dec 18, 2025 at 09:55:51AM +0100, Peter Zijlstra wrote:
> On Wed, Dec 17, 2025 at 01:42:41PM +0100, Greg Kroah-Hartman wrote:
> > In some cmp functions, a const pointer is cast out to a non-const
> > pointer by using container_of() which is not correct.  Fix this up by
> > properly marking the pointers as const, which preserves the correct
> > type of the pointer passed into the functions.
> 
> How did you find this? My builds do not complain and all that.

I have a local change that turns container_of() into container_of_const():
	https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=container_of_const_mess&id=ea8cab3db2b5a56c5ef63d0e32accce58eb9bb2c
that I'm using to sweep the tree and fix up all of the places we have
gotten this wrong.  And wow, have we gotten it wrong in so many
places...

It's a slow grind, I'll get there eventually and then will merge a patch
that forces container_of() to catch this type of thing so it will not
come back in the future.  Maybe a year or so, no real rush :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf/x86/uncore: clean up const mismatch
  2025-12-18  9:59   ` Greg Kroah-Hartman
@ 2025-12-18 10:11     ` Peter Zijlstra
  2025-12-18 11:20       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2025-12-18 10:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: mingo, acme, namhyung, linux-kernel, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, linux-perf-users

On Thu, Dec 18, 2025 at 10:59:25AM +0100, Greg Kroah-Hartman wrote:
> On Thu, Dec 18, 2025 at 09:55:51AM +0100, Peter Zijlstra wrote:
> > On Wed, Dec 17, 2025 at 01:42:41PM +0100, Greg Kroah-Hartman wrote:
> > > In some cmp functions, a const pointer is cast out to a non-const
> > > pointer by using container_of() which is not correct.  Fix this up by
> > > properly marking the pointers as const, which preserves the correct
> > > type of the pointer passed into the functions.
> > 
> > How did you find this? My builds do not complain and all that.
> 
> I have a local change that turns container_of() into container_of_const():
> 	https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=container_of_const_mess&id=ea8cab3db2b5a56c5ef63d0e32accce58eb9bb2c
> that I'm using to sweep the tree and fix up all of the places we have
> gotten this wrong.  And wow, have we gotten it wrong in so many
> places...
> 
> It's a slow grind, I'll get there eventually and then will merge a patch
> that forces container_of() to catch this type of thing so it will not
> come back in the future.  Maybe a year or so, no real rush :)

OK, meanwhile I'll see this patch is merged :-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf/x86/uncore: clean up const mismatch
  2025-12-18 10:11     ` Peter Zijlstra
@ 2025-12-18 11:20       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2025-12-18 11:20 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, acme, namhyung, linux-kernel, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	James Clark, Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, linux-perf-users

On Thu, Dec 18, 2025 at 11:11:13AM +0100, Peter Zijlstra wrote:
> On Thu, Dec 18, 2025 at 10:59:25AM +0100, Greg Kroah-Hartman wrote:
> > On Thu, Dec 18, 2025 at 09:55:51AM +0100, Peter Zijlstra wrote:
> > > On Wed, Dec 17, 2025 at 01:42:41PM +0100, Greg Kroah-Hartman wrote:
> > > > In some cmp functions, a const pointer is cast out to a non-const
> > > > pointer by using container_of() which is not correct.  Fix this up by
> > > > properly marking the pointers as const, which preserves the correct
> > > > type of the pointer passed into the functions.
> > > 
> > > How did you find this? My builds do not complain and all that.
> > 
> > I have a local change that turns container_of() into container_of_const():
> > 	https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=container_of_const_mess&id=ea8cab3db2b5a56c5ef63d0e32accce58eb9bb2c
> > that I'm using to sweep the tree and fix up all of the places we have
> > gotten this wrong.  And wow, have we gotten it wrong in so many
> > places...
> > 
> > It's a slow grind, I'll get there eventually and then will merge a patch
> > that forces container_of() to catch this type of thing so it will not
> > come back in the future.  Maybe a year or so, no real rush :)
> 
> OK, meanwhile I'll see this patch is merged :-)

Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip: perf/core] perf/x86/uncore: clean up const mismatch
  2025-12-17 12:42 [PATCH] perf/x86/uncore: clean up const mismatch Greg Kroah-Hartman
  2025-12-18  8:55 ` Peter Zijlstra
@ 2026-01-12  8:03 ` tip-bot2 for Greg Kroah-Hartman
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Greg Kroah-Hartman @ 2026-01-12  8:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Greg Kroah-Hartman, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     632d89b030f1dac8d91875cd56a08adededba349
Gitweb:        https://git.kernel.org/tip/632d89b030f1dac8d91875cd56a08adededba349
Author:        Greg Kroah-Hartman <gregkh@linuxfoundation.org>
AuthorDate:    Wed, 17 Dec 2025 13:42:41 +01:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 06 Jan 2026 16:34:23 +01:00

perf/x86/uncore: clean up const mismatch

In some cmp functions, a const pointer is cast out to a non-const
pointer by using container_of() which is not correct.  Fix this up by
properly marking the pointers as const, which preserves the correct
type of the pointer passed into the functions.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/2025121741-headstand-stratus-f5eb@gregkh
---
 arch/x86/events/intel/uncore_discovery.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c
index 7d57ce7..330bca2 100644
--- a/arch/x86/events/intel/uncore_discovery.c
+++ b/arch/x86/events/intel/uncore_discovery.c
@@ -52,7 +52,7 @@ static int get_device_die_id(struct pci_dev *dev)
 
 static inline int __type_cmp(const void *key, const struct rb_node *b)
 {
-	struct intel_uncore_discovery_type *type_b = __node_2_type(b);
+	const struct intel_uncore_discovery_type *type_b = __node_2_type(b);
 	const u16 *type_id = key;
 
 	if (type_b->type > *type_id)
@@ -115,7 +115,7 @@ get_uncore_discovery_type(struct uncore_unit_discovery *unit)
 
 static inline int pmu_idx_cmp(const void *key, const struct rb_node *b)
 {
-	struct intel_uncore_discovery_unit *unit;
+	const struct intel_uncore_discovery_unit *unit;
 	const unsigned int *id = key;
 
 	unit = rb_entry(b, struct intel_uncore_discovery_unit, node);
@@ -173,7 +173,7 @@ int intel_uncore_find_discovery_unit_id(struct rb_root *units, int die,
 
 static inline bool unit_less(struct rb_node *a, const struct rb_node *b)
 {
-	struct intel_uncore_discovery_unit *a_node, *b_node;
+	const struct intel_uncore_discovery_unit *a_node, *b_node;
 
 	a_node = rb_entry(a, struct intel_uncore_discovery_unit, node);
 	b_node = rb_entry(b, struct intel_uncore_discovery_unit, node);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-12  8:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17 12:42 [PATCH] perf/x86/uncore: clean up const mismatch Greg Kroah-Hartman
2025-12-18  8:55 ` Peter Zijlstra
2025-12-18  9:59   ` Greg Kroah-Hartman
2025-12-18 10:11     ` Peter Zijlstra
2025-12-18 11:20       ` Greg Kroah-Hartman
2026-01-12  8:03 ` [tip: perf/core] " tip-bot2 for Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox