2024-01-04 09:57:07

by Thomas Zimmermann

[permalink] [raw]
Subject: [PATCH v3 0/4] arch/x86: Remove unnecessary dependencies on bootparam.h

Reduce built time in some cases by removing unnecessary include statements
for <asm/bootparam.h>. Reorganize some header files accordingly.

While working on the kernel's boot-up graphics, I noticed that touching
include/linux/screen_info.h triggers a complete rebuild of the kernel
on x86. It turns out that the architecture's PCI and EFI headers include
<asm/bootparam.h>, which depends on <linux/screen_info.h>. But none of
the drivers have any business with boot parameters or the screen_info
state.

The patchset moves code from bootparam.h and efi.h into separate header
files and removes obsolete include statements on x86. I did

make allmodconfig
make -j28
touch include/linux/screen_info.h
time make -j28

to measure the time it takes to rebuild. Results without the patchset
are around 20 minutes.

real 20m46,705s
user 354m29,166s
sys 28m27,359s

And with the patchset applied it goes down to less than one minute.

real 0m56,643s
user 4m0,661s
sys 0m32,956s

The test system is an Intel i5-13500.

v3:
* keep setup_header in bootparam.h (Ard)
* implement arch_ima_efi_boot_mode() in source file (Ard)
v2:
* only keep struct boot_params in bootparam.h (Ard)
* simplify arch_ima_efi_boot_mode define (Ard)
* updated cover letter

Thomas Zimmermann (4):
arch/x86: Move UAPI setup structures into setup_data.h
arch/x86: Move internal setup_data structures into setup_data.h
arch/x86: Implement arch_ima_efi_boot_mode() in source file
arch/x86: Do not include <asm/bootparam.h> in several files

arch/x86/boot/compressed/acpi.c | 2 +
arch/x86/boot/compressed/cmdline.c | 2 +
arch/x86/boot/compressed/efi.c | 2 +
arch/x86/boot/compressed/efi.h | 9 ---
arch/x86/boot/compressed/misc.h | 3 +-
arch/x86/boot/compressed/pgtable_64.c | 1 +
arch/x86/boot/compressed/sev.c | 1 +
arch/x86/include/asm/efi.h | 14 +----
arch/x86/include/asm/kexec.h | 1 -
arch/x86/include/asm/mem_encrypt.h | 2 +-
arch/x86/include/asm/pci.h | 13 ----
arch/x86/include/asm/setup_data.h | 32 ++++++++++
arch/x86/include/asm/sev.h | 3 +-
arch/x86/include/asm/x86_init.h | 2 -
arch/x86/include/uapi/asm/bootparam.h | 72 +---------------------
arch/x86/include/uapi/asm/setup_data.h | 83 ++++++++++++++++++++++++++
arch/x86/kernel/crash.c | 1 +
arch/x86/kernel/sev-shared.c | 2 +
arch/x86/platform/efi/efi.c | 5 ++
arch/x86/platform/pvh/enlighten.c | 1 +
arch/x86/xen/enlighten_pvh.c | 1 +
arch/x86/xen/vga.c | 1 -
22 files changed, 142 insertions(+), 111 deletions(-)
create mode 100644 arch/x86/include/asm/setup_data.h
create mode 100644 arch/x86/include/uapi/asm/setup_data.h


base-commit: 25232eb8a9ac7fa0dac7e846a4bf7fba2b6db39a
prerequisite-patch-id: 0aa359f6144c4015c140c8a6750be19099c676fb
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
prerequisite-patch-id: cbc453ee02fae02af22fbfdce56ab732c7a88c36
prerequisite-patch-id: e7a5405fb48608e0c8e3b41bf983fefa2c8bd1f3
prerequisite-patch-id: f12b8b5465e519f8588e3743e70166be3294009b
prerequisite-patch-id: c3de42afb37f6240a840f8b12504262d4483873c
prerequisite-patch-id: 5f31d981a18037906b0e422c0a1031e7dff91a2d
prerequisite-patch-id: 2345c90842ae2a9117d21b9bd205fe3b89e89c20
--
2.43.0



