Skip to contentSkip to conversation

x86/perf_events: build fix

PATCH In review Jan Beulich 2 participants 5 messages Nov 23, 2012 – Jan 20, 2013 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/perf_events: build fix

At least some older gcc versions dislike mixing constant and non-const data in the same section ("... causes a section type confict"). Newer gcc simply emits the section as writable (which isn't what we want, but also is not a big problem as it gets discarded post-init anyway).

Also get the Knight's Corner definitions in sync.

---
 arch/x86/kernel/cpu/perf_event_knc.c |    4 ++--
 arch/x86/kernel/cpu/perf_event_p6.c  |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event_knc.c +2 -2
@@ -17,7 +17,7 @@ static const u64 knc_perfmon_event_map[]
   [PERF_COUNT_HW_BRANCH_MISSES]		= 0x002b,
 };
 
-static __initconst u64 knc_hw_cache_event_ids
+static const u64 __initconst knc_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
@@ -284,7 +284,7 @@ static struct attribute *intel_knc_forma
 	NULL,
 };
 
-static __initconst struct x86_pmu knc_pmu = {
+static const struct x86_pmu knc_pmu __initconst = {
 	.name			= "knc",
 	.handle_irq		= knc_pmu_handle_irq,
 	.disable_all		= knc_pmu_disable_all,
arch/x86/kernel/cpu/perf_event_p6.c +1 -1
@@ -19,7 +19,7 @@ static const u64 p6_perfmon_event_map[]
 
 };
 
-static __initconst u64 p6_hw_cache_event_ids
+static const u64 __initconst p6_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

[forgot to copy lkml]

Hi Jan,

Quoted 39 lines · Jan Beulich

At least some older gcc versions dislike mixing constant and non-const data in the same section ("... causes a section type confict"). Newer gcc simply emits the section as writable (which isn't what we want, but also is not a big problem as it gets discarded post-init anyway).

Also get the Knight's Corner definitions in sync.

---
 arch/x86/kernel/cpu/perf_event_knc.c |    4 ++--
 arch/x86/kernel/cpu/perf_event_p6.c  |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event_knc.c +2 -2
@@ -17,7 +17,7 @@ static const u64 knc_perfmon_event_map[]
   [PERF_COUNT_HW_BRANCH_MISSES]		= 0x002b,
 };
 
-static __initconst u64 knc_hw_cache_event_ids
+static const u64 __initconst knc_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
@@ -284,7 +284,7 @@ static struct attribute *intel_knc_forma
 	NULL,
 };
 
-static __initconst struct x86_pmu knc_pmu = {
+static const struct x86_pmu knc_pmu __initconst = {
 	.name			= "knc",
 	.handle_irq		= knc_pmu_handle_irq,
 	.disable_all		= knc_pmu_disable_all,
arch/x86/kernel/cpu/perf_event_p6.c +0 -0
@@ -19,7 +19,7 @@ static const u64 p6_perfmon_event_map[]
 
 };

arch/x86/kernel/cpu/perf_event_p6.c static const u64 p6_perfmon_event_map[]

Quoted 10 lines
arch/x86/kernel/cpu/perf_event_p6.c +1 -2
 
-static __initconst u64 p6_hw_cache_event_ids
+static const u64 __initconst p6_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
 
 
 
--

I was testing out 3.8-rc1 when I ran into the same problem resolved by this patch when building with gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)

Were you given a reason why this shouldn't be needed?

