fix 25 section mismatch warnings..
Subsystems (7)
cover fix 25 section mismatch warnings..
The following set of patches fixes 25 Section mismatch warnings in following directories:
kernel/mm/drivers/pciarch/x86/
When build individually they are now clean.
The shortlog:
Sam Ravnborg (11):
pci: fix section mismatch warnings referring to pci_do_scan_bus
pci: fix 4x section mismatch warnings
cpu: fix section mismatch warnings for enable_nonboot_cpus
cpu: fix section mismatch related to cpu_chain
cpu: do not annotate exported register_cpu_notifier()
cpu: silence section mismatch warnings for hotcpu notifies
mm: fix section mismatch warning in sparse.c
x86: fix section mismatch warning in acpi/boot.c
x86: silence section mismatch warning in smpboot_64.c
x86: fix section mismatch warning in kernel/pci-calgary
x86: fix section mismatch warnings when referencing notifiers
With these patches applied I have a clean build of arch/x86/ with an allyesconfig.
I expect Greg to pick up the pci patches - but as they conflict with patches recently posted by Adrian a qualified selection should be made.
The cpu patches are cc:ed to Gautham R Shenoy but I think they need to go in via Andrew.
The mm patch are cc:ed the Mel, Christoph and Andy but I think this one should also go in via Andrew.
The x86 patches are cc:ed to the x86 gang and should all go in via the x86 tree.
I would like some extra review of the following patches:
-> The pci patches
-> x86: silence section mismatch warning in smpboot_64.c
The others are more strightforward but please eye ball them too.
For my allyesconfig build I still has 116 warnings - but this is without Adrian's patches applied.
Of these 8 happens only when running the final check on vmlinux.o which is due to references between the sub directories (kernel/ <-> arch/x86/kernel/)
Patches follows unnumbered as they are independent of each other.
Sam
PATCH 1/1 pci: fix section mismatch warnings referring to pci_do_scan_bus
Fix following warnings:
WARNING: o-x86_64/drivers/pci/built-in.o(.text+0xb054): Section mismatch in reference from the function cpci_configure_slot() to the function .devinit.text:pci_do_scan_bus()
WARNING: o-x86_64/drivers/pci/built-in.o(.text+0x153ab): Section mismatch in reference from the function shpchp_configure_device() to the function .devinit.text:pci_do_scan_bus()
WARNING: o-x86_64/drivers/pci/built-in.o(__ksymtab+0xc0): Section mismatch in reference from the variable __ksymtab_pci_do_scan_bus to the function .devinit.text:pci_do_scan_bus()
PCI hotplug were the only user of pci_do_scan_bus() so moving this function to the directory of PCI Hotplug was a logical way to fix so
we only include this function in the kernel when the CONFIG_HOTPLUG_PCI is enabled.
Then the abuse of __devinit could be dropped and
we no longer trigger the above warnings.
--- drivers/pci/hotplug/Makefile | 1 + drivers/pci/hotplug/pci-core.c | 20 ++++++++++++++++++++ drivers/pci/probe.c | 15 --------------- 3 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 drivers/pci/hotplug/pci-core.c
drivers/pci/hotplug/Makefile +1 -0
@@ -1,6 +1,7 @@ # # Makefile for the Linux kernel pci hotplug controller drivers. # +obj-y := pci-core.o obj-$(CONFIG_HOTPLUG_PCI) += pci_hotplug.o obj-$(CONFIG_HOTPLUG_PCI_FAKE) += fakephp.o
drivers/pci/hotplug/pci-core.c new file +20 -0
@@ -0,0 +1,20 @@ +/* Core PCI functionality used only by PCI hotplug */ + +#include <linux/pci.h> +#include "../pci.h" + + +unsigned int pci_do_scan_bus (struct pci_bus *bus) +{ +unsigned int max; + + max =pci_scan_child_bus (bus); + +/* +* Make the discovered devices available. +*/ +pci_bus_add_devices (bus); + +return max; +} +EXPORT_SYMBOL (pci_do_scan_bus);
drivers/pci/probe.c +0 -15
@@ -1050,20 +1050,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)return max; } -unsigned int __devinit pci_do_scan_bus (struct pci_bus *bus) -{ -unsigned int max; - - max =pci_scan_child_bus (bus); - -/* -* Make the discovered devices available. -*/ -pci_bus_add_devices (bus); - -return max; -} -struct pci_bus *pci_create_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata) {
@@ -1156,7 +1142,6 @@ EXPORT_SYMBOL(pci_scan_bus_parented);#ifdef CONFIG_HOTPLUG EXPORT_SYMBOL (pci_add_new_bus); -EXPORT_SYMBOL (pci_do_scan_bus);EXPORT_SYMBOL (pci_scan_slot);EXPORT_SYMBOL (pci_scan_bridge);EXPORT_SYMBOL (pci_scan_single_device);
Signature · 1 line
1.5.4.rc3.14.g44397
Re: [PATCH] pci: fix section mismatch warnings referring to pci_do_scan_bus
Quoted 11 lines · Sam Ravnborg
Fix following warnings:
WARNING: o-x86_64/drivers/pci/built-in.o(.text+0xb054): Section mismatch in reference from the functioncpci_configure_slot()to the function .devinit.text:pci_do_scan_bus()
WARNING: o-x86_64/drivers/pci/built-in.o(.text+0x153ab): Section mismatch in reference from the functionshpchp_configure_device()to the function .devinit.text:pci_do_scan_bus()
WARNING: o-x86_64/drivers/pci/built-in.o(__ksymtab+0xc0): Section mismatch in reference from the variable__ksymtab_pci_do_scan_busto the function .devinit.text:pci_do_scan_bus()PCI hotplug were the only user of
pci_do_scan_bus()so moving this function to the directory of PCI Hotplug was a logical way to fix so
we only include this function in the kernel when theCONFIG_HOTPLUG_PCIis enabled.
Quoted 7 lines
Then the abuse of
__devinitcould be dropped and
we no longer trigger the above warnings.Signed-off-by Sam Ravnborg <[email protected]>Cc Greg KH <[email protected]>Cc Adrian Bunk <[email protected]>---
This patch is bogus - I will send an updated version later this weekend.
Sam
PATCH 1/1 pci: fix 4x section mismatch warnings
In reply to Sam RavnborgThe following warnings were issued during build ofdrivers/pci with an allyesconfig build:
WARNING: o-x86_64/drivers/pci/built-in.o(.text+0xdaf): Section mismatch in reference from the function pci_add_new_bus() to the function .devinit.text:pci_alloc_child_bus()
WARNING: o-x86_64/drivers/pci/built-in.o(.text+0x15e2): Section mismatch in reference from the function pci_scan_single_device() to the function .devinit.text:pci_scan_device()
WARNING: o-x86_64/drivers/pci/built-in.o(.text+0x1b0c5): Section mismatch in reference from the function pci_bus_assign_resources() to the function .devinit.text:pci_setup_bridge()
WARNING: o-x86_64/drivers/pci/built-in.o(.text+0x1b32d): Section mismatch in reference from the function pci_bus_size_bridges() to the function .devinit.text:pci_bus_size_cardbus()
Investigating each case closer it looked like all referred functions are only used in the init phase or during hotplug.
So to avoid wasting too much memory in the non-hotplug case the simpler fix was to allow the fuctions to use code/data from the __devinit sections. This was done in all four case by adding the __ref annotation.
--- drivers/pci/probe.c | 4 ++-- drivers/pci/setup-bus.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/pci/probe.c +2 -2
@@ -442,7 +442,7 @@ error_register:return NULL ; } -struct pci_bus *pci_add_new_bus (struct pci_bus *parent,struct pci_dev *dev,int busnr) +struct pci_bus *__ref pci_add_new_bus (struct pci_bus *parent,struct pci_dev *dev,int busnr) {struct pci_bus *child;
@@ -959,7 +959,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)up_write (&pci_bus_sem); } -struct pci_dev *pci_scan_single_device (struct pci_bus *bus,int devfn) +struct pci_dev *__ref pci_scan_single_device (struct pci_bus *bus,int devfn) {struct pci_dev *dev;
drivers/pci/setup-bus.c +2 -2
@@ -440,7 +440,7 @@ pci_bus_size_cardbus(struct pci_bus *bus) } } -void pci_bus_size_bridges (struct pci_bus *bus) +void __ref pci_bus_size_bridges (struct pci_bus *bus) {struct pci_dev *dev;unsigned long mask, prefmask;
@@ -495,7 +495,7 @@ void pci_bus_size_bridges(struct pci_bus *bus) }EXPORT_SYMBOL (pci_bus_size_bridges); -void pci_bus_assign_resources (struct pci_bus *bus) +void __ref pci_bus_assign_resources (struct pci_bus *bus) {struct pci_bus *b;struct pci_dev *dev;
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 cpu: silence section mismatch warnings for hotcpu notifies
In reply to Sam RavnborgThe hotcpu_notifier is used to create notifiers to be called later. It really looks like the functions that are registered are only relevant in a HOTPLUG_CPU configuration and the correct fix was to wrap them in an #ifdef / #endif or similar.
But for now just tell modpost to silence the warning by annotating the static variable with __refdata.
This silences the following warnings in kernel/:
WARNING: o-x86_64/kernel/built-in.o(.data+0x960): Section mismatch in reference from the variable profile_cpu_callback_nb.17240 to the function .devinit.text:profile_cpu_callback()
WARNING: o-x86_64/kernel/built-in.o(.data+0x3fa0): Section mismatch in reference from the variable workqueue_cpu_callback_nb.14663 to the function .devinit.text:workqueue_cpu_callback()
WARNING: o-x86_64/kernel/built-in.o(.data+0xe280): Section mismatch in reference from the variable relay_hotcpu_callback_nb.19247 to the function .cpuinit.text:relay_hotcpu_callback()
Additional warnings are silenced with this change but they are left put.
This patch is just a workaround for the bad practice to use __cpuinit to annotate code solely used for HOTPLUG_CPU.
--- include/linux/cpu.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/cpu.h +1 -1
@@ -109,7 +109,7 @@ static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)extern void get_online_cpus (void );extern void put_online_cpus (void );#define hotcpu_notifier (fn, pri) { \ - static struct notifier_block fn##_nb = \ + static struct notifier_block fn##_nb __refdata = \ { .notifier_call = fn, .priority = pri }; \ register_cpu_notifier(&fn##_nb); \ }
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 cpu: do not annotate exported register_cpu_notifier()
In reply to Sam RavnborgFix following warning:
WARNING: o-x86_64/kernel/built-in.o(__ksymtab+0xfb0): Section mismatch in reference from the variable __ksymtab_register_cpu_notifier to the function .cpuinit.text:register_cpu_notifier()
register_cpu_notifier() are used from modules that may be loaded long after init has completed.
Drop the annotation so the function is kept after init.
--- kernel/cpu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cpu.c +1 -1
@@ -136,7 +136,7 @@ static void cpu_hotplug_done(void)mutex_unlock (&cpu_hotplug.lock); }/* Need to know about CPUs going up/down? */ -int __cpuinit register_cpu_notifier (struct notifier_block *nb) +int register_cpu_notifier (struct notifier_block *nb) {int ret;cpu_maps_update_begin ();
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 cpu: fix section mismatch warnings for enable_nonboot_cpus
In reply to Sam RavnborgFix following warning:
WARNING: o-x86_64/kernel/built-in.o(.text+0x36d8b): Section mismatch in reference from the function enable_nonboot_cpus() to the function .cpuinit.text:_cpu_up()
enable_nonboot_cpus() are used solely from CONFIG_CONFIG_PM_SLEEP_SMP=y and PM_SLEEP_SMP imply HOTPLUG_CPU therefore the reference to _cpu_up() is valid.
Annotate enable_nonboot_cpus() with __ref to silence modpost.
--- kernel/cpu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cpu.c +1 -1
@@ -389,7 +389,7 @@ int disable_nonboot_cpus(void)return error; } -void enable_nonboot_cpus (void ) +void __ref enable_nonboot_cpus (void ) {int cpu, error;
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 x86: silence section mismatch warning in smpboot_64.c
In reply to Sam RavnborgSilence the following warning:
WARNING: o-x86_64/arch/x86/kernel/built-in.o(.text+0x17cd3): Section mismatch in reference from the function remove_cpu_from_maps() to the variable .cpuinit.data:cpu_initialized
remove_cpu:maps() had a single user: __cpu_disable() so mark it static and annotate it with __ref to silence the warning from modpost.
_cpu_disable() has a single user in kernel/cpu.c:
=> take_cpu_down()
which again has a single user in the following call:
=> __stop_machine_run(take_cpu_down, &tcd_param, cpu);
Here a kthread is created.
So maybe the warning is correct and the right fix is to remove the __cpuinitdata annotation of cpu_initialized?
Note: The analysis were disturbed by the fact that we had a variable
with the same name in cpu/common.c - but this is 32 bit only]
Note: Should smpboot_64 use cpu_clear()?
--- arch/x86/kernel/smpboot_64.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/smpboot_64.c +1 -1
@@ -1019,7 +1019,7 @@ static void remove_siblinginfo(int cpu)cpu_clear (cpu, cpu_sibling_setup_map); } -void remove_cpu_from_maps (void ) +static void __ref remove_cpu_from_maps (void ) {int cpu =smp_processor_id ();
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 x86: fix section mismatch warning in acpi/boot.c
In reply to Sam RavnborgFix following warning:
WARNING: o-x86_64/arch/x86/kernel/built-in.o(.text+0x13d15): Section mismatch in reference from the function acpi_map_lsapic() to the function .cpuinit.text:mp_register_lapic()
The function acpi_map_lsapic() is exported and thus not annotated. But the sole user is acpi/processor_core.c in a __cpuinit path. So create a small wrapper and put back the annotation thus avoiding the warning.
--- arch/x86/kernel/acpi/boot.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
arch/x86/kernel/acpi/boot.c +7 -1
@@ -496,7 +496,8 @@ EXPORT_SYMBOL(acpi_register_gsi);* ACPI based hotplug support for CPU */ #ifdef CONFIG_ACPI_HOTPLUG_CPU -int acpi_map_lsapic (acpi_handle handle,int *pcpu) + +static int __cpuinit _acpi_map_lsapic (acpi_handle handle,int *pcpu) {struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL };union acpi_object *obj;
@@ -551,6 +552,11 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu)return 0 ; } +/* wrapper to silence section mismatch warning */ +int __ref acpi_map_lsapic (acpi_handle handle,int *pcpu) +{ +return _acpi_map_lsapic (handle, pcpu); +}EXPORT_SYMBOL (acpi_map_lsapic);int acpi_unmap_lsapic (int cpu)
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 x86: fix section mismatch warning in kernel/pci-calgary
In reply to Sam RavnborgFix following warning:
WARNING: arch/x86/kernel/built-in.o(.text+0x1eb41): Section mismatch in reference from the function calgary_handle_quirks() to the function .init.text:calgary_set_split_completion_timeout()
calgary_handle_quirks() are only called at__init time (in calgary_init_one() via handle_quirks ops). So annotate this function and the sister function __init.
--- arch/x86/kernel/pci-calgary_64.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/pci-calgary_64.c +2 -2
@@ -1006,7 +1006,7 @@ static void __init calgary_set_split_completion_timeout(void __iomem *bbar,readq (target);/* flush */ } -static void calioc2_handle_quirks (struct iommu_table *tbl,struct pci_dev *dev) +static void __init calioc2_handle_quirks (struct iommu_table *tbl,struct pci_dev *dev) {unsigned char busnum = dev->bus->number;void __iomem *bbar = tbl->bbar;
@@ -1022,7 +1022,7 @@ static void calioc2_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev)writel (cpu_to_be32 (val), target); } -static void calgary_handle_quirks (struct iommu_table *tbl,struct pci_dev *dev) +static void __init calgary_handle_quirks (struct iommu_table *tbl,struct pci_dev *dev) {unsigned char busnum = dev->bus->number;
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 mm: fix section mismatch warning in sparse.c
In reply to Sam RavnborgFix following warning:
WARNING: mm/built-in.o(.text+0x22069): Section mismatch in reference from the function sparse_early_usemap_alloc() to the function .init.text:__alloc_bootmem_node()
static sparse_early_usemap_alloc() were used only by sparse_init() and with sparse_init() annotated _init it is safe to annotate sparse_early_usemap_alloc with __init too.
--- mm/sparse.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
mm/sparse.c +1 -1
@@ -237,7 +237,7 @@ static unsigned long *__kmalloc_section_usemap(void) }#endif /* CONFIG_MEMORY_HOTPLUG */ -static unsigned long *sparse_early_usemap_alloc (unsigned long pnum) +static unsigned long *__init sparse_early_usemap_alloc (unsigned long pnum) {unsigned long *usemap;struct mem_section *ms =__nr_to_section (pnum);
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 cpu: fix section mismatch related to cpu_chain
In reply to Sam RavnborgFix following warnings:
WARNING: o-x86_64/kernel/built-in.o(.text+0x36de9): Section mismatch in reference from the function take_cpu_down() to the variable .cpuinit.data:cpu_chain
WARNING: o-x86_64/kernel/built-in.o(.text+0x36e86): Section mismatch in reference from the function _cpu_down() to the variable .cpuinit.data:cpu_chain
WARNING: o-x86_64/kernel/built-in.o(.text+0x36ea9): Section mismatch in reference from the function _cpu_down() to the variable .cpuinit.data:cpu_chain
WARNING: o-x86_64/kernel/built-in.o(.text+0x36f40): Section mismatch in reference from the function _cpu_down() to the variable .cpuinit.data:cpu_chain
WARNING: o-x86_64/kernel/built-in.o(.text+0x36f8f): Section mismatch in reference from the function _cpu_down() to the variable .cpuinit.data:cpu_chain
WARNING: o-x86_64/kernel/built-in.o(.text+0x370aa): Section mismatch in reference from the function unregister_cpu_notifier() to the variable .cpuinit.data:cpu_chain
cpu_chain is used by unregister_cpu_notifier() that is used by the kvm module. So we can call the unregister_cpu_notifier() long after init completed.
Drop the __cpuinitdata annotation to avoid freeing cpu_chain.
--- kernel/cpu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cpu.c +1 -1
@@ -18,7 +18,7 @@/* Serializes the updates to cpu_online_map, cpu_present_map */ static DEFINE_MUTEX (cpu_add_remove_lock); -static __cpuinitdata RAW_NOTIFIER_HEAD (cpu_chain); +static RAW_NOTIFIER_HEAD (cpu_chain);/* If set, cpu_up and cpu_down will return -EBUSY and do nothing. * Should always be manipulated under cpu_add_remove_lock
Signature · 1 line
1.5.4.rc3.14.g44397
PATCH 1/1 x86: fix section mismatch warnings when referencing notifiers
In reply to Sam RavnborgFix the following warnings:
WARNING: arch/x86/kernel/built-in.o(.exit.text+0xf8): Section mismatch in reference from the function msr_exit() to the variable .cpuinit.data:msr_class_cpu_notifier
WARNING: arch/x86/kernel/built-in.o(.exit.text+0x158): Section mismatch in reference from the function cpuid_exit() to the variable .cpuinit.data:cpuid_class_cpu_notifier
WARNING: arch/x86/kernel/built-in.o(.exit.text+0x171): Section mismatch in reference from the function microcode_exit() to the variable .cpuinit.data:mc_cpu_notifier
In all three cases there were a function annotated __exit that referenced a variable annotated __cpuinitdata.
The fix was to replace the annotation of the notifier with __refdata to tell modpost that the reference to a _cpuinit function in the notifier are OK. The unregister call that references the notifier variable will simple delete the function pointer so there is no problem ignoring the reference.
Note: This looks like another case where __cpuinit has been used as replacement for proper use of CONFIG_HOTPLUG_CPU to decide what code are used for HOTPLUG_CPU.
--- arch/x86/kernel/cpuid.c | 2 +- arch/x86/kernel/microcode.c | 2 +- arch/x86/kernel/msr.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpuid.c +1 -1
@@ -170,7 +170,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,return err ?NOTIFY_BAD :NOTIFY_OK ; } -static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier = +static struct notifier_block __refdata cpuid_class_cpu_notifier = { .notifier_call = cpuid_class_cpu_callback, };
arch/x86/kernel/microcode.c +1 -1
@@ -797,7 +797,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)return NOTIFY_OK ; } -static struct notifier_block __cpuinitdata mc_cpu_notifier = { +static struct notifier_block __refdata mc_cpu_notifier = { .notifier_call = mc_cpu_callback, };
arch/x86/kernel/msr.c +1 -1
@@ -168,7 +168,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,return err ?NOTIFY_BAD :NOTIFY_OK ; } -static struct notifier_block __cpuinitdata msr_class_cpu_notifier = { +static struct notifier_block __refdata msr_class_cpu_notifier = { .notifier_call = msr_class_cpu_callback, };
Signature · 1 line
1.5.4.rc3.14.g44397
Quoted 4 lines · Sam Ravnborg
x86: fix section mismatch warning in
acpi/boot.c
x86: silence section mismatch warning insmpboot_64.c
x86: fix section mismatch warning inkernel/pci-calgary
x86: fix section mismatch warnings when referencing notifiers
thanks Sam, i've applied your 4 x86 related fixes to x86.git.
Ingo