2024-01-04 09:57:52

by Thomas Zimmermann

[permalink] [raw]
Subject: [PATCH v3 2/4] arch/x86: Move internal setup_data structures into setup_data.h

The type definition of struct pci_setup_rom in <asm/pci.h> requires
struct setup_data from <asm/bootparam.h>. Many drivers include
<linux/pci.h>, but do not use boot parameters. Changes to bootparam.h
or its included header files could easily trigger a large, unnecessary
rebuild of the kernel.

Moving struct pci_setup_rom into its own header file avoids including
<asm/bootparam.h> in <asm/pci.h>. Moving struct_efi_setup_data allows
to unify duplicated definition of the data structure in a single place.

Signed-off-by: Thomas Zimmermann <[email protected]>
---
arch/x86/boot/compressed/efi.h | 9 ---------
arch/x86/include/asm/efi.h | 9 ---------
arch/x86/include/asm/pci.h | 13 -------------
arch/x86/include/asm/setup_data.h | 32 +++++++++++++++++++++++++++++++
4 files changed, 32 insertions(+), 31 deletions(-)
create mode 100644 arch/x86/include/asm/setup_data.h

diff --git a/arch/x86/boot/compressed/efi.h b/arch/x86/boot/compressed/efi.h
index 866c0af8b5b9..b22300970f97 100644
--- a/arch/x86/boot/compressed/efi.h
+++ b/arch/x86/boot/compressed/efi.h
@@ -97,15 +97,6 @@ typedef struct {
u32 tables;
} efi_system_table_32_t;

-/* kexec external ABI */
-struct efi_setup_data {
- u64 fw_vendor;
- u64 __unused;
- u64 tables;
- u64 smbios;
- u64 reserved[8];
-};
-
struct efi_unaccepted_memory {
u32 version;
u32 unit_size;
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index c4555b269a1b..a5d7a83e4c2a 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -143,15 +143,6 @@ extern void efi_free_boot_services(void);
void arch_efi_call_virt_setup(void);
void arch_efi_call_virt_teardown(void);

-/* kexec external ABI */
-struct efi_setup_data {
- u64 fw_vendor;
- u64 __unused;
- u64 tables;
- u64 smbios;
- u64 reserved[8];
-};
-
extern u64 efi_setup;

#ifdef CONFIG_EFI
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index f6100df3652e..b3ab80a03365 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -10,7 +10,6 @@
#include <linux/numa.h>
#include <asm/io.h>
#include <asm/memtype.h>
-#include <asm/setup_data.h>

struct pci_sysdata {
int domain; /* PCI domain */
@@ -124,16 +123,4 @@ cpumask_of_pcibus(const struct pci_bus *bus)
}
#endif

-struct pci_setup_rom {
- struct setup_data data;
- uint16_t vendor;
- uint16_t devid;
- uint64_t pcilen;
- unsigned long segment;
- unsigned long bus;
- unsigned long device;
- unsigned long function;
- uint8_t romdata[];
-};
-
#endif /* _ASM_X86_PCI_H */
diff --git a/arch/x86/include/asm/setup_data.h b/arch/x86/include/asm/setup_data.h
new file mode 100644
index 000000000000..77c51111a893
--- /dev/null
+++ b/arch/x86/include/asm/setup_data.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_SETUP_DATA_H
+#define _ASM_X86_SETUP_DATA_H
+
+#include <uapi/asm/setup_data.h>
+
+#ifndef __ASSEMBLY__
+
+struct pci_setup_rom {
+ struct setup_data data;
+ uint16_t vendor;
+ uint16_t devid;
+ uint64_t pcilen;
+ unsigned long segment;
+ unsigned long bus;
+ unsigned long device;
+ unsigned long function;
+ uint8_t romdata[];
+};
+
+/* kexec external ABI */
+struct efi_setup_data {
+ u64 fw_vendor;
+ u64 __unused;
+ u64 tables;
+ u64 smbios;
+ u64 reserved[8];
+};
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _ASM_X86_SETUP_DATA_H */
--
2.43.0