It looks like the build error was introduced by (e09df47 "perf/x86:
Update/fix generic events on P6 PMU") which is in v3.7 as well.

Thanks,
Shaun

#3 lore raw

PATCH 1/1 x86/perf_events: Fix "section type conflict" build error.

From: Jan Beulich <[email protected]>

This patch fixes a build regression first introduced in 3.7 with (e09df47 "perf/x86: Update/fix generic events on P6 PMU").

At least some older versions of gcc, like (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51), dislike mixing constant and non-const data in the same section. Without this patch a build will fail with the following error:

CC arch/x86/kernel/cpu/perf_event_p6.o
arch/x86/kernel/cpu/perf_event_p6.c:22: error: p6_hw_cache_event_ids causes a section type conflict make[3]: *** [arch/x86/kernel/cpu/perf_event_p6.o] Error 1

Newer versions of gcc simply emits the section as writable (which isn't what we want, but also is not a big problem as it gets discarded post-init anyway).

Also get the Knight's Corner definitions in sync.

Cc [email protected] # 3.7.x only
[[email protected]: Added details to the commit message.]

---

Hans, Thomas,

Any chance of picking this up for 3.8? This doesn't seem too controversial since it only makes sure that data in the __initconst section is const.

Rob Landley also reported this to the list here:
https://lkml.org/lkml/2012/12/14/511.

Thanks,
Shaun

 arch/x86/kernel/cpu/perf_event_knc.c | 4 ++--
 arch/x86/kernel/cpu/perf_event_p6.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event_knc.c +2 -2
index 4b7731b..838fa87 100644
@@ -17,7 +17,7 @@ static const u64 knc_perfmon_event_map[] =
   [PERF_COUNT_HW_BRANCH_MISSES]		= 0x002b,
 };
 
-static __initconst u64 knc_hw_cache_event_ids
+static const u64 __initconst knc_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
@@ -284,7 +284,7 @@ static struct attribute *intel_knc_formats_attr[] = {
 	NULL,
 };
 
-static __initconst struct x86_pmu knc_pmu = {
+static const struct x86_pmu knc_pmu __initconst = {
 	.name			= "knc",
 	.handle_irq		= knc_pmu_handle_irq,
 	.disable_all		= knc_pmu_disable_all,
arch/x86/kernel/cpu/perf_event_p6.c +1 -1
index f2af39f..b1e2fe1 100644
@@ -19,7 +19,7 @@ static const u64 p6_perfmon_event_map[] =
 
 };
 
-static __initconst u64 p6_hw_cache_event_ids
+static const u64 __initconst p6_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
Signature · 1 line
1.8.1
#4 lore raw

PATCH 1/1 x86/perf_events: Fix "section type conflict" build error.

From: Jan Beulich <[email protected]>

This patch fixes a build regression first introduced in 3.7 with (e09df47 "perf/x86: Update/fix generic events on P6 PMU").

At least some older versions of gcc, like (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51), dislike mixing constant and non-const data in the same section. Without this patch a build will fail with the following error:

CC arch/x86/kernel/cpu/perf_event_p6.o
arch/x86/kernel/cpu/perf_event_p6.c:22: error: p6_hw_cache_event_ids causes a section type conflict make[3]: *** [arch/x86/kernel/cpu/perf_event_p6.o] Error 1

Newer versions of gcc simply emits the section as writable (which isn't what we want, but also is not a big problem as it gets discarded post-init anyway).

Also get the Knight's Corner definitions in sync.

Cc [email protected] # 3.7.x only
[[email protected]: Added details to the commit message.]

---

[I had the wrong stable email address when I previously sent this. Sorry about the extra noise.]

Hans, Thomas,

Any chance of picking this up for 3.8? This doesn't seem too controversial since it only makes sure that data in the __initconst section is const.

Rob Landley also reported this to the list here:
https://lkml.org/lkml/2012/12/14/511.

Thanks,
Shaun

 arch/x86/kernel/cpu/perf_event_knc.c | 4 ++--
 arch/x86/kernel/cpu/perf_event_p6.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event_knc.c +2 -2
index 4b7731b..838fa87 100644
@@ -17,7 +17,7 @@ static const u64 knc_perfmon_event_map[] =
   [PERF_COUNT_HW_BRANCH_MISSES]		= 0x002b,
 };
 
-static __initconst u64 knc_hw_cache_event_ids
+static const u64 __initconst knc_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
@@ -284,7 +284,7 @@ static struct attribute *intel_knc_formats_attr[] = {
 	NULL,
 };
 
-static __initconst struct x86_pmu knc_pmu = {
+static const struct x86_pmu knc_pmu __initconst = {
 	.name			= "knc",
 	.handle_irq		= knc_pmu_handle_irq,
 	.disable_all		= knc_pmu_disable_all,
arch/x86/kernel/cpu/perf_event_p6.c +1 -1
index f2af39f..b1e2fe1 100644
@@ -19,7 +19,7 @@ static const u64 p6_perfmon_event_map[] =
 
 };
 
-static __initconst u64 p6_hw_cache_event_ids
+static const u64 __initconst p6_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
Signature · 1 line
1.8.1
#5 lore raw

Re: [PATCH] x86/perf_events: Fix "section type conflict" build error.

Bump. Still an issue with v3.8-rc4. Am I mistaken in thinking this patch is trivial and obviously correct?

Thanks,
Shaun

Quoted 81 lines · Shaun Ruffell

From: Jan Beulich <[email protected]>

This patch fixes a build regression first introduced in 3.7 with (e09df47 "perf/x86: Update/fix generic events on P6 PMU").

At least some older versions of gcc, like (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51), dislike mixing constant and non-const data in the same section. Without this patch a build will fail with the following error:

CC arch/x86/kernel/cpu/perf_event_p6.o
arch/x86/kernel/cpu/perf_event_p6.c:22: error: p6_hw_cache_event_ids causes a section type conflict make[3]: *** [arch/x86/kernel/cpu/perf_event_p6.o] Error 1

Newer versions of gcc simply emits the section as writable (which isn't what we want, but also is not a big problem as it gets discarded post-init anyway).

Also get the Knight's Corner definitions in sync.

Cc [email protected] # 3.7.x only
[[email protected]: Added details to the commit message.]

---

[I had the wrong stable email address when I previously sent this. Sorry about the extra noise.]

Hans, Thomas,

Any chance of picking this up for 3.8? This doesn't seem too controversial since it only makes sure that data in the __initconst section is const.

Rob Landley also reported this to the list here:
https://lkml.org/lkml/2012/12/14/511.

Thanks,
Shaun

 arch/x86/kernel/cpu/perf_event_knc.c | 4 ++--
 arch/x86/kernel/cpu/perf_event_p6.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/perf_event_knc.c +2 -2
index 4b7731b..838fa87 100644
@@ -17,7 +17,7 @@ static const u64 knc_perfmon_event_map[] =
   [PERF_COUNT_HW_BRANCH_MISSES]		= 0x002b,
 };
 
-static __initconst u64 knc_hw_cache_event_ids
+static const u64 __initconst knc_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
@@ -284,7 +284,7 @@ static struct attribute *intel_knc_formats_attr[] = {
 	NULL,
 };
 
-static __initconst struct x86_pmu knc_pmu = {
+static const struct x86_pmu knc_pmu __initconst = {
 	.name			= "knc",
 	.handle_irq		= knc_pmu_handle_irq,
 	.disable_all		= knc_pmu_disable_all,
arch/x86/kernel/cpu/perf_event_p6.c +1 -1
index f2af39f..b1e2fe1 100644
@@ -19,7 +19,7 @@ static const u64 p6_perfmon_event_map[] =
 
 };
 
-static __initconst u64 p6_hw_cache_event_ids
+static const u64 __initconst p6_hw_cache_event_ids
 				[PERF_COUNT_HW_CACHE_MAX]
 				[PERF_COUNT_HW_CACHE_OP_MAX]
 				[PERF_COUNT_HW_CACHE_RESULT_MAX] =
Signature · 1 line
1.8.1