Skip to contentSkip to conversation

kbuild: various cleanups

PATCH Superseded Masahiro Yamada 7 participants 28 messages Sep 6, 2022 – Sep 24, 2022

Subsystems (26)
Documentation Arm (32-bit) x86 SCSI +22 more subsystems

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover kbuild: various cleanups

- Refactor single target build to make it work more correctly
- Link vmlinux and modules in parallel
- Remove head-y syntax

Masahiro Yamada (8):
kbuild: fix and refactor single target build
kbuild: rename modules.order in sub-directories to .modules.order
kbuild: move core-y and drivers-y to ./Kbuild
kbuild: move .vmlinux.objs rule to Makefile.modpost
kbuild: move vmlinux.o rule to the top Makefile
kbuild: unify two modpost invocations
kbuild: use obj-y instead extra-y for objects placed at the head
kbuild: remove head-y syntax

 Documentation/kbuild/makefiles.rst          |  27 ++---
 Kbuild                                      |  23 ++++
 Makefile                                    | 113 ++++++++++++--------
 arch/alpha/Makefile                         |   2 -
 arch/alpha/kernel/Makefile                  |   4 +-
 arch/arc/Makefile                           |   2 -
 arch/arc/kernel/Makefile                    |   4 +-
 arch/arm/Makefile                           |   3 -
 arch/arm/kernel/Makefile                    |   4 +-
 arch/arm64/Makefile                         |   3 -
 arch/arm64/kernel/Makefile                  |   4 +-
 arch/csky/Makefile                          |   2 -
 arch/csky/kernel/Makefile                   |   4 +-
 arch/hexagon/Makefile                       |   2 -
 arch/hexagon/kernel/Makefile                |   3 +-
 arch/ia64/Makefile                          |   1 -
 arch/ia64/kernel/Makefile                   |   4 +-
 arch/loongarch/Makefile                     |   2 -
 arch/loongarch/kernel/Makefile              |   4 +-
 arch/m68k/68000/Makefile                    |   2 +-
 arch/m68k/Makefile                          |   9 --
 arch/m68k/coldfire/Makefile                 |   2 +-
 arch/m68k/kernel/Makefile                   |  21 ++--
 arch/microblaze/Makefile                    |   1 -
 arch/microblaze/kernel/Makefile             |   4 +-
 arch/mips/Makefile                          |   2 -
 arch/mips/kernel/Makefile                   |   4 +-
 arch/nios2/Makefile                         |   1 -
 arch/nios2/kernel/Makefile                  |   2 +-
 arch/openrisc/Makefile                      |   2 -
 arch/openrisc/kernel/Makefile               |   4 +-
 arch/parisc/Makefile                        |   2 -
 arch/parisc/kernel/Makefile                 |   4 +-
 arch/powerpc/Makefile                       |  12 ---
 arch/powerpc/kernel/Makefile                |  22 ++--
 arch/riscv/Makefile                         |   2 -
 arch/riscv/kernel/Makefile                  |   2 +-
 arch/s390/Makefile                          |   2 -
 arch/s390/kernel/Makefile                   |   4 +-
 arch/sh/Makefile                            |   2 -
 arch/sh/kernel/Makefile                     |   4 +-
 arch/sparc/Makefile                         |   2 -
 arch/sparc/kernel/Makefile                  |   3 +-
 arch/x86/Makefile                           |   5 -
 arch/x86/kernel/Makefile                    |  10 +-
 arch/xtensa/Makefile                        |   2 -
 arch/xtensa/kernel/Makefile                 |   4 +-
 scripts/Makefile.build                      |  70 +++++-------
 scripts/Makefile.lib                        |  10 +-
 scripts/Makefile.modfinal                   |   2 +-
 scripts/Makefile.modpost                    | 112 +++++++++----------
 scripts/Makefile.vmlinux_o                  |   6 +-
 scripts/clang-tools/gen_compile_commands.py |  19 +---
 scripts/head-object-list.txt                |  53 +++++++++
 scripts/link-vmlinux.sh                     |  34 +-----
 55 files changed, 304 insertions(+), 349 deletions(-)
 create mode 100644 scripts/head-object-list.txt
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/8 kbuild: fix and refactor single target build

The single target build has a subtle bug for the combination for an individual file and a subdirectory.

[1] 'make kernel/fork.i' builds only kernel/fork.i

  $ make kernel/fork.i
    CALL    scripts/checksyscalls.sh
    DESCEND objtool
    CPP     kernel/fork.i

[2] 'make kernel/' builds only under the kernel/ directory.

  $ make kernel/
    CALL    scripts/checksyscalls.sh
    DESCEND objtool
    CC      kernel/fork.o
    CC      kernel/exec_domain.o
       [snip]
    CC      kernel/rseq.o
    AR      kernel/built-in.a

But, if you try to do [1] and [2] in a single command, you will get only [1] with a weird log:

  $ make kernel/fork.i kernel/
    CALL    scripts/checksyscalls.sh
    DESCEND objtool
    CPP     kernel/fork.i
  make[2]: Nothing to be done for 'kernel/'.

With 'make kernel/fork.i kernel/', you should get both [1] and [2].

Rewrite the single target build.

---

Changes in v2:
- New

 Makefile               |  9 ++++---
 scripts/Makefile.build | 54 +++++++++++++-----------------------------
 2 files changed, 20 insertions(+), 43 deletions(-)
Makefile +4 -5
index 0af9dd405fb1..373cd2f0f49e 100644
@@ -1824,11 +1824,11 @@ single_modpost: $(single-no-ko) modules_prepare
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 	$(Q)rm -f $(MODORDER)
 
-export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod_prefix), $(single-no-ko))
+single-goals := $(addprefix $(extmod_prefix), $(single-no-ko))
 
 # trim unrelated directories
 build-dirs := $(foreach d, $(build-dirs), \
-			$(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d)))
+			$(if $(filter $d/%, $(single-goals)), $d))
 
 endif
 
@@ -1840,9 +1840,8 @@ endif
 PHONY += descend $(build-dirs)
 descend: $(build-dirs)
 $(build-dirs): prepare
-	$(Q)$(MAKE) $(build)=$@ \
-	single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
-	need-builtin=1 need-modorder=1
+	$(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 \
+	$(filter $@/%, $(single-goals))
 
 clean-dirs := $(addprefix _clean_, $(clean-dirs))
 PHONY += $(clean-dirs) clean
scripts/Makefile.build +16 -38

97 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/8 kbuild: rename modules.order in sub-directories to .modules.order

In reply to Masahiro Yamada

The next commit will move core-y from the top Makefile to ./Kbuild to use obj-y to list sub-directories.

With that, both ./Makefile and ./Kbuild would create modules.order in the top directory.

To avoid the conflict, rename the per-directory modules.order to .modules.order.

---

(no changes since v1)

 Makefile               | 27 +++++++++++++--------------
 scripts/Makefile.build | 18 +++++++++---------
 scripts/Makefile.lib   |  8 ++++----
 3 files changed, 26 insertions(+), 27 deletions(-)
Makefile +13 -14
index 373cd2f0f49e..552ade93ca1d 100644
@@ -1116,8 +1116,6 @@ vmlinux-alldirs	:= $(sort $(vmlinux-dirs) Documentation . \
 build-dirs	:= $(vmlinux-dirs)
 clean-dirs	:= $(vmlinux-alldirs)
 
-subdir-modorder := $(addsuffix /modules.order, $(build-dirs))
-
 # Externally visible symbols (used by link-vmlinux.sh)
 KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
@@ -1172,7 +1170,7 @@ targets := vmlinux
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
-$(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
+$(sort $(vmlinux-deps)): descend ;
 
 filechk_kernel.release = \
 	echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@ -1444,13 +1442,6 @@ endif
 
 modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare
 
-cmd_modules_order = cat $(real-prereqs) > $@
-
-modules.order: $(subdir-modorder) FORCE
-	$(call if_changed,modules_order)
-
-targets += modules.order
-
 # Target to prepare building external modules
 modules_prepare: prepare
 	$(Q)$(MAKE) $(build)=scripts scripts/module.lds
@@ -1722,8 +1713,6 @@ KBUILD_BUILTIN :=
 KBUILD_MODULES := 1
 
 build-dirs := $(KBUILD_EXTMOD)
-$(MODORDER): descend
-	@:
 
 compile_commands.json: $(extmod_prefix)compile_commands.json
 PHONY += compile_commands.json
@@ -1755,12 +1744,22 @@ help:
 endif # KBUILD_EXTMOD
 
 # ---------------------------------------------------------------------------
-# Modules
+# Modules (common for in-tree modules and external modules)
 
 PHONY += modules modules_install modules_prepare
 
 ifdef CONFIG_MODULES
 
+subdir-modorder := $(addsuffix /.modules.order, $(build-dirs))
+
+$(sort $(subdir-modorder)): %/.modules.order: % ;
+
+cmd_modules_order = cat $(real-prereqs) > $@
+
+targets += $(MODORDER)
+$(MODORDER): $(subdir-modorder) FORCE
+	$(call if_changed,modules_order)
+
 modules: modules_check
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
@@ -1859,7 +1858,7 @@ clean: $(clean-dirs)
 		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
 		-o -name '*.lex.c' -o -name '*.tab.[ch]' \
 		-o -name '*.asn1.[ch]' \
-		-o -name '*.symtypes' -o -name 'modules.order' \
+		-o -name '*.symtypes' -o -name '*modules.order' \
 		-o -name '.tmp_*' \
 		-o -name '*.c.[012]*.*' \
 		-o -name '*.ll' \
scripts/Makefile.build +9 -9
index 91d2e5461a3e..da3dc4f5456e 100644
@@ -73,7 +73,7 @@ endif
 
 # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
 subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
-subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
+subdir-modorder := $(sort $(filter %/.modules.order, $(obj-m)))
 
 targets-for-builtin := $(extra-y)
 
@@ -89,7 +89,7 @@ targets-for-modules := $(foreach x, o mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usym
 				$(patsubst %.o, %.$x, $(filter %.o, $(obj-m))))
 
 ifdef need-modorder
-targets-for-modules += $(obj)/modules.order
+targets-for-modules += $(obj)/.modules.order
 endif
 
 targets += $(targets-for-builtin) $(targets-for-modules)
@@ -348,7 +348,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
 
 # To build objects in subdirs, we need to descend into the directories
 $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
-$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
+$(subdir-modorder): $(obj)/%/.modules.order: $(obj)/% ;
 
 #
 # Rule to compile a set of .o files into one .a file (without symbol table)
@@ -365,18 +365,18 @@ $(obj)/built-in.a: $(real-obj-y) FORCE
 	$(call if_changed,ar_builtin)
 
 #
-# Rule to create modules.order file
+# Rule to create .modules.order file
 #
-# Create commands to either record .ko file or cat modules.order from
+# Create commands to either record .ko file or cat .modules.order from
 # a subdirectory
 # Add $(obj-m) as the prerequisite to avoid updating the timestamp of
-# modules.order unless contained modules are updated.
+# .modules.order unless contained modules are updated.
 
 cmd_modules_order = { $(foreach m, $(real-prereqs), \
-	$(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \
+	$(if $(filter %/.modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \
 	> $@
 
-$(obj)/modules.order: $(obj-m) FORCE
+$(obj)/.modules.order: $(obj-m) FORCE
 	$(call if_changed,modules_order)
 
 #
@@ -439,7 +439,7 @@ PHONY += $(subdir-ym)
 $(subdir-ym):
 	$(Q)$(MAKE) $(build)=$@ \
 	need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
-	need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1) \
+	need-modorder=$(if $(filter $@/.modules.order, $(subdir-modorder)),1) \
 	$(filter $@/%, $(single-subdir-goals))
 
 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
scripts/Makefile.lib +4 -4
index 3fb6a99e78c4..b594705d571a 100644
@@ -26,14 +26,14 @@ subdir-ym := $(sort $(subdir-y) $(subdir-m) \
 
 # Handle objects in subdirs:
 # - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and
-#   foo/modules.order
-# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order
+#   foo/.modules.order
+# - If we encounter foo/ in $(obj-m), replace it by foo/.modules.order
 #
-# Generate modules.order to determine modorder. Unfortunately, we don't have
+# Generate .modules.order to determine modorder. Unfortunately, we don't have
 # information about ordering between -y and -m subdirs. Just put -y's first.
 
 ifdef need-modorder
-obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m))
+obj-m := $(patsubst %/,%/.modules.order, $(filter %/, $(obj-y)) $(obj-m))
 else
 obj-m := $(filter-out %/, $(obj-m))
 endif
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/8 kbuild: move core-y and drivers-y to ./Kbuild

In reply to Masahiro Yamada

Use the ordinary obj-y to list subdirectories.

Note1:
GNU Make seems to transform './.modules.order' to '.modules.order' before matching it against the target pattern. Split ./.modules.order to a dedicated rule to avoid "doesn't match the target pattern" warning. [1]

Note2:
Previously, the link order of lib-y depended on CONFIG_MODULES; lib-y was linked before drivers-y when CONFIG_MODULES=y, otherwise after drivers-y. This was a bug of commit 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y"), but it was not a big deal after all. Now, libs-y (all objects that come from lib/ and arch/*/lib/) is linked last, irrespective of CONFIG_MODULES.

Note3:
Now, the single target build in arch/*/lib/ works correctly. There was a bug report about this. [2]

  $ make ARCH=arm arch/arm/lib/findbit.o
    CALL    scripts/checksyscalls.sh
    AS      arch/arm/lib/findbit.o

[1]: https://lists.gnu.org/archive/html/bug-make/2022-08/msg00059.html
[2]: https://lore.kernel.org/linux-kbuild/YvUQOwL6lD4%2F5%[email protected]/

---

Changes in v2:
- Move all core-y and drivers-y
- Fix single target build

 Kbuild               | 23 +++++++++++++++++++++++
 Makefile             | 29 +++++++++++++----------------
 scripts/Makefile.lib |  2 ++
 3 files changed, 38 insertions(+), 16 deletions(-)
Kbuild +23 -0
index 0b9e8a16a621..8854e88e0619 100644
@@ -72,3 +72,26 @@ $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/%  FORCE
 PHONY += prepare
 prepare: $(offsets-file) missing-syscalls $(atomic-checks)
 	@:
+
+# Ordinary directory descending
+# ---------------------------------------------------------------------------
+
+obj-y			+= init/
+obj-y			+= usr/
+obj-y			+= arch/$(SRCARCH)/
+obj-y			+= $(ARCH_CORE)
+obj-y			+= kernel/
+obj-y			+= certs/
+obj-y			+= mm/
+obj-y			+= fs/
+obj-y			+= ipc/
+obj-y			+= security/
+obj-y			+= crypto/
+obj-$(CONFIG_BLOCK)	+= block/
+obj-$(CONFIG_IO_URING)	+= io_uring/
+obj-y			+= drivers/
+obj-y			+= sound/
+obj-$(CONFIG_SAMPLES)	+= samples/
+obj-$(CONFIG_NET)	+= net/
+obj-y			+= virt/
+obj-y			+= $(ARCH_DRIVERS)
Makefile +13 -16
index 552ade93ca1d..ef0621d55ebb 100644
@@ -676,11 +676,8 @@ endif
 
 ifeq ($(KBUILD_EXTMOD),)
 # Objects we will link into vmlinux / subdirs we need to visit
-core-y		:= init/ usr/ arch/$(SRCARCH)/
-drivers-y	:= drivers/ sound/
-drivers-$(CONFIG_SAMPLES) += samples/
-drivers-$(CONFIG_NET) += net/
-drivers-y	+= virt/
+core-y		:=
+drivers-y	:=
 libs-y		:= lib/
 endif # KBUILD_EXTMOD
 
@@ -1101,23 +1098,20 @@ export MODORDER := $(extmod_prefix)modules.order
 export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
 
 ifeq ($(KBUILD_EXTMOD),)
-core-y			+= kernel/ certs/ mm/ fs/ ipc/ security/ crypto/
-core-$(CONFIG_BLOCK)	+= block/
-core-$(CONFIG_IO_URING)	+= io_uring/
 
-vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, \
-		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
-		     $(libs-y) $(libs-m)))
+vmlinux-dirs	:= . $(patsubst %/,%,$(filter %/, $(libs-y) $(libs-m)))
 
-vmlinux-alldirs	:= $(sort $(vmlinux-dirs) Documentation . \
+vmlinux-alldirs	:= $(sort $(vmlinux-dirs) Documentation \
 		     $(patsubst %/,%,$(filter %/, $(core-) \
 			$(drivers-) $(libs-))))
 
 build-dirs	:= $(vmlinux-dirs)
 clean-dirs	:= $(vmlinux-alldirs)
 
+export ARCH_CORE	:= $(core-y)
+export ARCH_DRIVERS	:= $(drivers-y)
 # Externally visible symbols (used by link-vmlinux.sh)
-KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
+KBUILD_VMLINUX_OBJS := $(head-y) ./built-in.a
 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
 ifdef CONFIG_MODULES
 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
@@ -1125,7 +1119,6 @@ KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
 else
 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
 endif
-KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
 
 export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
@@ -1752,7 +1745,10 @@ ifdef CONFIG_MODULES
 
 subdir-modorder := $(addsuffix /.modules.order, $(build-dirs))
 
-$(sort $(subdir-modorder)): %/.modules.order: % ;
+# Split ./.modules.order into a dedicate target to avoid
+# "doesn't match the target pattern" warning
+./.modules.order: . ;
+$(sort $(filter-out ./.modules.order, $(subdir-modorder))): %/.modules.order: % ;
 
 cmd_modules_order = cat $(real-prereqs) > $@
 
@@ -1823,7 +1819,8 @@ single_modpost: $(single-no-ko) modules_prepare
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 	$(Q)rm -f $(MODORDER)
 
-single-goals := $(addprefix $(extmod_prefix), $(single-no-ko))
+single-goals := $(foreach x, $(addprefix $(extmod_prefix), $(single-no-ko)), \
+		$(if $(filter $(addsuffix /%, $(build-dirs)), $x),,./)$x)
 
 # trim unrelated directories
 build-dirs := $(foreach d, $(build-dirs), \
scripts/Makefile.lib +2 -0
index b594705d571a..9bdc9ed37f49 100644
@@ -89,6 +89,7 @@ always-y			+= $(dtb-y)
 
 # Add subdir path
 
+ifneq ($(obj),.)
 extra-y		:= $(addprefix $(obj)/,$(extra-y))
 always-y	:= $(addprefix $(obj)/,$(always-y))
 targets		:= $(addprefix $(obj)/,$(targets))
@@ -100,6 +101,7 @@ multi-obj-m	:= $(addprefix $(obj)/, $(multi-obj-m))
 multi-dtb-y	:= $(addprefix $(obj)/, $(multi-dtb-y))
 real-dtb-y	:= $(addprefix $(obj)/, $(real-dtb-y))
 subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
+endif
 
 # Finds the multi-part object the current object will be linked into.
 # If the object belongs to two or more multi-part objects, list them all.
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v2 3/8] kbuild: move core-y and drivers-y to ./Kbuild

Hi,

Quoted 20 lines · Masahiro Yamada

Use the ordinary obj-y to list subdirectories.

Note1:
GNU Make seems to transform './.modules.order' to '.modules.order' before matching it against the target pattern. Split ./.modules.order to a dedicated rule to avoid "doesn't match the target pattern" warning. [1]

Note2:
Previously, the link order of lib-y depended on CONFIG_MODULES; lib-y was linked before drivers-y when CONFIG_MODULES=y, otherwise after drivers-y. This was a bug of commit 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y"), but it was not a big deal after all. Now, libs-y (all objects that come from lib/ and arch/*/lib/) is linked last, irrespective of CONFIG_MODULES.

Note3:
Now, the single target build in arch/*/lib/ works correctly. There was a bug report about this. [2]

Quoted 8 lines
  $ make ARCH=arm arch/arm/lib/findbit.o
    CALL    scripts/checksyscalls.sh
    AS      arch/arm/lib/findbit.o

[1]: https://lists.gnu.org/archive/html/bug-make/2022-08/msg00059.html
[2]: https://lore.kernel.org/linux-kbuild/YvUQOwL6lD4%2F5%[email protected]/

With this patch in place, all parisc images crash during boot with the crash dump below. Bisect on next-20220920 points to this patch. Crash and bisect logs are attached.

Loking through boot logs, the same problem (same backtrace) is seen with various boot tests on alpha. There may be more, but -next crashes all over the place right now so it is difficult to determine the platforms affected by a specicfic problem.

Guenter

---
# bad: [ef08d387bbbc20df740ced8caee0ffac835869ac] Add linux-next specific files for 20220920
# good: [521a547ced6477c54b4b0cc206000406c221b4d6] Linux 6.0-rc6
git bisect start 'HEAD' 'v6.0-rc6'
# bad: [df970c033333b10c728198606fe787535e08ab8a] Merge branch 'drm-next' of git://git.freedesktop.org/git/drm/drm.git
git bisect bad df970c033333b10c728198606fe787535e08ab8a
# bad: [0120f1228dc162c1e00ac24b788a67cc669ff56f] Merge branch 'docs-next' of git://git.lwn.net/linux.git
git bisect bad 0120f1228dc162c1e00ac24b788a67cc669ff56f
# bad: [ed1b38e88a53a328673e1fffdd6bb69e02c34af1] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
git bisect bad ed1b38e88a53a328673e1fffdd6bb69e02c34af1
# bad: [4dd0700db9ab87d345d989c7589077d858a1f387] Merge branch 'for-next/core' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
git bisect bad 4dd0700db9ab87d345d989c7589077d858a1f387
# good: [61aa10c4f088adac94f88ba967db44ffab627aef] Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git
git bisect good 61aa10c4f088adac94f88ba967db44ffab627aef
# bad: [94c23f8f94b27223a557c88075ea063c70afc0ae] Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
git bisect bad 94c23f8f94b27223a557c88075ea063c70afc0ae
# good: [6357b3bb80d81a4ad5fe1d15f50ebe5de6c9cab2] perf intel-pt: Support itrace option flag d+e to log on error
git bisect good 6357b3bb80d81a4ad5fe1d15f50ebe5de6c9cab2
# bad: [d2ed1be371b80f97d2141cfcb0c4ecd02e550180] scripts: remove unused argument 'type'
git bisect bad d2ed1be371b80f97d2141cfcb0c4ecd02e550180
# good: [a521c97e2a63490c238865763fc86942dce8d6bb] kbuild: rewrite check-local-export in sh/awk
git bisect good a521c97e2a63490c238865763fc86942dce8d6bb
# bad: [165b718fdd8c5a9165b4485019729c0cd8728120] kbuild: unify two modpost invocations
git bisect bad 165b718fdd8c5a9165b4485019729c0cd8728120
# bad: [10d1d4b75525f3172c6930fb20445f669762ea95] kbuild: move core-y and drivers-y to ./Kbuild
git bisect bad 10d1d4b75525f3172c6930fb20445f669762ea95
# good: [fd5f5437264c05b9fc0fff4349f0564f474bdf5e] kbuild: rename modules.order in sub-directories to .modules.order
git bisect good fd5f5437264c05b9fc0fff4349f0564f474bdf5e

# first bad commit: [10d1d4b75525f3172c6930fb20445f669762ea95] kbuild: move core-y and drivers-y to ./Kbuild

---

[    1.812993] sym53c8xx 0000:00:00.0: enabling SERR and PARITY (0107 -> 0147)
[    1.816056] sym0: <895a> rev 0x0 at pci 0000:00:00.0 irq 19
[    1.823635] sym0: PA-RISC Firmware, ID 7, Fast-40, LVD, parity checking
[    1.827770] sym0: SCSI BUS has been reset.
[    1.833713] scsi host0: sym-2.2.3
[    1.845265] Backtrace:
[    1.845750]  [<10b83400>] sg_pool_alloc+0xac/0xc0
[    1.846512]  [<10ac8ba8>] __sg_alloc_table+0x16c/0x1c0
[    1.846728]  [<10b83540>] sg_alloc_table_chained+0x6c/0xec
[    1.846911]  [<106ff470>] scsi_alloc_sgtables+0x8c/0x268
[    1.847129]  [<10703d5c>] scsi_queue_rq+0xae4/0xb3c
[    1.847296]  [<1060f62c>] blk_mq_dispatch_rq_list+0x1e4/0xa2c
[    1.847538]  [<10617184>] __blk_mq_sched_dispatch_requests+0xb4/0x188
[    1.847758]  [<10617334>] blk_mq_sched_dispatch_requests+0x58/0x84
[    1.847787]  [<1060b6bc>] __blk_mq_run_hw_queue+0x78/0x108
[    1.847787]  [<1060d968>] __blk_mq_delay_run_hw_queue+0x114/0x1e0
[    1.847787]  [<1060dc64>] blk_mq_run_hw_queue+0xb0/0x12c
[    1.847787]  [<10617600>] blk_mq_sched_insert_request+0x12c/0x158
[    1.847787]  [<1060ad9c>] blk_execute_rq+0x9c/0x194
[    1.847787]  [<10700a1c>] __scsi_execute+0x130/0x1f4
[    1.847787]  [<10704d70>] scsi_probe_and_add_lun+0x214/0xc60
[    1.847787]  [<10706144>] __scsi_scan_target+0x164/0x5b4
[    1.847787]  [<10706804>] scsi_scan_host_selected+0x138/0x23c
[    1.847787]  [<107069d8>] do_scsi_scan_host+0xd0/0xf0
[    1.847787]  [<10706b98>] scsi_scan_host+0x1a0/0x1f0
[    1.847787]  [<10716ba0>] sym2_probe+0x824/0x850
[    1.847787]  [<10656110>] pci_device_probe+0x9c/0x148
[    1.847787]  [<106deee0>] really_probe+0xc4/0x34c
[    1.847787]  [<106df1c4>] __driver_probe_device+0x5c/0xbc
[    1.847787]  [<106df2c0>] driver_probe_device+0x9c/0x188
[    1.847787]  [<106dfb50>] __driver_attach+0xac/0x194
[    1.847787]  [<106dc784>] bus_for_each_dev+0x78/0xb8
[    1.847787]  [<106de698>] driver_attach+0x28/0x38
[    1.847787]  [<106de144>] bus_add_driver+0x198/0x224
[    1.847787]  [<106e05e0>] driver_register+0x98/0x168
[    1.847787]  [<106555d0>] __pci_register_driver+0x80/0x94
[    1.847787]
[    1.847787]
[    1.847787] Kernel Fault: Code=26 (Data memory access rights trap) at addr 0000002c
[    1.847787] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc6-next-20220920-32bit #1
[    1.847787] Hardware name: 9000/778/B160L
[    1.847787]
[    1.847787]      YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
[    1.847787] PSW: 00000000000001001011111100001111 Not tainted
[    1.847787] r00-03  0004bf0f 1183d400 10b83400 1183d440
[    1.847787] r04-07  00000000 00092820 00092820 00000080
[    1.847787] r08-11  00000000 00000034 00000002 11830000
[    1.847787] r12-15  000001f4 10db0000 1204f128 00000001
[    1.847787] r16-19  11beb200 1204f038 1183d0c8 00000080
[    1.847787] r20-23  00000820 00000001 10b83354 00000000
[    1.847787] r24-27  00000080 00000820 00000000 10e42e18
[    1.847787] r28-31  00092000 0000000f 1183d4c0 10ac8ba8
[    1.847787] sr00-03  00000000 00000000 00000000 00000000
[    1.847787] sr04-07  00000000 00000000 00000000 00000000
[    1.847787]
[    1.847787] IASQ: 00000000 00000000 IAOQ: 102bce5c 102bce60
[    1.847787]  IIR: 48960058    ISR: 00000000  IOR: 0000002c
[    1.847787]  CPU:        0   CR30: 11830000 CR31: 00000000
[    1.847787]  ORIG_R28: 86b51896
[    1.847787]  IAOQ[0]: mempool_alloc+0x78/0x1a8
[    1.847787]  IAOQ[1]: mempool_alloc+0x7c/0x1a8
[    1.847787]  RP(r2): sg_pool_alloc+0xac/0xc0
[    1.847787] Backtrace:
[    1.847787]  [<10b83400>] sg_pool_alloc+0xac/0xc0
[    1.847787]  [<10ac8ba8>] __sg_alloc_table+0x16c/0x1c0
[    1.847787]  [<10b83540>] sg_alloc_table_chained+0x6c/0xec
[    1.847787]  [<106ff470>] scsi_alloc_sgtables+0x8c/0x268
[    1.847787]  [<10703d5c>] scsi_queue_rq+0xae4/0xb3c
[    1.847787]  [<1060f62c>] blk_mq_dispatch_rq_list+0x1e4/0xa2c
[    1.847787]  [<10617184>] __blk_mq_sched_dispatch_requests+0xb4/0x188
[    1.847787]  [<10617334>] blk_mq_sched_dispatch_requests+0x58/0x84
[    1.847787]  [<1060b6bc>] __blk_mq_run_hw_queue+0x78/0x108
[    1.847787]  [<1060d968>] __blk_mq_delay_run_hw_queue+0x114/0x1e0
[    1.847787]  [<1060dc64>] blk_mq_run_hw_queue+0xb0/0x12c
[    1.847787]  [<10617600>] blk_mq_sched_insert_request+0x12c/0x158
[    1.847787]  [<1060ad9c>] blk_execute_rq+0x9c/0x194
[    1.847787]  [<10700a1c>] __scsi_execute+0x130/0x1f4
[    1.847787]  [<10704d70>] scsi_probe_and_add_lun+0x214/0xc60
[    1.847787]  [<10706144>] __scsi_scan_target+0x164/0x5b4
[    1.847787]  [<10706804>] scsi_scan_host_selected+0x138/0x23c
[    1.847787]  [<107069d8>] do_scsi_scan_host+0xd0/0xf0
[    1.847787]  [<10706b98>] scsi_scan_host+0x1a0/0x1f0
[    1.847787]  [<10716ba0>] sym2_probe+0x824/0x850
[    1.847787]  [<10656110>] pci_device_probe+0x9c/0x148
[    1.847787]  [<106deee0>] really_probe+0xc4/0x34c
[    1.847787]  [<106df1c4>] __driver_probe_device+0x5c/0xbc
[    1.847787]  [<106df2c0>] driver_probe_device+0x9c/0x188
[    1.847787]  [<106dfb50>] __driver_attach+0xac/0x194
[    1.847787]  [<106dc784>] bus_for_each_dev+0x78/0xb8
[    1.847787]  [<106de698>] driver_attach+0x28/0x38
[    1.847787]  [<106de144>] bus_add_driver+0x198/0x224
[    1.847787]  [<106e05e0>] driver_register+0x98/0x168
[    1.847787]  [<106555d0>] __pci_register_driver+0x80/0x94
[    1.847787]
[    1.847787] Kernel panic - not syncing: Kernel Fault
#5 lore raw

Re: [PATCH v2 3/8] kbuild: move core-y and drivers-y to ./Kbuild

Hi All,

Quoted 29 lines · Guenter Roeck
Quoted 20 lines · Masahiro Yamada

Use the ordinary obj-y to list subdirectories.

Note1:
GNU Make seems to transform './.modules.order' to '.modules.order' before matching it against the target pattern. Split ./.modules.order to a dedicated rule to avoid "doesn't match the target pattern" warning. [1]

Note2:
Previously, the link order of lib-y depended on CONFIG_MODULES; lib-y was linked before drivers-y when CONFIG_MODULES=y, otherwise after drivers-y. This was a bug of commit 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y"), but it was not a big deal after all. Now, libs-y (all objects that come from lib/ and arch/*/lib/) is linked last, irrespective of CONFIG_MODULES.

Note3:
Now, the single target build in arch/*/lib/ works correctly. There was a bug report about this. [2]

Quoted 8 lines
   $ make ARCH=arm arch/arm/lib/findbit.o
     CALL    scripts/checksyscalls.sh
     AS      arch/arm/lib/findbit.o

[1]: https://lists.gnu.org/archive/html/bug-make/2022-08/msg00059.html
[2]: https://lore.kernel.org/linux-kbuild/YvUQOwL6lD4%2F5%[email protected]/

Quoted 8 lines

With this patch in place, all parisc images crash during boot with the crash dump below. Bisect on next-20220920 points to this patch. Crash and bisect logs are attached.

Loking through boot logs, the same problem (same backtrace) is seen with various boot tests on alpha. There may be more, but -next crashes all over the place right now so it is difficult to determine the platforms affected by a specicfic problem.

I confirm this. I've observed similar issue recently (from time to time) on the ARM 32bit based Exynos5250-based Arndale board. 'git bisect' lead me also to this change. A short investigation revealed that the issue is caused by the NULL sgp->pool in lib/sg_pool.c:sg_pool_alloc() function. Sometimes it works fine, sometimes not. It looks that there is a race in the sg_pools and scsi initialization somehow after this patch.

To confirm that this change is really responsible for the issue I've tried to revert it on top of linux-next. This is however hard due to the dependencies. Instead I've only did:

# git revert -m1 6fb5a32d95a9b1a9d4a6e135404468a8d74cfde6

on top of the linux next-20220921 and resolved the conflict (trivial to resolve). After that the kernel boots fine and I was not able to reproduce the issue.

The issue I've observed was:

ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
ata1.00: HPA detected: current 117229295, native 117231408 ata1.00: ATA-8: Corsair CSSD-F60GB2, 1.1, max UDMA/133
ata1.00: 117229295 sectors, multi 1: LBA48 NCQ (depth 32) ata1.00: configured for UDMA/133
scsi 0:0:0:0: Direct-Access     ATA      Corsair CSSD-F60 1.1  PQ: 0 ANSI: 5 sd 0:0:0:0: [sda] 117229295 512-byte logical blocks: (60.0 GB/55.9 GiB) sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Preferred minimum I/O size 512 bytes
8<--- cut here ---

Unable to handle kernel NULL pointer dereference at virtual address 00000034

usb3503 usb-hub: switched to HUB mode [00000034] *pgd=00000000
usb3503 usb-hub: usb3503_probe: probed in hub mode UDC core: g_ether: couldn't find an available UDC

Internal error: Oops: 5 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0 PID: 7 Comm: kworker/0:0H Not tainted 
6.0.0-rc5-00016-g10d1d4b75525 #12835
Hardware name: Samsung Exynos (Flattened Device Tree)
Workqueue: kblockd blk_mq_run_work_fn
PC is at mempool_alloc+0x48/0x14c
LR is at mempool_alloc+0x2c/0x14c
pc : [<c0267a2c>]    lr : [<c0267a10>]    psr: 40000013

...
Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 4000406a  DAC: 00000051
...
Process kworker/0:0H (pid: 7, stack limit = 0x(ptrval))

Stack: (0xf0839cc8 to 0xf083a000)

...
 mempool_alloc from __sg_alloc_table+0x120/0x160 __sg_alloc_table from sg_alloc_table_chained+0x5c/0xc0 sg_alloc_table_chained from scsi_alloc_sgtables+0x5c/0x294 scsi_alloc_sgtables from sd_init_command+0x118/0x908 sd_init_command from scsi_queue_rq+0x360/0xbe0
 scsi_queue_rq from blk_mq_dispatch_rq_list+0x1d8/0x8c8 blk_mq_dispatch_rq_list from blk_mq_do_dispatch_sched+0x2e0/0x338 blk_mq_do_dispatch_sched from __blk_mq_sched_dispatch_requests+0xa8/0x150 __blk_mq_sched_dispatch_requests from

blk_mq_sched_dispatch_requests+0x34/0x5c
  blk_mq_sched_dispatch_requests from __blk_mq_run_hw_queue+0x88/0x22c
  __blk_mq_run_hw_queue from process_one_work+0x288/0x778
  process_one_work from worker_thread+0x44/0x504
  worker_thread from kthread+0xf0/0x124
  kthread from ret_from_fork+0x14/0x2c
Exception stack(0xf0839fb0 to 0xf0839ff8)

9fa0:                                     00000000 00000000 00000000 00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000

Code: e30ea764 e3c44d11 e34ca017 e3844a92 (e5953034)
---[ end trace 0000000000000000 ]---
Quoted 121 lines

Guenter

---
# bad: [ef08d387bbbc20df740ced8caee0ffac835869ac] Add linux-next specific files for 20220920
# good: [521a547ced6477c54b4b0cc206000406c221b4d6] Linux 6.0-rc6
git bisect start 'HEAD' 'v6.0-rc6'
# bad: [df970c033333b10c728198606fe787535e08ab8a] Merge branch 'drm-next' of git://git.freedesktop.org/git/drm/drm.git
git bisect bad df970c033333b10c728198606fe787535e08ab8a
# bad: [0120f1228dc162c1e00ac24b788a67cc669ff56f] Merge branch 'docs-next' of git://git.lwn.net/linux.git
git bisect bad 0120f1228dc162c1e00ac24b788a67cc669ff56f
# bad: [ed1b38e88a53a328673e1fffdd6bb69e02c34af1] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
git bisect bad ed1b38e88a53a328673e1fffdd6bb69e02c34af1
# bad: [4dd0700db9ab87d345d989c7589077d858a1f387] Merge branch 'for-next/core' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
git bisect bad 4dd0700db9ab87d345d989c7589077d858a1f387
# good: [61aa10c4f088adac94f88ba967db44ffab627aef] Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git
git bisect good 61aa10c4f088adac94f88ba967db44ffab627aef
# bad: [94c23f8f94b27223a557c88075ea063c70afc0ae] Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
git bisect bad 94c23f8f94b27223a557c88075ea063c70afc0ae
# good: [6357b3bb80d81a4ad5fe1d15f50ebe5de6c9cab2] perf intel-pt: Support itrace option flag d+e to log on error
git bisect good 6357b3bb80d81a4ad5fe1d15f50ebe5de6c9cab2
# bad: [d2ed1be371b80f97d2141cfcb0c4ecd02e550180] scripts: remove unused argument 'type'
git bisect bad d2ed1be371b80f97d2141cfcb0c4ecd02e550180
# good: [a521c97e2a63490c238865763fc86942dce8d6bb] kbuild: rewrite check-local-export in sh/awk
git bisect good a521c97e2a63490c238865763fc86942dce8d6bb
# bad: [165b718fdd8c5a9165b4485019729c0cd8728120] kbuild: unify two modpost invocations
git bisect bad 165b718fdd8c5a9165b4485019729c0cd8728120
# bad: [10d1d4b75525f3172c6930fb20445f669762ea95] kbuild: move core-y and drivers-y to ./Kbuild
git bisect bad 10d1d4b75525f3172c6930fb20445f669762ea95
# good: [fd5f5437264c05b9fc0fff4349f0564f474bdf5e] kbuild: rename modules.order in sub-directories to .modules.order
git bisect good fd5f5437264c05b9fc0fff4349f0564f474bdf5e

# first bad commit: [10d1d4b75525f3172c6930fb20445f669762ea95] kbuild: move core-y and drivers-y to ./Kbuild

---

[    1.812993] sym53c8xx 0000:00:00.0: enabling SERR and PARITY (0107 -> 0147)
[    1.816056] sym0: <895a> rev 0x0 at pci 0000:00:00.0 irq 19
[    1.823635] sym0: PA-RISC Firmware, ID 7, Fast-40, LVD, parity checking
[    1.827770] sym0: SCSI BUS has been reset.
[    1.833713] scsi host0: sym-2.2.3
[    1.845265] Backtrace:
[    1.845750]  [<10b83400>] sg_pool_alloc+0xac/0xc0
[    1.846512]  [<10ac8ba8>] __sg_alloc_table+0x16c/0x1c0
[    1.846728]  [<10b83540>] sg_alloc_table_chained+0x6c/0xec
[    1.846911]  [<106ff470>] scsi_alloc_sgtables+0x8c/0x268
[    1.847129]  [<10703d5c>] scsi_queue_rq+0xae4/0xb3c
[    1.847296]  [<1060f62c>] blk_mq_dispatch_rq_list+0x1e4/0xa2c
[    1.847538]  [<10617184>] __blk_mq_sched_dispatch_requests+0xb4/0x188
[    1.847758]  [<10617334>] blk_mq_sched_dispatch_requests+0x58/0x84
[    1.847787]  [<1060b6bc>] __blk_mq_run_hw_queue+0x78/0x108
[    1.847787]  [<1060d968>] __blk_mq_delay_run_hw_queue+0x114/0x1e0
[    1.847787]  [<1060dc64>] blk_mq_run_hw_queue+0xb0/0x12c
[    1.847787]  [<10617600>] blk_mq_sched_insert_request+0x12c/0x158
[    1.847787]  [<1060ad9c>] blk_execute_rq+0x9c/0x194
[    1.847787]  [<10700a1c>] __scsi_execute+0x130/0x1f4
[    1.847787]  [<10704d70>] scsi_probe_and_add_lun+0x214/0xc60
[    1.847787]  [<10706144>] __scsi_scan_target+0x164/0x5b4
[    1.847787]  [<10706804>] scsi_scan_host_selected+0x138/0x23c
[    1.847787]  [<107069d8>] do_scsi_scan_host+0xd0/0xf0
[    1.847787]  [<10706b98>] scsi_scan_host+0x1a0/0x1f0
[    1.847787]  [<10716ba0>] sym2_probe+0x824/0x850
[    1.847787]  [<10656110>] pci_device_probe+0x9c/0x148
[    1.847787]  [<106deee0>] really_probe+0xc4/0x34c
[    1.847787]  [<106df1c4>] __driver_probe_device+0x5c/0xbc
[    1.847787]  [<106df2c0>] driver_probe_device+0x9c/0x188
[    1.847787]  [<106dfb50>] __driver_attach+0xac/0x194
[    1.847787]  [<106dc784>] bus_for_each_dev+0x78/0xb8
[    1.847787]  [<106de698>] driver_attach+0x28/0x38
[    1.847787]  [<106de144>] bus_add_driver+0x198/0x224
[    1.847787]  [<106e05e0>] driver_register+0x98/0x168
[    1.847787]  [<106555d0>] __pci_register_driver+0x80/0x94
[    1.847787]
[    1.847787]
[    1.847787] Kernel Fault: Code=26 (Data memory access rights trap) at addr 0000002c
[    1.847787] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc6-next-20220920-32bit #1
[    1.847787] Hardware name: 9000/778/B160L
[    1.847787]
[    1.847787]      YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
[    1.847787] PSW: 00000000000001001011111100001111 Not tainted
[    1.847787] r00-03  0004bf0f 1183d400 10b83400 1183d440
[    1.847787] r04-07  00000000 00092820 00092820 00000080
[    1.847787] r08-11  00000000 00000034 00000002 11830000
[    1.847787] r12-15  000001f4 10db0000 1204f128 00000001
[    1.847787] r16-19  11beb200 1204f038 1183d0c8 00000080
[    1.847787] r20-23  00000820 00000001 10b83354 00000000
[    1.847787] r24-27  00000080 00000820 00000000 10e42e18
[    1.847787] r28-31  00092000 0000000f 1183d4c0 10ac8ba8
[    1.847787] sr00-03  00000000 00000000 00000000 00000000
[    1.847787] sr04-07  00000000 00000000 00000000 00000000
[    1.847787]
[    1.847787] IASQ: 00000000 00000000 IAOQ: 102bce5c 102bce60
[    1.847787]  IIR: 48960058    ISR: 00000000  IOR: 0000002c
[    1.847787]  CPU:        0   CR30: 11830000 CR31: 00000000
[    1.847787]  ORIG_R28: 86b51896
[    1.847787]  IAOQ[0]: mempool_alloc+0x78/0x1a8
[    1.847787]  IAOQ[1]: mempool_alloc+0x7c/0x1a8
[    1.847787]  RP(r2): sg_pool_alloc+0xac/0xc0
[    1.847787] Backtrace:
[    1.847787]  [<10b83400>] sg_pool_alloc+0xac/0xc0
[    1.847787]  [<10ac8ba8>] __sg_alloc_table+0x16c/0x1c0
[    1.847787]  [<10b83540>] sg_alloc_table_chained+0x6c/0xec
[    1.847787]  [<106ff470>] scsi_alloc_sgtables+0x8c/0x268
[    1.847787]  [<10703d5c>] scsi_queue_rq+0xae4/0xb3c
[    1.847787]  [<1060f62c>] blk_mq_dispatch_rq_list+0x1e4/0xa2c
[    1.847787]  [<10617184>] __blk_mq_sched_dispatch_requests+0xb4/0x188
[    1.847787]  [<10617334>] blk_mq_sched_dispatch_requests+0x58/0x84
[    1.847787]  [<1060b6bc>] __blk_mq_run_hw_queue+0x78/0x108
[    1.847787]  [<1060d968>] __blk_mq_delay_run_hw_queue+0x114/0x1e0
[    1.847787]  [<1060dc64>] blk_mq_run_hw_queue+0xb0/0x12c
[    1.847787]  [<10617600>] blk_mq_sched_insert_request+0x12c/0x158
[    1.847787]  [<1060ad9c>] blk_execute_rq+0x9c/0x194
[    1.847787]  [<10700a1c>] __scsi_execute+0x130/0x1f4
[    1.847787]  [<10704d70>] scsi_probe_and_add_lun+0x214/0xc60
[    1.847787]  [<10706144>] __scsi_scan_target+0x164/0x5b4
[    1.847787]  [<10706804>] scsi_scan_host_selected+0x138/0x23c
[    1.847787]  [<107069d8>] do_scsi_scan_host+0xd0/0xf0
[    1.847787]  [<10706b98>] scsi_scan_host+0x1a0/0x1f0
[    1.847787]  [<10716ba0>] sym2_probe+0x824/0x850
[    1.847787]  [<10656110>] pci_device_probe+0x9c/0x148
[    1.847787]  [<106deee0>] really_probe+0xc4/0x34c
[    1.847787]  [<106df1c4>] __driver_probe_device+0x5c/0xbc
[    1.847787]  [<106df2c0>] driver_probe_device+0x9c/0x188
Quoted 10 lines
[    1.847787]  [<106dfb50>] __driver_attach+0xac/0x194
[    1.847787]  [<106dc784>] bus_for_each_dev+0x78/0xb8
[    1.847787]  [<106de698>] driver_attach+0x28/0x38
[    1.847787]  [<106de144>] bus_add_driver+0x198/0x224
[    1.847787]  [<106e05e0>] driver_register+0x98/0x168
[    1.847787]  [<106555d0>] __pci_register_driver+0x80/0x94
[    1.847787]
[    1.847787] Kernel panic - not syncing: Kernel Fault

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#6 lore raw

Re: [PATCH v2 3/8] kbuild: move core-y and drivers-y to ./Kbuild

Hi All,

CCed: Christoph and Robin, although this is not strictly DMA-mapping related issue...

Quoted 112 lines · Marek Szyprowski
Quoted 30 lines · Guenter Roeck
Quoted 24 lines · Masahiro Yamada

Use the ordinary obj-y to list subdirectories.

Note1:
GNU Make seems to transform './.modules.order' to '.modules.order' before matching it against the target pattern. Split ./.modules.order to a dedicated rule to avoid "doesn't match the target pattern" warning. [1]

Note2:
Previously, the link order of lib-y depended on CONFIG_MODULES; lib-y was linked before drivers-y when CONFIG_MODULES=y, otherwise after drivers-y. This was a bug of commit 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y"), but it was not a big deal after all. Now, libs-y (all objects that come from lib/ and arch/*/lib/) is linked last, irrespective of CONFIG_MODULES.

Note3:
Now, the single target build in arch/*/lib/ works correctly. There was a bug report about this. [2]

   $ make ARCH=arm arch/arm/lib/findbit.o
     CALL    scripts/checksyscalls.sh
     AS      arch/arm/lib/findbit.o
Quoted 5 lines

[1]: https://lists.gnu.org/archive/html/bug-make/2022-08/msg00059.html
[2]:
https://lore.kernel.org/linux-kbuild/YvUQOwL6lD4%2F5%[email protected]/

Quoted 8 lines

With this patch in place, all parisc images crash during boot with the crash dump below. Bisect on next-20220920 points to this patch. Crash and bisect logs are attached.

Loking through boot logs, the same problem (same backtrace) is seen with various boot tests on alpha. There may be more, but -next crashes all over the place right now so it is difficult to determine the platforms affected by a specicfic problem.

I confirm this. I've observed similar issue recently (from time to time) on the ARM 32bit based Exynos5250-based Arndale board. 'git bisect' lead me also to this change. A short investigation revealed that the issue is caused by the NULL sgp->pool in lib/sg_pool.c:sg_pool_alloc() function. Sometimes it works fine, sometimes not. It looks that there is a race in the sg_pools and scsi initialization somehow after this patch.

To confirm that this change is really responsible for the issue I've tried to revert it on top of linux-next. This is however hard due to the dependencies. Instead I've only did:

# git revert -m1 6fb5a32d95a9b1a9d4a6e135404468a8d74cfde6

on top of the linux next-20220921 and resolved the conflict (trivial to resolve). After that the kernel boots fine and I was not able to reproduce the issue.

The issue I've observed was:

ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300) ata1.00: HPA detected: current 117229295, native 117231408 ata1.00: ATA-8: Corsair CSSD-F60GB2, 1.1, max UDMA/133 ata1.00: 117229295 sectors, multi 1: LBA48 NCQ (depth 32) ata1.00: configured for UDMA/133
scsi 0:0:0:0: Direct-Access     ATA      Corsair CSSD-F60 1.1  PQ: 0
ANSI: 5
sd 0:0:0:0: [sda] 117229295 512-byte logical blocks: (60.0 GB/55.9 GiB) sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Preferred minimum I/O size 512 bytes
8<--- cut here ---

Unable to handle kernel NULL pointer dereference at virtual address 

00000034
usb3503 usb-hub: switched to HUB mode [00000034] *pgd=00000000
usb3503 usb-hub: usb3503_probe: probed in hub mode UDC core: g_ether: couldn't find an available UDC

Internal error: Oops: 5 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0 PID: 7 Comm: kworker/0:0H Not tainted 
6.0.0-rc5-00016-g10d1d4b75525 #12835
Hardware name: Samsung Exynos (Flattened Device Tree)
Workqueue: kblockd blk_mq_run_work_fn
PC is at mempool_alloc+0x48/0x14c
LR is at mempool_alloc+0x2c/0x14c
pc : [<c0267a2c>]    lr : [<c0267a10>]    psr: 40000013

...
Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: 4000406a  DAC: 00000051
...
Process kworker/0:0H (pid: 7, stack limit = 0x(ptrval))

Stack: (0xf0839cc8 to 0xf083a000)

...
 mempool_alloc from __sg_alloc_table+0x120/0x160 __sg_alloc_table from sg_alloc_table_chained+0x5c/0xc0 sg_alloc_table_chained from scsi_alloc_sgtables+0x5c/0x294 scsi_alloc_sgtables from sd_init_command+0x118/0x908 sd_init_command from scsi_queue_rq+0x360/0xbe0 scsi_queue_rq from blk_mq_dispatch_rq_list+0x1d8/0x8c8 blk_mq_dispatch_rq_list from blk_mq_do_dispatch_sched+0x2e0/0x338 blk_mq_do_dispatch_sched from __blk_mq_sched_dispatch_requests+0xa8/0x150 __blk_mq_sched_dispatch_requests from

blk_mq_sched_dispatch_requests+0x34/0x5c
 blk_mq_sched_dispatch_requests from __blk_mq_run_hw_queue+0x88/0x22c
 __blk_mq_run_hw_queue from process_one_work+0x288/0x778
 process_one_work from worker_thread+0x44/0x504
 worker_thread from kthread+0xf0/0x124
 kthread from ret_from_fork+0x14/0x2c
Exception stack(0xf0839fb0 to 0xf0839ff8)
Quoted 8 lines

9fa0:                                     00000000 00000000 00000000 00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000

Code: e30ea764 e3c44d11 e34ca017 e3844a92 (e5953034)
---[ end trace 0000000000000000 ]---

I've analyzed this issue a bit more and it looks that the $subject patch just revealed a bug in the lib/sg_pool.c. This looks a bit suspicious for me:

module_init(sg_pool_init);

After changing the above to:

core_initcall(sg_pool_init);

the issue is gone.

Please confirm that this is a proper way of fixing this issue, so I will send a final patch.

Quoted 143 lines
Quoted 143 lines

Guenter

---
# bad: [ef08d387bbbc20df740ced8caee0ffac835869ac] Add linux-next specific files for 20220920
# good: [521a547ced6477c54b4b0cc206000406c221b4d6] Linux 6.0-rc6 git bisect start 'HEAD' 'v6.0-rc6'
# bad: [df970c033333b10c728198606fe787535e08ab8a] Merge branch 'drm-next' of git://git.freedesktop.org/git/drm/drm.git
git bisect bad df970c033333b10c728198606fe787535e08ab8a
# bad: [0120f1228dc162c1e00ac24b788a67cc669ff56f] Merge branch 'docs-next' of git://git.lwn.net/linux.git
git bisect bad 0120f1228dc162c1e00ac24b788a67cc669ff56f
# bad: [ed1b38e88a53a328673e1fffdd6bb69e02c34af1] Merge branch 'for-next' of
git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
git bisect bad ed1b38e88a53a328673e1fffdd6bb69e02c34af1
# bad: [4dd0700db9ab87d345d989c7589077d858a1f387] Merge branch 'for-next/core' of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
git bisect bad 4dd0700db9ab87d345d989c7589077d858a1f387
# good: [61aa10c4f088adac94f88ba967db44ffab627aef] Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git
git bisect good 61aa10c4f088adac94f88ba967db44ffab627aef
# bad: [94c23f8f94b27223a557c88075ea063c70afc0ae] Merge branch 'perf/core' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
git bisect bad 94c23f8f94b27223a557c88075ea063c70afc0ae
# good: [6357b3bb80d81a4ad5fe1d15f50ebe5de6c9cab2] perf intel-pt:
Support itrace option flag d+e to log on error
git bisect good 6357b3bb80d81a4ad5fe1d15f50ebe5de6c9cab2
# bad: [d2ed1be371b80f97d2141cfcb0c4ecd02e550180] scripts: remove unused argument 'type'
git bisect bad d2ed1be371b80f97d2141cfcb0c4ecd02e550180
# good: [a521c97e2a63490c238865763fc86942dce8d6bb] kbuild: rewrite check-local-export in sh/awk
git bisect good a521c97e2a63490c238865763fc86942dce8d6bb
# bad: [165b718fdd8c5a9165b4485019729c0cd8728120] kbuild: unify two modpost invocations
git bisect bad 165b718fdd8c5a9165b4485019729c0cd8728120
# bad: [10d1d4b75525f3172c6930fb20445f669762ea95] kbuild: move core-y and drivers-y to ./Kbuild
git bisect bad 10d1d4b75525f3172c6930fb20445f669762ea95
# good: [fd5f5437264c05b9fc0fff4349f0564f474bdf5e] kbuild: rename modules.order in sub-directories to .modules.order
git bisect good fd5f5437264c05b9fc0fff4349f0564f474bdf5e

# first bad commit: [10d1d4b75525f3172c6930fb20445f669762ea95] 
kbuild: move core-y and drivers-y to ./Kbuild

---
[    1.812993] sym53c8xx 0000:00:00.0: enabling SERR and PARITY (0107 -> 0147)
[    1.816056] sym0: <895a> rev 0x0 at pci 0000:00:00.0 irq 19 [    1.823635] sym0: PA-RISC Firmware, ID 7, Fast-40, LVD, parity checking
[    1.827770] sym0: SCSI BUS has been reset.
[    1.833713] scsi host0: sym-2.2.3
[    1.845265] Backtrace:
[    1.845750]  [<10b83400>] sg_pool_alloc+0xac/0xc0
[    1.846512]  [<10ac8ba8>] __sg_alloc_table+0x16c/0x1c0
[    1.846728]  [<10b83540>] sg_alloc_table_chained+0x6c/0xec [    1.846911]  [<106ff470>] scsi_alloc_sgtables+0x8c/0x268 [    1.847129]  [<10703d5c>] scsi_queue_rq+0xae4/0xb3c
[    1.847296]  [<1060f62c>] blk_mq_dispatch_rq_list+0x1e4/0xa2c [    1.847538]  [<10617184>] __blk_mq_sched_dispatch_requests+0xb4/0x188 [    1.847758]  [<10617334>] blk_mq_sched_dispatch_requests+0x58/0x84 [    1.847787]  [<1060b6bc>] __blk_mq_run_hw_queue+0x78/0x108 [    1.847787]  [<1060d968>] __blk_mq_delay_run_hw_queue+0x114/0x1e0 [    1.847787]  [<1060dc64>] blk_mq_run_hw_queue+0xb0/0x12c [    1.847787]  [<10617600>] blk_mq_sched_insert_request+0x12c/0x158 [    1.847787]  [<1060ad9c>] blk_execute_rq+0x9c/0x194
[    1.847787]  [<10700a1c>] __scsi_execute+0x130/0x1f4
[    1.847787]  [<10704d70>] scsi_probe_and_add_lun+0x214/0xc60 [    1.847787]  [<10706144>] __scsi_scan_target+0x164/0x5b4 [    1.847787]  [<10706804>] scsi_scan_host_selected+0x138/0x23c [    1.847787]  [<107069d8>] do_scsi_scan_host+0xd0/0xf0
[    1.847787]  [<10706b98>] scsi_scan_host+0x1a0/0x1f0
[    1.847787]  [<10716ba0>] sym2_probe+0x824/0x850
[    1.847787]  [<10656110>] pci_device_probe+0x9c/0x148
[    1.847787]  [<106deee0>] really_probe+0xc4/0x34c
[    1.847787]  [<106df1c4>] __driver_probe_device+0x5c/0xbc [    1.847787]  [<106df2c0>] driver_probe_device+0x9c/0x188 [    1.847787]  [<106dfb50>] __driver_attach+0xac/0x194
[    1.847787]  [<106dc784>] bus_for_each_dev+0x78/0xb8
[    1.847787]  [<106de698>] driver_attach+0x28/0x38
[    1.847787]  [<106de144>] bus_add_driver+0x198/0x224
[    1.847787]  [<106e05e0>] driver_register+0x98/0x168
[    1.847787]  [<106555d0>] __pci_register_driver+0x80/0x94 [    1.847787]
[    1.847787]
[    1.847787] Kernel Fault: Code=26 (Data memory access rights trap) at addr 0000002c
[    1.847787] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc6-next-20220920-32bit #1
[    1.847787] Hardware name: 9000/778/B160L
[    1.847787]
[    1.847787]      YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
[    1.847787] PSW: 00000000000001001011111100001111 Not tainted [    1.847787] r00-03  0004bf0f 1183d400 10b83400 1183d440
[    1.847787] r04-07  00000000 00092820 00092820 00000080
[    1.847787] r08-11  00000000 00000034 00000002 11830000
[    1.847787] r12-15  000001f4 10db0000 1204f128 00000001
[    1.847787] r16-19  11beb200 1204f038 1183d0c8 00000080
[    1.847787] r20-23  00000820 00000001 10b83354 00000000
[    1.847787] r24-27  00000080 00000820 00000000 10e42e18
[    1.847787] r28-31  00092000 0000000f 1183d4c0 10ac8ba8
[    1.847787] sr00-03  00000000 00000000 00000000 00000000 [    1.847787] sr04-07  00000000 00000000 00000000 00000000 [    1.847787]
[    1.847787] IASQ: 00000000 00000000 IAOQ: 102bce5c 102bce60 [    1.847787]  IIR: 48960058    ISR: 00000000  IOR: 0000002c [    1.847787]  CPU:        0   CR30: 11830000 CR31: 00000000 [    1.847787]  ORIG_R28: 86b51896
[    1.847787]  IAOQ[0]: mempool_alloc+0x78/0x1a8
[    1.847787]  IAOQ[1]: mempool_alloc+0x7c/0x1a8
[    1.847787]  RP(r2): sg_pool_alloc+0xac/0xc0
[    1.847787] Backtrace:
[    1.847787]  [<10b83400>] sg_pool_alloc+0xac/0xc0
[    1.847787]  [<10ac8ba8>] __sg_alloc_table+0x16c/0x1c0
[    1.847787]  [<10b83540>] sg_alloc_table_chained+0x6c/0xec [    1.847787]  [<106ff470>] scsi_alloc_sgtables+0x8c/0x268 [    1.847787]  [<10703d5c>] scsi_queue_rq+0xae4/0xb3c
[    1.847787]  [<1060f62c>] blk_mq_dispatch_rq_list+0x1e4/0xa2c [    1.847787]  [<10617184>] __blk_mq_sched_dispatch_requests+0xb4/0x188 [    1.847787]  [<10617334>] blk_mq_sched_dispatch_requests+0x58/0x84 [    1.847787]  [<1060b6bc>] __blk_mq_run_hw_queue+0x78/0x108 [    1.847787]  [<1060d968>] __blk_mq_delay_run_hw_queue+0x114/0x1e0 [    1.847787]  [<1060dc64>] blk_mq_run_hw_queue+0xb0/0x12c [    1.847787]  [<10617600>] blk_mq_sched_insert_request+0x12c/0x158 [    1.847787]  [<1060ad9c>] blk_execute_rq+0x9c/0x194
[    1.847787]  [<10700a1c>] __scsi_execute+0x130/0x1f4
[    1.847787]  [<10704d70>] scsi_probe_and_add_lun+0x214/0xc60 [    1.847787]  [<10706144>] __scsi_scan_target+0x164/0x5b4 [    1.847787]  [<10706804>] scsi_scan_host_selected+0x138/0x23c [    1.847787]  [<107069d8>] do_scsi_scan_host+0xd0/0xf0
[    1.847787]  [<10706b98>] scsi_scan_host+0x1a0/0x1f0
[    1.847787]  [<10716ba0>] sym2_probe+0x824/0x850
[    1.847787]  [<10656110>] pci_device_probe+0x9c/0x148
[    1.847787]  [<106deee0>] really_probe+0xc4/0x34c
[    1.847787]  [<106df1c4>] __driver_probe_device+0x5c/0xbc [    1.847787]  [<106df2c0>] driver_probe_device+0x9c/0x188 [    1.847787]  [<106dfb50>] __driver_attach+0xac/0x194

Quoted 9 lines
Quoted 8 lines

[    1.847787]  [<106dc784>] bus_for_each_dev+0x78/0xb8 [    1.847787]  [<106de698>] driver_attach+0x28/0x38 [    1.847787]  [<106de144>] bus_add_driver+0x198/0x224 [    1.847787]  [<106e05e0>] driver_register+0x98/0x168 [    1.847787]  [<106555d0>] __pci_register_driver+0x80/0x94 [    1.847787]
[    1.847787] Kernel panic - not syncing: Kernel Fault

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#7 lore raw

Re: [PATCH v2 3/8] kbuild: move core-y and drivers-y to ./Kbuild

Quoted 135 lines · Marek Szyprowski

Hi All,

CCed: Christoph and Robin, although this is not strictly DMA-mapping related issue...

Quoted 112 lines · Marek Szyprowski
Quoted 30 lines · Guenter Roeck
Quoted 24 lines · Masahiro Yamada

Use the ordinary obj-y to list subdirectories.

Note1:
GNU Make seems to transform './.modules.order' to '.modules.order' before matching it against the target pattern. Split ./.modules.order to a dedicated rule to avoid "doesn't match the target pattern" warning. [1]

Note2:
Previously, the link order of lib-y depended on CONFIG_MODULES; lib-y was linked before drivers-y when CONFIG_MODULES=y, otherwise after drivers-y. This was a bug of commit 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y"), but it was not a big deal after all. Now, libs-y (all objects that come from lib/ and arch/*/lib/) is linked last, irrespective of CONFIG_MODULES.

Note3:
Now, the single target build in arch/*/lib/ works correctly. There was a bug report about this. [2]

   $ make ARCH=arm arch/arm/lib/findbit.o
     CALL    scripts/checksyscalls.sh
     AS      arch/arm/lib/findbit.o
Quoted 5 lines

[1]: https://lists.gnu.org/archive/html/bug-make/2022-08/msg00059.html
[2]:
https://lore.kernel.org/linux-kbuild/YvUQOwL6lD4%2F5%[email protected]/

Quoted 8 lines

With this patch in place, all parisc images crash during boot with the crash dump below. Bisect on next-20220920 points to this patch. Crash and bisect logs are attached.

Loking through boot logs, the same problem (same backtrace) is seen with various boot tests on alpha. There may be more, but -next crashes all over the place right now so it is difficult to determine the platforms affected by a specicfic problem.

I confirm this. I've observed similar issue recently (from time to time) on the ARM 32bit based Exynos5250-based Arndale board. 'git bisect' lead me also to this change. A short investigation revealed that the issue is caused by the NULL sgp->pool in lib/sg_pool.c:sg_pool_alloc() function. Sometimes it works fine, sometimes not. It looks that there is a race in the sg_pools and scsi initialization somehow after this patch.

To confirm that this change is really responsible for the issue I've tried to revert it on top of linux-next. This is however hard due to the dependencies. Instead I've only did:

# git revert -m1 6fb5a32d95a9b1a9d4a6e135404468a8d74cfde6

on top of the linux next-20220921 and resolved the conflict (trivial to resolve). After that the kernel boots fine and I was not able to reproduce the issue.

The issue I've observed was:

ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300) ata1.00: HPA detected: current 117229295, native 117231408 ata1.00: ATA-8: Corsair CSSD-F60GB2, 1.1, max UDMA/133 ata1.00: 117229295 sectors, multi 1: LBA48 NCQ (depth 32) ata1.00: configured for UDMA/133
scsi 0:0:0:0: Direct-Access ATA Corsair CSSD-F60 1.1 PQ: 0
ANSI: 5
sd 0:0:0:0: [sda] 117229295 512-byte logical blocks: (60.0 GB/55.9 GiB) sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Preferred minimum I/O size 512 bytes
8<--- cut here ---

Unable to handle kernel NULL pointer dereference at virtual address

00000034
usb3503 usb-hub: switched to HUB mode [00000034] *pgd=00000000
usb3503 usb-hub: usb3503_probe: probed in hub mode UDC core: g_ether: couldn't find an available UDC

Internal error: Oops: 5 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0 PID: 7 Comm: kworker/0:0H Not tainted
6.0.0-rc5-00016-g10d1d4b75525 #12835
Hardware name: Samsung Exynos (Flattened Device Tree)
Workqueue: kblockd blk_mq_run_work_fn
PC is at mempool_alloc+0x48/0x14c
LR is at mempool_alloc+0x2c/0x14c
pc : [<c0267a2c>]    lr : [<c0267a10>]    psr: 40000013

...
Flags: nZcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 10c5387d Table: 4000406a DAC: 00000051
...
Process kworker/0:0H (pid: 7, stack limit = 0x(ptrval))

Stack: (0xf0839cc8 to 0xf083a000)

...
mempool_alloc from __sg_alloc_table+0x120/0x160 __sg_alloc_table from sg_alloc_table_chained+0x5c/0xc0 sg_alloc_table_chained from scsi_alloc_sgtables+0x5c/0x294 scsi_alloc_sgtables from sd_init_command+0x118/0x908 sd_init_command from scsi_queue_rq+0x360/0xbe0 scsi_queue_rq from blk_mq_dispatch_rq_list+0x1d8/0x8c8 blk_mq_dispatch_rq_list from blk_mq_do_dispatch_sched+0x2e0/0x338 blk_mq_do_dispatch_sched from

__blk_mq_sched_dispatch_requests+0xa8/0x150
 __blk_mq_sched_dispatch_requests from
blk_mq_sched_dispatch_requests+0x34/0x5c
 blk_mq_sched_dispatch_requests from __blk_mq_run_hw_queue+0x88/0x22c
 __blk_mq_run_hw_queue from process_one_work+0x288/0x778
 process_one_work from worker_thread+0x44/0x504
 worker_thread from kthread+0xf0/0x124
 kthread from ret_from_fork+0x14/0x2c
Exception stack(0xf0839fb0 to 0xf0839ff8)
Quoted 8 lines

9fa0: 00000000 00000000 00000000
00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000

Code: e30ea764 e3c44d11 e34ca017 e3844a92 (e5953034)
---[ end trace 0000000000000000 ]---

I've analyzed this issue a bit more and it looks that the $subject patch just revealed a bug in the lib/sg_pool.c. This looks a bit suspicious for me:

module_init(sg_pool_init);

After changing the above to:

Quoted 7 lines

core_initcall(sg_pool_init);

the issue is gone.

Please confirm that this is a proper way of fixing this issue, so I will send a final patch.

What a coincidence, I just submitted a patch...

Quoted 158 lines
Quoted 144 lines
Quoted 144 lines

Guenter

---
# bad: [ef08d387bbbc20df740ced8caee0ffac835869ac] Add linux-next specific files for 20220920
# good: [521a547ced6477c54b4b0cc206000406c221b4d6] Linux 6.0-rc6 git bisect start 'HEAD' 'v6.0-rc6'
# bad: [df970c033333b10c728198606fe787535e08ab8a] Merge branch 'drm-next' of git://git.freedesktop.org/git/drm/drm.git
git bisect bad df970c033333b10c728198606fe787535e08ab8a
# bad: [0120f1228dc162c1e00ac24b788a67cc669ff56f] Merge branch 'docs-next' of git://git.lwn.net/linux.git
git bisect bad 0120f1228dc162c1e00ac24b788a67cc669ff56f
# bad: [ed1b38e88a53a328673e1fffdd6bb69e02c34af1] Merge branch 'for-next' of
git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
git bisect bad ed1b38e88a53a328673e1fffdd6bb69e02c34af1
# bad: [4dd0700db9ab87d345d989c7589077d858a1f387] Merge branch 'for-next/core' of
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
git bisect bad 4dd0700db9ab87d345d989c7589077d858a1f387
# good: [61aa10c4f088adac94f88ba967db44ffab627aef] Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git
git bisect good 61aa10c4f088adac94f88ba967db44ffab627aef
# bad: [94c23f8f94b27223a557c88075ea063c70afc0ae] Merge branch 'perf/core' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
git bisect bad 94c23f8f94b27223a557c88075ea063c70afc0ae
# good: [6357b3bb80d81a4ad5fe1d15f50ebe5de6c9cab2] perf intel-pt:
Support itrace option flag d+e to log on error
git bisect good 6357b3bb80d81a4ad5fe1d15f50ebe5de6c9cab2
# bad: [d2ed1be371b80f97d2141cfcb0c4ecd02e550180] scripts: remove unused argument 'type'
git bisect bad d2ed1be371b80f97d2141cfcb0c4ecd02e550180
# good: [a521c97e2a63490c238865763fc86942dce8d6bb] kbuild: rewrite check-local-export in sh/awk
git bisect good a521c97e2a63490c238865763fc86942dce8d6bb
# bad: [165b718fdd8c5a9165b4485019729c0cd8728120] kbuild: unify two modpost invocations
git bisect bad 165b718fdd8c5a9165b4485019729c0cd8728120
# bad: [10d1d4b75525f3172c6930fb20445f669762ea95] kbuild: move core-y and drivers-y to ./Kbuild
git bisect bad 10d1d4b75525f3172c6930fb20445f669762ea95
# good: [fd5f5437264c05b9fc0fff4349f0564f474bdf5e] kbuild: rename modules.order in sub-directories to .modules.order
git bisect good fd5f5437264c05b9fc0fff4349f0564f474bdf5e

# first bad commit: [10d1d4b75525f3172c6930fb20445f669762ea95]
kbuild: move core-y and drivers-y to ./Kbuild

---

[    1.812993] sym53c8xx 0000:00:00.0: enabling SERR and PARITY (0107
-> 0147)
[    1.816056] sym0: <895a> rev 0x0 at pci 0000:00:00.0 irq 19
[    1.823635] sym0: PA-RISC Firmware, ID 7, Fast-40, LVD, parity
checking
[    1.827770] sym0: SCSI BUS has been reset.
[    1.833713] scsi host0: sym-2.2.3
[    1.845265] Backtrace:
[    1.845750]  [<10b83400>] sg_pool_alloc+0xac/0xc0
[    1.846512]  [<10ac8ba8>] __sg_alloc_table+0x16c/0x1c0
[    1.846728]  [<10b83540>] sg_alloc_table_chained+0x6c/0xec
[    1.846911]  [<106ff470>] scsi_alloc_sgtables+0x8c/0x268
[    1.847129]  [<10703d5c>] scsi_queue_rq+0xae4/0xb3c
[    1.847296]  [<1060f62c>] blk_mq_dispatch_rq_list+0x1e4/0xa2c
[    1.847538]  [<10617184>] __blk_mq_sched_dispatch_requests+0xb4/0x188
[    1.847758]  [<10617334>] blk_mq_sched_dispatch_requests+0x58/0x84
[    1.847787]  [<1060b6bc>] __blk_mq_run_hw_queue+0x78/0x108
[    1.847787]  [<1060d968>] __blk_mq_delay_run_hw_queue+0x114/0x1e0
[    1.847787]  [<1060dc64>] blk_mq_run_hw_queue+0xb0/0x12c
[    1.847787]  [<10617600>] blk_mq_sched_insert_request+0x12c/0x158
[    1.847787]  [<1060ad9c>] blk_execute_rq+0x9c/0x194
[    1.847787]  [<10700a1c>] __scsi_execute+0x130/0x1f4
[    1.847787]  [<10704d70>] scsi_probe_and_add_lun+0x214/0xc60
[    1.847787]  [<10706144>] __scsi_scan_target+0x164/0x5b4
[    1.847787]  [<10706804>] scsi_scan_host_selected+0x138/0x23c
[    1.847787]  [<107069d8>] do_scsi_scan_host+0xd0/0xf0
[    1.847787]  [<10706b98>] scsi_scan_host+0x1a0/0x1f0
[    1.847787]  [<10716ba0>] sym2_probe+0x824/0x850
[    1.847787]  [<10656110>] pci_device_probe+0x9c/0x148
[    1.847787]  [<106deee0>] really_probe+0xc4/0x34c
[    1.847787]  [<106df1c4>] __driver_probe_device+0x5c/0xbc
[    1.847787]  [<106df2c0>] driver_probe_device+0x9c/0x188
[    1.847787]  [<106dfb50>] __driver_attach+0xac/0x194
[    1.847787]  [<106dc784>] bus_for_each_dev+0x78/0xb8
[    1.847787]  [<106de698>] driver_attach+0x28/0x38
[    1.847787]  [<106de144>] bus_add_driver+0x198/0x224
[    1.847787]  [<106e05e0>] driver_register+0x98/0x168
[    1.847787]  [<106555d0>] __pci_register_driver+0x80/0x94
[    1.847787]
[    1.847787]
[    1.847787] Kernel Fault: Code=26 (Data memory access rights trap)
at addr 0000002c
[    1.847787] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
6.0.0-rc6-next-20220920-32bit #1
[    1.847787] Hardware name: 9000/778/B160L
[    1.847787]
[    1.847787]      YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI
[    1.847787] PSW: 00000000000001001011111100001111 Not tainted
[    1.847787] r00-03  0004bf0f 1183d400 10b83400 1183d440
[    1.847787] r04-07  00000000 00092820 00092820 00000080
[    1.847787] r08-11  00000000 00000034 00000002 11830000
[    1.847787] r12-15  000001f4 10db0000 1204f128 00000001
[    1.847787] r16-19  11beb200 1204f038 1183d0c8 00000080
[    1.847787] r20-23  00000820 00000001 10b83354 00000000
[    1.847787] r24-27  00000080 00000820 00000000 10e42e18
[    1.847787] r28-31  00092000 0000000f 1183d4c0 10ac8ba8
[    1.847787] sr00-03  00000000 00000000 00000000 00000000
[    1.847787] sr04-07  00000000 00000000 00000000 00000000
[    1.847787]
[    1.847787] IASQ: 00000000 00000000 IAOQ: 102bce5c 102bce60
[    1.847787]  IIR: 48960058    ISR: 00000000  IOR: 0000002c
[    1.847787]  CPU:        0   CR30: 11830000 CR31: 00000000
[    1.847787]  ORIG_R28: 86b51896
[    1.847787]  IAOQ[0]: mempool_alloc+0x78/0x1a8
[    1.847787]  IAOQ[1]: mempool_alloc+0x7c/0x1a8
[    1.847787]  RP(r2): sg_pool_alloc+0xac/0xc0
[    1.847787] Backtrace:
[    1.847787]  [<10b83400>] sg_pool_alloc+0xac/0xc0
[    1.847787]  [<10ac8ba8>] __sg_alloc_table+0x16c/0x1c0
[    1.847787]  [<10b83540>] sg_alloc_table_chained+0x6c/0xec
[    1.847787]  [<106ff470>] scsi_alloc_sgtables+0x8c/0x268
[    1.847787]  [<10703d5c>] scsi_queue_rq+0xae4/0xb3c
[    1.847787]  [<1060f62c>] blk_mq_dispatch_rq_list+0x1e4/0xa2c
[    1.847787]  [<10617184>] __blk_mq_sched_dispatch_requests+0xb4/0x188
[    1.847787]  [<10617334>] blk_mq_sched_dispatch_requests+0x58/0x84
[    1.847787]  [<1060b6bc>] __blk_mq_run_hw_queue+0x78/0x108
[    1.847787]  [<1060d968>] __blk_mq_delay_run_hw_queue+0x114/0x1e0
[    1.847787]  [<1060dc64>] blk_mq_run_hw_queue+0xb0/0x12c
[    1.847787]  [<10617600>] blk_mq_sched_insert_request+0x12c/0x158
[    1.847787]  [<1060ad9c>] blk_execute_rq+0x9c/0x194
[    1.847787]  [<10700a1c>] __scsi_execute+0x130/0x1f4
[    1.847787]  [<10704d70>] scsi_probe_and_add_lun+0x214/0xc60
[    1.847787]  [<10706144>] __scsi_scan_target+0x164/0x5b4
[    1.847787]  [<10706804>] scsi_scan_host_selected+0x138/0x23c
[    1.847787]  [<107069d8>] do_scsi_scan_host+0xd0/0xf0
[    1.847787]  [<10706b98>] scsi_scan_host+0x1a0/0x1f0
[    1.847787]  [<10716ba0>] sym2_probe+0x824/0x850
[    1.847787]  [<10656110>] pci_device_probe+0x9c/0x148
[    1.847787]  [<106deee0>] really_probe+0xc4/0x34c
[    1.847787]  [<106df1c4>] __driver_probe_device+0x5c/0xbc
[    1.847787]  [<106df2c0>] driver_probe_device+0x9c/0x188
[    1.847787]  [<106dfb50>] __driver_attach+0xac/0x194
Quoted 9 lines
Quoted 8 lines
[    1.847787]  [<106dc784>] bus_for_each_dev+0x78/0xb8
[    1.847787]  [<106de698>] driver_attach+0x28/0x38
[    1.847787]  [<106de144>] bus_add_driver+0x198/0x224
[    1.847787]  [<106e05e0>] driver_register+0x98/0x168
[    1.847787]  [<106555d0>] __pci_register_driver+0x80/0x94
[    1.847787]
[    1.847787] Kernel panic - not syncing: Kernel Fault

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

Signature · 2 lines
Best Regards
Masahiro Yamada
#8 lore raw

Re: [PATCH v2 3/8] kbuild: move core-y and drivers-y to ./Kbuild

In reply to Marek Szyprowski
Quoted 135 lines · Marek Szyprowski

Hi All,

CCed: Christoph and Robin, although this is not strictly DMA-mapping related issue...

Quoted 112 lines · Marek Szyprowski
Quoted 30 lines · Guenter Roeck
Quoted 24 lines · Masahiro Yamada

Use the ordinary obj-y to list subdirectories.

Note1:
GNU Make seems to transform './.modules.order' to '.modules.order' before matching it against the target pattern. Split ./.modules.order to a dedicated rule to avoid "doesn't match the target pattern" warning. [1]

Note2:
Previously, the link order of lib-y depended on CONFIG_MODULES; lib-y was linked before drivers-y when CONFIG_MODULES=y, otherwise after drivers-y. This was a bug of commit 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y"), but it was not a big deal after all. Now, libs-y (all objects that come from lib/ and arch/*/lib/) is linked last, irrespective of CONFIG_MODULES.

Note3:
Now, the single target build in arch/*/lib/ works correctly. There was a bug report about this. [2]

   $ make ARCH=arm arch/arm/lib/findbit.o
     CALL    scripts/checksyscalls.sh
     AS      arch/arm/lib/findbit.o
Quoted 5 lines

[1]: https://lists.gnu.org/archive/html/bug-make/2022-08/msg00059.html
[2]:
https://lore.kernel.org/linux-kbuild/YvUQOwL6lD4%2F5%[email protected]/

Quoted 8 lines

With this patch in place, all parisc images crash during boot with the crash dump below. Bisect on next-20220920 points to this patch. Crash and bisect logs are attached.

Loking through boot logs, the same problem (same backtrace) is seen with various boot tests on alpha. There may be more, but -next crashes all over the place right now so it is difficult to determine the platforms affected by a specicfic problem.

I confirm this. I've observed similar issue recently (from time to time) on the ARM 32bit based Exynos5250-based Arndale board. 'git bisect' lead me also to this change. A short investigation revealed that the issue is caused by the NULL sgp->pool in lib/sg_pool.c:sg_pool_alloc() function. Sometimes it works fine, sometimes not. It looks that there is a race in the sg_pools and scsi initialization somehow after this patch.

To confirm that this change is really responsible for the issue I've tried to revert it on top of linux-next. This is however hard due to the dependencies. Instead I've only did:

# git revert -m1 6fb5a32d95a9b1a9d4a6e135404468a8d74cfde6

on top of the linux next-20220921 and resolved the conflict (trivial to resolve). After that the kernel boots fine and I was not able to reproduce the issue.

The issue I've observed was:

ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300) ata1.00: HPA detected: current 117229295, native 117231408 ata1.00: ATA-8: Corsair CSSD-F60GB2, 1.1, max UDMA/133 ata1.00: 117229295 sectors, multi 1: LBA48 NCQ (depth 32) ata1.00: configured for UDMA/133
scsi 0:0:0:0: Direct-Access ATA Corsair CSSD-F60 1.1 PQ: 0
ANSI: 5
sd 0:0:0:0: [sda] 117229295 512-byte logical blocks: (60.0 GB/55.9 GiB) sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Preferred minimum I/O size 512 bytes
8<--- cut here ---

Unable to handle kernel NULL pointer dereference at virtual address

00000034
usb3503 usb-hub: switched to HUB mode [00000034] *pgd=00000000
usb3503 usb-hub: usb3503_probe: probed in hub mode UDC core: g_ether: couldn't find an available UDC

Internal error: Oops: 5 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0 PID: 7 Comm: kworker/0:0H Not tainted
6.0.0-rc5-00016-g10d1d4b75525 #12835
Hardware name: Samsung Exynos (Flattened Device Tree)
Workqueue: kblockd blk_mq_run_work_fn
PC is at mempool_alloc+0x48/0x14c
LR is at mempool_alloc+0x2c/0x14c
pc : [<c0267a2c>]    lr : [<c0267a10>]    psr: 40000013

...
Flags: nZcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 10c5387d Table: 4000406a DAC: 00000051
...
Process kworker/0:0H (pid: 7, stack limit = 0x(ptrval))

Stack: (0xf0839cc8 to 0xf083a000)

...
mempool_alloc from __sg_alloc_table+0x120/0x160 __sg_alloc_table from sg_alloc_table_chained+0x5c/0xc0 sg_alloc_table_chained from scsi_alloc_sgtables+0x5c/0x294 scsi_alloc_sgtables from sd_init_command+0x118/0x908 sd_init_command from scsi_queue_rq+0x360/0xbe0 scsi_queue_rq from blk_mq_dispatch_rq_list+0x1d8/0x8c8 blk_mq_dispatch_rq_list from blk_mq_do_dispatch_sched+0x2e0/0x338 blk_mq_do_dispatch_sched from

__blk_mq_sched_dispatch_requests+0xa8/0x150
 __blk_mq_sched_dispatch_requests from
blk_mq_sched_dispatch_requests+0x34/0x5c
 blk_mq_sched_dispatch_requests from __blk_mq_run_hw_queue+0x88/0x22c
 __blk_mq_run_hw_queue from process_one_work+0x288/0x778
 process_one_work from worker_thread+0x44/0x504
 worker_thread from kthread+0xf0/0x124
 kthread from ret_from_fork+0x14/0x2c
Exception stack(0xf0839fb0 to 0xf0839ff8)
Quoted 8 lines

9fa0: 00000000 00000000 00000000
00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000

Code: e30ea764 e3c44d11 e34ca017 e3844a92 (e5953034)
---[ end trace 0000000000000000 ]---

I've analyzed this issue a bit more and it looks that the $subject patch just revealed a bug in the lib/sg_pool.c. This looks a bit suspicious for me:

module_init(sg_pool_init);

After changing the above to:

Quoted 7 lines

core_initcall(sg_pool_init);

the issue is gone.

Please confirm that this is a proper way of fixing this issue, so I will send a final patch.

I am not sure about the choice for *_initcall.
Please feel free to override me.

Anyway, I will make my Kbuild refactoring not depend on sg_pool fix-up.

Signature · 2 lines
Best Regards
Masahiro Yamada
#9 lore raw

PATCH v2 4/8 kbuild: move .vmlinux.objs rule to Makefile.modpost

In reply to Masahiro Yamada

.vmlinux.objs is used by modpost, so scripts/Makefile.modpost is a better place to generate it.

It is used only when CONFIG_MODVERSIONS=y. It should be guarded by "ifdef CONFIG_MODVERSIONS".

---

(no changes since v1)

 Makefile                 |  2 +-
 scripts/Makefile.modpost | 30 ++++++++++++++++++++++++++++--
 scripts/link-vmlinux.sh  | 18 ------------------
 3 files changed, 29 insertions(+), 21 deletions(-)
Makefile +1 -1
index ef0621d55ebb..cf06ace9da3a 100644
@@ -1485,7 +1485,7 @@ endif # CONFIG_MODULES
 # Directories & files removed with 'make clean'
 CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
 	       modules.builtin modules.builtin.modinfo modules.nsdeps \
-	       compile_commands.json .thinlto-cache
+	       compile_commands.json .thinlto-cache .vmlinux.objs
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_FILES += include/config include/generated          \
scripts/Makefile.modpost +28 -2
index 911606496341..04ad00917b2f 100644
@@ -57,6 +57,32 @@ vmlinux.symvers: vmlinux.o
 
 __modpost: vmlinux.symvers
 
+# Generate the list of in-tree objects in vmlinux
+# ---------------------------------------------------------------------------
+
+# This is used to retrieve symbol versions generated by genksyms.
+ifdef CONFIG_MODVERSIONS
+vmlinux.symvers: .vmlinux.objs
+endif
+
+# Ignore libgcc.a
+# Some architectures do '$(CC) --print-libgcc-file-name' to borrow libgcc.a
+# from the toolchain, but there is no EXPORT_SYMBOL in it.
+
+quiet_cmd_vmlinux_objs = GEN     $@
+      cmd_vmlinux_objs =		\
+	for f in $(real-prereqs); do	\
+		case $${f} in		\
+		*libgcc.a) ;;		\
+		*.a) $(AR) t $${f} ;;	\
+		*) echo $${f} ;;	\
+		esac			\
+	done > $@
+
+targets += .vmlinux.objs
+.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+	$(call if_changed,vmlinux_objs)
+
 else
 
 ifeq ($(KBUILD_EXTMOD),)
@@ -134,6 +160,8 @@ ifneq ($(KBUILD_MODPOST_NOFINAL),1)
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
 endif
 
+endif
+
 PHONY += FORCE
 FORCE:
 
@@ -141,6 +169,4 @@ existing-targets := $(wildcard $(sort $(targets)))
 
 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
 
-endif
-
 .PHONY: $(PHONY)
scripts/link-vmlinux.sh +0 -18
index 8d982574145a..161bca64e8aa 100755
@@ -199,7 +199,6 @@ cleanup()
 	rm -f System.map
 	rm -f vmlinux
 	rm -f vmlinux.map
-	rm -f .vmlinux.objs
 	rm -f .vmlinux.export.c
 }
 
@@ -218,23 +217,6 @@ fi
 #link vmlinux.o
 ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
 
-# Generate the list of in-tree objects in vmlinux
-#
-# This is used to retrieve symbol versions generated by genksyms.
-for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
-	case ${f} in
-	*libgcc.a)
-		# Some architectures do '$(CC) --print-libgcc-file-name' to
-		# borrow libgcc.a from the toolchain.
-		# There is no EXPORT_SYMBOL in external objects. Ignore this.
-		;;
-	*.a)
-		${AR} t ${f} ;;
-	*)
-		echo ${f} ;;
-	esac
-done > .vmlinux.objs
-
 # modpost vmlinux.o to check for section mismatches
 ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
 
Signature · 1 line
2.34.1
#10 lore raw

PATCH v2 5/8 kbuild: move vmlinux.o rule to the top Makefile

In reply to Masahiro Yamada

Move the build rules of vmlinux.o out of scripts/link-vmlinux.sh to clearly separate 1) pre-modpost, 2) modpost, 3) post-modpost stages. This will make furture refactoring possible.

---

(no changes since v1)

 Makefile                | 10 ++++++++--
 scripts/link-vmlinux.sh |  3 ---
 2 files changed, 8 insertions(+), 5 deletions(-)
Makefile +8 -2
index cf06ace9da3a..e4c270256849 100644
@@ -645,6 +645,8 @@ else
 __all: modules
 endif
 
+targets :=
+
 # Decide whether to build built-in, modular, or both.
 # Normally, just do built-in.
 
@@ -1149,6 +1151,10 @@ quiet_cmd_autoksyms_h = GEN     $@
 $(autoksyms_h):
 	$(call cmd,autoksyms_h)
 
+targets += vmlinux.o
+vmlinux.o: autoksyms_recursive $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
+
 ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
 
 # Final link of vmlinux with optional arch pass after final link
@@ -1156,10 +1162,10 @@ cmd_link-vmlinux =                                                 \
 	$(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)";    \
 	$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 
-vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
+vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
 	+$(call if_changed_dep,link-vmlinux)
 
-targets := vmlinux
+targets += vmlinux
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
scripts/link-vmlinux.sh +0 -3
index 161bca64e8aa..07486f90d5e2 100755
@@ -214,9 +214,6 @@ if [ "$1" = "clean" ]; then
 	exit 0
 fi
 
-#link vmlinux.o
-${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
-
 # modpost vmlinux.o to check for section mismatches
 ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
 
Signature · 1 line
2.34.1
#11 lore raw

PATCH v2 6/8 kbuild: unify two modpost invocations

In reply to Masahiro Yamada

Currently, modpost is executed twice; first for vmlinux, second for modules.

This commit merges them.

Current build flow
==================

1) build obj-y and obj-m objects
2) link vmlinux.o
3) modpost for vmlinux
4) link vmlinux
5) modpost for modules
6) link modules (*.ko)

The build steps 1) through 6) are serialized, that is, modules are built after vmlinux. You do not get benefits of parallel builds when scripts/link-vmlinux.sh is being run.

New build flow
==============

1) build obj-y and obj-m objects
2) link vmlinux.o
3) modpost for vmlinux and modules
4a) link vmlinux
4b) link modules (*.ko)

In the new build flow, modpost is invoked just once.

vmlinux and modules are built in parallel. One exception is CONFIG_DEBUG_INFO_BTF_MODULES=y, where modules depend on vmlinux.

---

(no changes since v1)

 Makefile                  | 30 ++++++++++---
 scripts/Makefile.modfinal |  2 +-
 scripts/Makefile.modpost  | 93 ++++++++++++---------------------------
 scripts/link-vmlinux.sh   |  3 --
 4 files changed, 53 insertions(+), 75 deletions(-)
Makefile +24 -6
index e4c270256849..f9ee16bd212d 100644
@@ -1162,7 +1162,7 @@ cmd_link-vmlinux =                                                 \
 	$(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)";    \
 	$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 
-vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
+vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) modpost FORCE
 	+$(call if_changed_dep,link-vmlinux)
 
 targets += vmlinux
@@ -1439,7 +1439,13 @@ endif
 # Build modules
 #
 
-modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare
+# *.ko are usually independent of vmlinux, but CONFIG_DEBUG_INFOBTF_MODULES
+# is an exception.
+ifdef CONFIG_DEBUG_INFO_BTF_MODULES
+modules: vmlinux
+endif
+
+modules: modules_prepare
 
 # Target to prepare building external modules
 modules_prepare: prepare
@@ -1762,8 +1768,12 @@ targets += $(MODORDER)
 $(MODORDER): $(subdir-modorder) FORCE
 	$(call if_changed,modules_order)
 
-modules: modules_check
-	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
+# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
+# This is solely useful to speed up test compiles.
+modules: modpost
+ifneq ($(KBUILD_MODPOST_NOFINAL),1)
+	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
+endif
 
 PHONY += modules_check
 modules_check: $(MODORDER)
@@ -1794,6 +1804,11 @@ KBUILD_MODULES :=
 
 endif # CONFIG_MODULES
 
+PHONY += modpost
+modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
+	 $(if $(KBUILD_MODULES), modules_check)
+	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
+
 # Single targets
 # ---------------------------------------------------------------------------
 # To build individual files in subdirectories, you can do like this:
@@ -1813,16 +1828,19 @@ single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
 single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
 		$(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
 
-$(single-ko): single_modpost
+$(single-ko): single_modules
 	@:
 $(single-no-ko): descend
 	@:
 
 # Remove MODORDER when done because it is not the real one.
 PHONY += single_modpost
-single_modpost: $(single-no-ko) modules_prepare
+single_modules: $(single-no-ko) modules_prepare
 	$(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER)
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
+ifneq ($(KBUILD_MODPOST_NOFINAL),1)
+	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
+endif
 	$(Q)rm -f $(MODORDER)
 
 single-goals := $(foreach x, $(addprefix $(extmod_prefix), $(single-no-ko)), \
scripts/Makefile.modfinal +1 -1
index 35100e981f4a..a3cf9e3647c9 100644
@@ -55,7 +55,7 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check),      \
 	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
 
 # Re-generate module BTFs if either module's .ko or vmlinux changed
-$(modules): %.ko: %.o %.mod.o scripts/module.lds $(if $(KBUILD_BUILTIN),vmlinux) FORCE
+$(modules): %.ko: %.o %.mod.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE
 	+$(call if_changed_except,ld_ko_o,vmlinux)
 ifdef CONFIG_DEBUG_INFO_BTF_MODULES
 	+$(if $(newer-prereqs),$(call cmd,btf_ko))
scripts/Makefile.modpost +28 -65

141 lines not on this page · raw message

scripts/link-vmlinux.sh +0 -3
index 07486f90d5e2..6a197d8a88ac 100755
@@ -214,9 +214,6 @@ if [ "$1" = "clean" ]; then
 	exit 0
 fi
 
-# modpost vmlinux.o to check for section mismatches
-${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
-
 info MODINFO modules.builtin.modinfo
 ${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo
 info GEN modules.builtin
Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 7/8 kbuild: use obj-y instead extra-y for objects placed at the head

In reply to Masahiro Yamada

The objects placed at the head of vmlinux need special treatments:

- arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line.

- arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'.

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects.

There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py.

---

(no changes since v1)

 Documentation/kbuild/makefiles.rst          | 18 +----------------
 Makefile                                    | 18 +++++++++++++----
 arch/alpha/kernel/Makefile                  |  4 ++--
 arch/arc/kernel/Makefile                    |  4 ++--
 arch/arm/kernel/Makefile                    |  4 ++--
 arch/arm64/kernel/Makefile                  |  4 ++--
 arch/csky/kernel/Makefile                   |  4 ++--
 arch/hexagon/kernel/Makefile                |  3 ++-
 arch/ia64/kernel/Makefile                   |  4 ++--
 arch/loongarch/kernel/Makefile              |  4 ++--
 arch/m68k/68000/Makefile                    |  2 +-
 arch/m68k/coldfire/Makefile                 |  2 +-
 arch/m68k/kernel/Makefile                   | 21 ++++++++++----------
 arch/microblaze/kernel/Makefile             |  4 ++--
 arch/mips/kernel/Makefile                   |  4 ++--
 arch/nios2/kernel/Makefile                  |  2 +-
 arch/openrisc/kernel/Makefile               |  4 ++--
 arch/parisc/kernel/Makefile                 |  4 ++--
 arch/powerpc/kernel/Makefile                | 22 ++++++++++-----------
 arch/riscv/kernel/Makefile                  |  2 +-
 arch/s390/kernel/Makefile                   |  4 ++--
 arch/sh/kernel/Makefile                     |  4 ++--
 arch/sparc/kernel/Makefile                  |  3 +--
 arch/x86/kernel/Makefile                    | 10 +++++-----
 arch/xtensa/kernel/Makefile                 |  4 ++--
 scripts/Makefile.modpost                    |  5 ++---
 scripts/Makefile.vmlinux_o                  |  6 +++---
 scripts/clang-tools/gen_compile_commands.py | 19 +-----------------
 scripts/link-vmlinux.sh                     | 10 ++++------
 29 files changed, 87 insertions(+), 112 deletions(-)
Documentation/kbuild/makefiles.rst +1 -17
index 11a296e52d68..07c7e5a843c1 100644
@@ -340,19 +340,7 @@ more details, with real examples.
 
 	Examples are:
 
-	1) head objects
-
-	    Some objects must be placed at the head of vmlinux. They are
-	    directly linked to vmlinux without going through built-in.a
-	    A typical use-case is an object that contains the entry point.
-
-	    arch/$(SRCARCH)/Makefile should specify such objects as head-y.
-
-	    Discussion:
-	      Given that we can control the section order in the linker script,
-	      why do we need head-y?
-
-	2) vmlinux linker script
+	1) vmlinux linker script
 
 	    The linker script for vmlinux is located at
 	    arch/$(SRCARCH)/kernel/vmlinux.lds
@@ -360,10 +348,6 @@ more details, with real examples.
 	Example::
 
 		# arch/x86/kernel/Makefile
-		extra-y	:= head_$(BITS).o
-		extra-y	+= head$(BITS).o
-		extra-y	+= ebda.o
-		extra-y	+= platform-quirks.o
 		extra-y	+= vmlinux.lds
 
 	$(extra-y) should only contain targets needed for vmlinux.
Makefile +14 -4
index f9ee16bd212d..f2d06aaaefd3 100644
@@ -1113,7 +1113,7 @@ clean-dirs	:= $(vmlinux-alldirs)
 export ARCH_CORE	:= $(core-y)
 export ARCH_DRIVERS	:= $(drivers-y)
 # Externally visible symbols (used by link-vmlinux.sh)
-KBUILD_VMLINUX_OBJS := $(head-y) ./built-in.a
+KBUILD_VMLINUX_OBJS := ./built-in.a
 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
 ifdef CONFIG_MODULES
 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
@@ -1122,7 +1122,7 @@ else
 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
 endif
 
-export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
+export KBUILD_VMLINUX_LIBS
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 # used by scripts/Makefile.package
 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools)
@@ -1151,8 +1151,18 @@ quiet_cmd_autoksyms_h = GEN     $@
 $(autoksyms_h):
 	$(call cmd,autoksyms_h)
 
+quiet_cmd_ar_vmlinux.a = AR      $@
+      cmd_ar_vmlinux.a = \
+	rm -f $@; \
+	$(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
+	$(AR) mPi $$($(AR) t $@ | head -n1) $@ $(head-y)
+
+targets += vmlinux.a
+vmlinux.a: $(KBUILD_VMLINUX_OBJS) FORCE
+	$(call if_changed,ar_vmlinux.a)
+
 targets += vmlinux.o
-vmlinux.o: autoksyms_recursive $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+vmlinux.o: autoksyms_recursive vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
 
 ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
@@ -1909,7 +1919,7 @@ quiet_cmd_gen_compile_commands = GEN     $@
       cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
 
 $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
-	$(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \
+	$(if $(KBUILD_EXTMOD),, vmlinux.a $(KBUILD_VMLINUX_LIBS)) \
 	$(if $(CONFIG_MODULES), $(MODORDER)) FORCE
 	$(call if_changed,gen_compile_commands)
 
arch/alpha/kernel/Makefile +2 -2
index 5a74581bf0ee..5a5b0a8b7c6a 100644
@@ -3,11 +3,11 @@
 # Makefile for the linux kernel.
 #
 
-extra-y		:= head.o vmlinux.lds
+extra-y		:= vmlinux.lds
 asflags-y	:= $(KBUILD_CFLAGS)
 ccflags-y	:= -Wno-sign-compare
 
-obj-y    := entry.o traps.o process.o osf_sys.o irq.o \
+obj-y    := head.o entry.o traps.o process.o osf_sys.o irq.o \
 	    irq_alpha.o signal.o setup.o ptrace.o time.o \
 	    systbls.o err_common.o io.o bugs.o
 
arch/arc/kernel/Makefile +2 -2
index 8c4fc4b54c14..0723d888ac44 100644
@@ -3,7 +3,7 @@
 # Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 #
 
-obj-y	:= arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o
+obj-y	:= head.o arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o
 obj-y	+= signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o
 obj-$(CONFIG_ISA_ARCOMPACT)		+= entry-compact.o intc-compact.o
 obj-$(CONFIG_ISA_ARCV2)			+= entry-arcv2.o intc-arcv2.o
@@ -31,4 +31,4 @@ else
 obj-y += ctx_sw_asm.o
 endif
 
-extra-y := vmlinux.lds head.o
+extra-y := vmlinux.lds
arch/arm/kernel/Makefile +2 -2
index 553866751e1a..8feaa3217ec5 100644
@@ -89,7 +89,7 @@ obj-$(CONFIG_VDSO)		+= vdso.o
 obj-$(CONFIG_EFI)		+= efi.o
 obj-$(CONFIG_PARAVIRT)	+= paravirt.o
 
-head-y			:= head$(MMUEXT).o
+obj-y			+= head$(MMUEXT).o
 obj-$(CONFIG_DEBUG_LL)	+= debug.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 obj-$(CONFIG_ARM_PATCH_PHYS_VIRT)	+= phys2virt.o
@@ -109,4 +109,4 @@ obj-$(CONFIG_HAVE_ARM_SMCCC)	+= smccc-call.o
 
 obj-$(CONFIG_GENERIC_CPU_VULNERABILITIES) += spectre.o
 
-extra-y := $(head-y) vmlinux.lds
+extra-y := vmlinux.lds
arch/arm64/kernel/Makefile +2 -2
index 1add7b01efa7..b619ff207a57 100644
@@ -85,8 +85,8 @@ $(obj)/vdso-wrap.o: $(obj)/vdso/vdso.so
 $(obj)/vdso32-wrap.o: $(obj)/vdso32/vdso.so
 
 obj-y					+= probes/
-head-y					:= head.o
-extra-y					+= $(head-y) vmlinux.lds
+obj-y					+= head.o
+extra-y					+= vmlinux.lds
 
 ifeq ($(CONFIG_DEBUG_EFI),y)
 AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\""
arch/csky/kernel/Makefile +2 -2
index 6f14c924b20d..8a868316b912 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
-extra-y := head.o vmlinux.lds
+extra-y := vmlinux.lds
 
-obj-y += entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/
+obj-y += head.o entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/
 obj-y += power.o syscall.o syscall_table.o setup.o io.o
 obj-y += process.o cpu-probe.o ptrace.o stacktrace.o
 obj-y += probes/
arch/hexagon/kernel/Makefile +2 -1
index fae3dce32fde..e73cb321630e 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
-extra-y := head.o vmlinux.lds
+extra-y := vmlinux.lds
 
+obj-y += head.o
 obj-$(CONFIG_SMP) += smp.o
 
 obj-y += setup.o irq_cpu.o traps.o syscalltab.o signal.o time.o
arch/ia64/kernel/Makefile +2 -2
index 08d4a2ba0652..4a1fcb121dda 100644
@@ -7,9 +7,9 @@ ifdef CONFIG_DYNAMIC_FTRACE
 CFLAGS_REMOVE_ftrace.o = -pg
 endif
 
-extra-y	:= head.o vmlinux.lds
+extra-y	:= vmlinux.lds
 
-obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o irq.o irq_ia64.o	\
+obj-y := head.o entry.o efi.o efi_stub.o gate-data.o fsys.o irq.o irq_ia64.o	\
 	 irq_lsapic.o ivt.o pal.o patch.o process.o ptrace.o sal.o		\
 	 salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \
 	 unwind.o mca.o mca_asm.o topology.o dma-mapping.o iosapic.o acpi.o \
arch/loongarch/kernel/Makefile +2 -2
index e5be17009fe8..6c33b5c45573 100644
@@ -3,9 +3,9 @@
 # Makefile for the Linux/LoongArch kernel.
 #
 
-extra-y		:= head.o vmlinux.lds
+extra-y		:= vmlinux.lds
 
-obj-y		+= cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
+obj-y		+= head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
 		   traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \
 		   elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o
 
arch/m68k/68000/Makefile +1 -1
index 674541fdf5b8..279560add577 100644
@@ -17,4 +17,4 @@ obj-$(CONFIG_DRAGEN2)	+= dragen2.o
 obj-$(CONFIG_UCSIMM)	+= ucsimm.o
 obj-$(CONFIG_UCDIMM)	+= ucsimm.o
 
-extra-y 		:= head.o
+obj-y			+= head.o
arch/m68k/coldfire/Makefile +1 -1
index 9419a6c1f036..c56bc0dc7f2e 100644
@@ -45,4 +45,4 @@ obj-$(CONFIG_STMARK2)	+= stmark2.o
 obj-$(CONFIG_PCI)	+= pci.o
 
 obj-y			+= gpio.o
-extra-y := head.o
+obj-y			+= head.o
arch/m68k/kernel/Makefile +11 -10
index c0833da6a2ca..1755e6cd309f 100644
@@ -3,18 +3,19 @@
 # Makefile for the linux kernel.
 #
 
-extra-$(CONFIG_AMIGA)	:= head.o
-extra-$(CONFIG_ATARI)	:= head.o
-extra-$(CONFIG_MAC)	:= head.o
-extra-$(CONFIG_APOLLO)	:= head.o
-extra-$(CONFIG_VME)	:= head.o
-extra-$(CONFIG_HP300)	:= head.o
-extra-$(CONFIG_Q40)	:= head.o
-extra-$(CONFIG_SUN3X)	:= head.o
-extra-$(CONFIG_VIRT)	:= head.o
-extra-$(CONFIG_SUN3)	:= sun3-head.o
 extra-y			+= vmlinux.lds
 
+obj-$(CONFIG_AMIGA)	:= head.o
+obj-$(CONFIG_ATARI)	:= head.o
+obj-$(CONFIG_MAC)	:= head.o
+obj-$(CONFIG_APOLLO)	:= head.o
+obj-$(CONFIG_VME)	:= head.o
+obj-$(CONFIG_HP300)	:= head.o
+obj-$(CONFIG_Q40)	:= head.o
+obj-$(CONFIG_SUN3X)	:= head.o
+obj-$(CONFIG_VIRT)	:= head.o
+obj-$(CONFIG_SUN3)	:= sun3-head.o
+
 obj-y	:= entry.o irq.o module.o process.o ptrace.o
 obj-y	+= setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
 
arch/microblaze/kernel/Makefile +2 -2
index 15a20eb814ce..4393bee64eaf 100644
@@ -12,9 +12,9 @@ CFLAGS_REMOVE_ftrace.o = -pg
 CFLAGS_REMOVE_process.o = -pg
 endif
 
-extra-y := head.o vmlinux.lds
+extra-y := vmlinux.lds
 
-obj-y += dma.o exceptions.o \
+obj-y += head.o dma.o exceptions.o \
 	hw_exception_handler.o irq.o \
 	process.o prom.o ptrace.o \
 	reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o
arch/mips/kernel/Makefile +2 -2
index 7c96282bff2e..5d1addac5e28 100644
@@ -3,9 +3,9 @@
 # Makefile for the Linux/MIPS kernel.
 #
 
-extra-y		:= head.o vmlinux.lds
+extra-y		:= vmlinux.lds
 
-obj-y		+= branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \
+obj-y		+= head.o branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \
 		   process.o prom.o ptrace.o reset.o setup.o signal.o \
 		   syscall.o time.o topology.o traps.o unaligned.o watch.o \
 		   vdso.o cacheinfo.o
arch/nios2/kernel/Makefile +1 -1
index 0b645e1e3158..78a913181fa1 100644
@@ -3,9 +3,9 @@
 # Makefile for the nios2 linux kernel.
 #
 
-extra-y	+= head.o
 extra-y	+= vmlinux.lds
 
+obj-y	+= head.o
 obj-y	+= cpuinfo.o
 obj-y	+= entry.o
 obj-y	+= insnemu.o
arch/openrisc/kernel/Makefile +2 -2
index 2d172e79f58d..79129161f3e0 100644
@@ -3,9 +3,9 @@
 # Makefile for the linux kernel.
 #
 
-extra-y	:= head.o vmlinux.lds
+extra-y	:= vmlinux.lds
 
-obj-y	:= setup.o or32_ksyms.o process.o dma.o \
+obj-y	:= head.o setup.o or32_ksyms.o process.o dma.o \
 	   traps.o time.o irq.o entry.o ptrace.o signal.o \
 	   sys_call_table.o unwinder.o
 
arch/parisc/kernel/Makefile +2 -2
index d0bfac89a842..3d138c9cf9ce 100644
@@ -3,9 +3,9 @@
 # Makefile for arch/parisc/kernel
 #
 
-extra-y			:= head.o vmlinux.lds
+extra-y		:= vmlinux.lds
 
-obj-y	     	:= cache.o pacache.o setup.o pdt.o traps.o time.o irq.o \
+obj-y		:= head.o cache.o pacache.o setup.o pdt.o traps.o time.o irq.o \
 		   pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \
 		   ptrace.o hardware.o inventory.o drivers.o alternative.o \
 		   signal.o hpmc.o real2.o parisc_ksyms.o unaligned.o \
arch/powerpc/kernel/Makefile +11 -11
index 06d2d1f78f71..f264d9b2cb63 100644
@@ -118,12 +118,12 @@ obj-$(CONFIG_PPC_FSL_BOOK3E)	+= cpu_setup_fsl_booke.o
 obj-$(CONFIG_PPC_DOORBELL)	+= dbell.o
 obj-$(CONFIG_JUMP_LABEL)	+= jump_label.o
 
-extra-$(CONFIG_PPC64)		:= head_64.o
-extra-$(CONFIG_PPC_BOOK3S_32)	:= head_book3s_32.o
-extra-$(CONFIG_40x)		:= head_40x.o
-extra-$(CONFIG_44x)		:= head_44x.o
-extra-$(CONFIG_FSL_BOOKE)	:= head_fsl_booke.o
-extra-$(CONFIG_PPC_8xx)		:= head_8xx.o
+obj-$(CONFIG_PPC64)		+= head_64.o
+obj-$(CONFIG_PPC_BOOK3S_32)	+= head_book3s_32.o
+obj-$(CONFIG_40x)		+= head_40x.o
+obj-$(CONFIG_44x)		+= head_44x.o
+obj-$(CONFIG_FSL_BOOKE)		+= head_fsl_booke.o
+obj-$(CONFIG_PPC_8xx)		+= head_8xx.o
 extra-y				+= vmlinux.lds
 
 obj-$(CONFIG_RELOCATABLE)	+= reloc_$(BITS).o
@@ -198,12 +198,12 @@ KCOV_INSTRUMENT_paca.o := n
 CFLAGS_setup_64.o		+= -fno-stack-protector
 CFLAGS_paca.o			+= -fno-stack-protector
 
-extra-$(CONFIG_PPC_FPU)		+= fpu.o
-extra-$(CONFIG_ALTIVEC)		+= vector.o
-extra-$(CONFIG_PPC64)		+= entry_64.o
-extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)	+= prom_init.o
+obj-$(CONFIG_PPC_FPU)		+= fpu.o
+obj-$(CONFIG_ALTIVEC)		+= vector.o
+obj-$(CONFIG_PPC64)		+= entry_64.o
+obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)	+= prom_init.o
 
-extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)	+= prom_init_check
+obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)	+= prom_init_check
 
 quiet_cmd_prom_init_check = PROMCHK $@
       cmd_prom_init_check = $(CONFIG_SHELL) $< "$(NM)" $(obj)/prom_init.o; touch $@
arch/riscv/kernel/Makefile +1 -1
index 33bb60a354cd..db6e4b1294ba 100644
@@ -28,9 +28,9 @@ KASAN_SANITIZE_cpufeature.o := n
 endif
 endif
 
-extra-y += head.o
 extra-y += vmlinux.lds
 
+obj-y	+= head.o
 obj-y	+= soc.o
 obj-$(CONFIG_RISCV_ALTERNATIVE) += alternative.o
 obj-y	+= cpu.o
arch/s390/kernel/Makefile +2 -2
index 3cbfa9fddd9a..7ce00816b8df 100644
@@ -33,7 +33,7 @@ CFLAGS_stacktrace.o	+= -fno-optimize-sibling-calls
 CFLAGS_dumpstack.o	+= -fno-optimize-sibling-calls
 CFLAGS_unwind_bc.o	+= -fno-optimize-sibling-calls
 
-obj-y	:= traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
+obj-y	:= head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
 obj-y	+= processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
 obj-y	+= debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
 obj-y	+= sysinfo.o lgr.o os_info.o machine_kexec.o
@@ -42,7 +42,7 @@ obj-y	+= entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
 obj-y	+= nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
 obj-y	+= smp.o text_amode31.o stacktrace.o
 
-extra-y				+= head64.o vmlinux.lds
+extra-y				+= vmlinux.lds
 
 obj-$(CONFIG_SYSFS)		+= nospec-sysfs.o
 CFLAGS_REMOVE_nospec-branch.o	+= $(CC_FLAGS_EXPOLINE)
arch/sh/kernel/Makefile +2 -2
index aa0fbc9202b1..69cd9ac4b2ab 100644
@@ -3,7 +3,7 @@
 # Makefile for the Linux/SuperH kernel.
 #
 
-extra-y	:= head_32.o vmlinux.lds
+extra-y	:= vmlinux.lds
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not profile debug and lowlevel utilities
@@ -12,7 +12,7 @@ endif
 
 CFLAGS_REMOVE_return_address.o = -pg
 
-obj-y	:= debugtraps.o dumpstack.o 		\
+obj-y	:= head_32.o debugtraps.o dumpstack.o				\
 	   idle.o io.o irq.o irq_32.o kdebugfs.o			\
 	   machvec.o nmi_debug.o process.o				\
 	   process_32.o ptrace.o ptrace_32.o				\
arch/sparc/kernel/Makefile +1 -2
index d3a0e072ebe8..b328e4a0bd57 100644
@@ -7,8 +7,6 @@
 asflags-y := -ansi
 ccflags-y := -Werror
 
-extra-y     := head_$(BITS).o
-
 # Undefine sparc when processing vmlinux.lds - it is used
 # And teach CPP we are doing $(BITS) builds (for this case)
 CPPFLAGS_vmlinux.lds := -Usparc -m$(BITS)
@@ -22,6 +20,7 @@ CFLAGS_REMOVE_perf_event.o := -pg
 CFLAGS_REMOVE_pcr.o := -pg
 endif
 
+obj-y                   := head_$(BITS).o
 obj-$(CONFIG_SPARC64)   += urtt_fill.o
 obj-$(CONFIG_SPARC32)   += entry.o wof.o wuf.o
 obj-$(CONFIG_SPARC32)   += etrap_32.o
arch/x86/kernel/Makefile +5 -5
index a20a5ebfacd7..956e50ca06e0 100644
@@ -3,10 +3,6 @@
 # Makefile for the linux kernel.
 #
 
-extra-y	:= head_$(BITS).o
-extra-y	+= head$(BITS).o
-extra-y	+= ebda.o
-extra-y	+= platform-quirks.o
 extra-y	+= vmlinux.lds
 
 CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE)
@@ -42,7 +38,11 @@ KCOV_INSTRUMENT		:= n
 
 CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace
 
-obj-y			:= process_$(BITS).o signal.o
+obj-y			+= head_$(BITS).o
+obj-y			+= head$(BITS).o
+obj-y			+= ebda.o
+obj-y			+= platform-quirks.o
+obj-y			+= process_$(BITS).o signal.o
 obj-$(CONFIG_COMPAT)	+= signal_compat.o
 obj-y			+= traps.o idt.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y			+= time.o ioport.o dumpstack.o nmi.o
arch/xtensa/kernel/Makefile +2 -2
index 897c1c741058..f28b8e3d717e 100644
@@ -3,9 +3,9 @@
 # Makefile for the Linux/Xtensa kernel.
 #
 
-extra-y := head.o vmlinux.lds
+extra-y := vmlinux.lds
 
-obj-y := align.o coprocessor.o entry.o irq.o platform.o process.o \
+obj-y := head.o align.o coprocessor.o entry.o irq.o platform.o process.o \
 	 ptrace.o setup.o signal.o stacktrace.o syscall.o time.o traps.o \
 	 vectors.o
 
scripts/Makefile.modpost +2 -3
index d7d3138c5ecc..4f74370ad1ee 100644
@@ -70,13 +70,12 @@ quiet_cmd_vmlinux_objs = GEN     $@
 	for f in $(real-prereqs); do	\
 		case $${f} in		\
 		*libgcc.a) ;;		\
-		*.a) $(AR) t $${f} ;;	\
-		*) echo $${f} ;;	\
+		*) $(AR) t $${f} ;;	\
 		esac			\
 	done > $@
 
 targets += .vmlinux.objs
-.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+.vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 	$(call if_changed,vmlinux_objs)
 
 vmlinux.o-if-present := $(wildcard vmlinux.o)
scripts/Makefile.vmlinux_o +3 -3
index 84019814f33f..81a4e0484457 100644
@@ -18,7 +18,7 @@ quiet_cmd_gen_initcalls_lds = GEN     $@
 	$(PERL) $(real-prereqs) > $@
 
 .tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \
-		$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+		vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 	$(call if_changed,gen_initcalls_lds)
 
 targets := .tmp_initcalls.lds
@@ -55,7 +55,7 @@ quiet_cmd_ld_vmlinux.o = LD      $@
       cmd_ld_vmlinux.o = \
 	$(LD) ${KBUILD_LDFLAGS} -r -o $@ \
 	$(addprefix -T , $(initcalls-lds)) \
-	--whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \
+	--whole-archive vmlinux.a --no-whole-archive \
 	--start-group $(KBUILD_VMLINUX_LIBS) --end-group \
 	$(cmd_objtool)
 
@@ -64,7 +64,7 @@ define rule_ld_vmlinux.o
 	$(call cmd,gen_objtooldep)
 endef
 
-vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 	$(call if_changed_rule,ld_vmlinux.o)
 
 targets += vmlinux.o
scripts/clang-tools/gen_compile_commands.py +1 -18
index 47da25b3ba7d..d800b2c0af97 100755
@@ -109,20 +109,6 @@ def to_cmdfile(path):
     return os.path.join(dir, '.' + base + '.cmd')
 
 
-def cmdfiles_for_o(obj):
-    """Generate the iterator of .cmd files associated with the object
-
-    Yield the .cmd file used to build the given object
-
-    Args:
-        obj: The object path
-
-    Yields:
-        The path to .cmd file
-    """
-    yield to_cmdfile(obj)
-
-
 def cmdfiles_for_a(archive, ar):
     """Generate the iterator of .cmd files associated with the archive.
 
@@ -211,13 +197,10 @@ def main():
     for path in paths:
         # If 'path' is a directory, handle all .cmd files under it.
         # Otherwise, handle .cmd files associated with the file.
-        # Most of built-in objects are linked via archives (built-in.a or lib.a)
-        # but some objects are linked to vmlinux directly.
+        # built-in objects are linked via vmlinux.a
         # Modules are listed in modules.order.
         if os.path.isdir(path):
             cmdfiles = cmdfiles_in_dir(path)
-        elif path.endswith('.o'):
-            cmdfiles = cmdfiles_for_o(path)
         elif path.endswith('.a'):
             cmdfiles = cmdfiles_for_a(path, ar)
         elif path.endswith('modules.order'):
scripts/link-vmlinux.sh +4 -6
index 6a197d8a88ac..23ac13fd9d89 100755
@@ -3,17 +3,15 @@
 #
 # link vmlinux
 #
-# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and
-# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories
-# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
+# vmlinux is linked from the objects in vmlinux.a and $(KBUILD_VMLINUX_LIBS).
+# vmlinux.a contains objects that are linked unconditionally.
 # $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
 # (not within --whole-archive), and do not require symbol indexes added.
 #
 # vmlinux
 #   ^
 #   |
-#   +--< $(KBUILD_VMLINUX_OBJS)
-#   |    +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
+#   +--< vmlinux.a
 #   |
 #   +--< $(KBUILD_VMLINUX_LIBS)
 #   |    +--< lib/lib.a + more
@@ -67,7 +65,7 @@ vmlinux_link()
 		objs=vmlinux.o
 		libs=
 	else
-		objs="${KBUILD_VMLINUX_OBJS}"
+		objs=vmlinux.a
 		libs="${KBUILD_VMLINUX_LIBS}"
 	fi
 
Signature · 1 line
2.34.1
#13 lore raw

Re: [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head

Quoted 35 lines · Masahiro Yamada

The objects placed at the head of vmlinux need special treatments:

- arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line.

- arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'.

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects.

There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py.

---

(no changes since v1)

arch/powerpc/kernel/Makefile +0 -1
@@ -198,12 +198,12 @@ KCOV_INSTRUMENT_paca.o := n
 CFLAGS_setup_64.o              += -fno-stack-protector
 CFLAGS_paca.o                  += -fno-stack-protector
 
-extra-$(CONFIG_PPC_FPU)                += fpu.o

arch/powerpc/kernel/Makefile KCOV_INSTRUMENT_paca.o := n · line 206

Quoted 10 lines
arch/powerpc/kernel/Makefile +5 -4
-extra-$(CONFIG_ALTIVEC)                += vector.o
-extra-$(CONFIG_PPC64)          += entry_64.o
-extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init.o
+obj-$(CONFIG_PPC_FPU)          += fpu.o
+obj-$(CONFIG_ALTIVEC)          += vector.o
+obj-$(CONFIG_PPC64)            += entry_64.o
+obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)   += prom_init.o
 
-extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init_check
+obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)   += prom_init_check

This line should not be changed.

I fixed it up locally.

https://lore.kernel.org/lkml/CAK7LNARzFmJjpyUciy1LRvaFo72aZcqRbzY-63ArpeszC+HfmQ@mail.gmail.com/

Signature · 2 lines
Best Regards
Masahiro Yamada
#14 lore raw

Re: [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head

In reply to Masahiro Yamada

Hi Yamada-san,

Quoted 14 lines · Masahiro Yamada

The objects placed at the head of vmlinux need special treatments:

- arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line.

- arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'.

Quoted 7 lines

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects.

There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py.

Thanks for your patch, which is now commit 6676e2cdd7c339dc ("kbuild:
use obj-y instead extra-y for objects placed at the head") in next-20220916.

[email protected] reported various build failures on m68k since next-20220916, which I have bisected to the above commit:

m68k-linux-gnu-ld: warning: cannot find entry symbol _start; defaulting to 0000000000001000
m68k-linux-gnu-ld: arch/m68k/kernel/setup.o: in function `setup_arch':
setup.c:(.init.text+0x2da): undefined reference to `availmem'
m68k-linux-gnu-ld: arch/m68k/kernel/early_printk.o: in function `debug_cons_write':
early_printk.c:(.ref.text+0x28): undefined reference to `debug_cons_nputs'
m68k-linux-gnu-ld: arch/m68k/mm/init.o: in function `mem_init':
init.c:(.init.text+0x24): undefined reference to `kernel_pg_dir'
m68k-linux-gnu-ld: init.c:(.init.text+0x10): undefined reference to `kernel_pg_dir'
m68k-linux-gnu-ld: init.c:(.init.text+0x1e): undefined reference to `kernel_pg_dir'
m68k-linux-gnu-ld: arch/m68k/mm/motorola.o: in function `cache_page':
motorola.c:(.text+0xfc): undefined reference to `m68k_supervisor_cachemode'
m68k-linux-gnu-ld: arch/m68k/mm/motorola.o: in function `mmu_page_ctor':
motorola.c:(.text+0x162): undefined reference to `m68k_pgtable_cachemode'
m68k-linux-gnu-ld: arch/m68k/mm/motorola.o: in function `paging_init':
motorola.c:(.init.text+0x3d0): undefined reference to `kernel_pg_dir'
m68k-linux-gnu-ld: motorola.c:(.init.text+0x1d8): undefined reference to `availmem'
m68k-linux-gnu-ld: motorola.c:(.init.text+0x32e): undefined reference to `m68k_supervisor_cachemode'
m68k-linux-gnu-ld: motorola.c:(.init.text+0x3a6): undefined reference to `kernel_pg_dir'
m68k-linux-gnu-ld: arch/m68k/q40/config.o: in function `q40_mem_console_write':
config.c:(.text+0x25c): undefined reference to `q40_mem_cptr'
m68k-linux-gnu-ld: config.c:(.text+0x254): undefined reference to `q40_mem_cptr'
m68k-linux-gnu-ld: arch/m68k/q40/config.o: in function `q40_debug_setup':
config.c:(.init.text+0x28): undefined reference to `q40_mem_cptr'
m68k-linux-gnu-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_abort_int':
config.c:(.text+0x4): undefined reference to `mvme_bdid'
m68k-linux-gnu-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_get_model':
config.c:(.text+0xc6): undefined reference to `mvme_bdid'
m68k-linux-gnu-ld: config.c:(.text+0xcc): undefined reference to `mvme_bdid'
m68k-linux-gnu-ld: config.c:(.text+0xe8): undefined reference to `mvme_bdid'
m68k-linux-gnu-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_get_hardware_list':
config.c:(.text+0x146): undefined reference to `mvme_bdid'
m68k-linux-gnu-ld: arch/m68k/mvme16x/config.o:config.c:(.text+0x1ce):
more undefined references to `mvme_bdid' follow
m68k-linux-gnu-ld: kernel/extable.o: in function `core_kernel_text':
extable.c:(.text+0x52): undefined reference to `_stext'
m68k-linux-gnu-ld: kernel/kallsyms.o: in function `is_ksym_addr':
kallsyms.c:(.text+0x28e): undefined reference to `_stext'
m68k-linux-gnu-ld: kernel/crash_core.o: in function `crash_save_vmcoreinfo_init':
crash_core.c:(.init.text+0x4d8): undefined reference to `_stext'
m68k-linux-gnu-ld: crash_core.c:(.init.text+0x4c0): undefined reference to `kernel_pg_dir'
m68k-linux-gnu-ld: mm/page_alloc.o: in function `mem_init_print_info':
page_alloc.c:(.init.text+0xfe4): undefined reference to `_stext'
m68k-linux-gnu-ld: page_alloc.c:(.init.text+0x103c): undefined reference to `_stext'
m68k-linux-gnu-ld: mm/init-mm.o:(.data+0x24): undefined reference to `kernel_pg_dir'
m68k-linux-gnu-ld: mm/usercopy.o: in function `__check_object_size':
usercopy.c:(.text+0x15a): undefined reference to `_stext'
make[1]: *** [Makefile:1175: vmlinux] Error 1

Quoted 676 lines

---

(no changes since v1)

 Documentation/kbuild/makefiles.rst          | 18 +----------------
 Makefile                                    | 18 +++++++++++++----
 arch/alpha/kernel/Makefile                  |  4 ++--
 arch/arc/kernel/Makefile                    |  4 ++--
 arch/arm/kernel/Makefile                    |  4 ++--
 arch/arm64/kernel/Makefile                  |  4 ++--
 arch/csky/kernel/Makefile                   |  4 ++--
 arch/hexagon/kernel/Makefile                |  3 ++-
 arch/ia64/kernel/Makefile                   |  4 ++--
 arch/loongarch/kernel/Makefile              |  4 ++--
 arch/m68k/68000/Makefile                    |  2 +-
 arch/m68k/coldfire/Makefile                 |  2 +-
 arch/m68k/kernel/Makefile                   | 21 ++++++++++----------
 arch/microblaze/kernel/Makefile             |  4 ++--
 arch/mips/kernel/Makefile                   |  4 ++--
 arch/nios2/kernel/Makefile                  |  2 +-
 arch/openrisc/kernel/Makefile               |  4 ++--
 arch/parisc/kernel/Makefile                 |  4 ++--
 arch/powerpc/kernel/Makefile                | 22 ++++++++++-----------
 arch/riscv/kernel/Makefile                  |  2 +-
 arch/s390/kernel/Makefile                   |  4 ++--
 arch/sh/kernel/Makefile                     |  4 ++--
 arch/sparc/kernel/Makefile                  |  3 +--
 arch/x86/kernel/Makefile                    | 10 +++++-----
 arch/xtensa/kernel/Makefile                 |  4 ++--
 scripts/Makefile.modpost                    |  5 ++---
 scripts/Makefile.vmlinux_o                  |  6 +++---
 scripts/clang-tools/gen_compile_commands.py | 19 +-----------------
 scripts/link-vmlinux.sh                     | 10 ++++------
 29 files changed, 87 insertions(+), 112 deletions(-)
Documentation/kbuild/makefiles.rst +1 -17
index 11a296e52d68..07c7e5a843c1 100644
@@ -340,19 +340,7 @@ more details, with real examples.
 
        Examples are:
 
-       1) head objects
-
-           Some objects must be placed at the head of vmlinux. They are
-           directly linked to vmlinux without going through built-in.a
-           A typical use-case is an object that contains the entry point.
-
-           arch/$(SRCARCH)/Makefile should specify such objects as head-y.
-
-           Discussion:
-             Given that we can control the section order in the linker script,
-             why do we need head-y?
-
-       2) vmlinux linker script
+       1) vmlinux linker script
 
            The linker script for vmlinux is located at
            arch/$(SRCARCH)/kernel/vmlinux.lds
@@ -360,10 +348,6 @@ more details, with real examples.
        Example::
 
                # arch/x86/kernel/Makefile
-               extra-y := head_$(BITS).o
-               extra-y += head$(BITS).o
-               extra-y += ebda.o
-               extra-y += platform-quirks.o
                extra-y += vmlinux.lds
 
        $(extra-y) should only contain targets needed for vmlinux.
Makefile +14 -4
index f9ee16bd212d..f2d06aaaefd3 100644
@@ -1113,7 +1113,7 @@ clean-dirs        := $(vmlinux-alldirs)
 export ARCH_CORE       := $(core-y)
 export ARCH_DRIVERS    := $(drivers-y)
 # Externally visible symbols (used by link-vmlinux.sh)
-KBUILD_VMLINUX_OBJS := $(head-y) ./built-in.a
+KBUILD_VMLINUX_OBJS := ./built-in.a
 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
 ifdef CONFIG_MODULES
 KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
@@ -1122,7 +1122,7 @@ else
 KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
 endif
 
-export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
+export KBUILD_VMLINUX_LIBS
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 # used by scripts/Makefile.package
 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools)
@@ -1151,8 +1151,18 @@ quiet_cmd_autoksyms_h = GEN     $@
 $(autoksyms_h):
        $(call cmd,autoksyms_h)
 
+quiet_cmd_ar_vmlinux.a = AR      $@
+      cmd_ar_vmlinux.a = \
+       rm -f $@; \
+       $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
+       $(AR) mPi $$($(AR) t $@ | head -n1) $@ $(head-y)
+
+targets += vmlinux.a
+vmlinux.a: $(KBUILD_VMLINUX_OBJS) FORCE
+       $(call if_changed,ar_vmlinux.a)
+
 targets += vmlinux.o
-vmlinux.o: autoksyms_recursive $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+vmlinux.o: autoksyms_recursive vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
 
 ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
@@ -1909,7 +1919,7 @@ quiet_cmd_gen_compile_commands = GEN     $@
       cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
 
 $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
-       $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \
+       $(if $(KBUILD_EXTMOD),, vmlinux.a $(KBUILD_VMLINUX_LIBS)) \
        $(if $(CONFIG_MODULES), $(MODORDER)) FORCE
        $(call if_changed,gen_compile_commands)
 
arch/alpha/kernel/Makefile +2 -2
index 5a74581bf0ee..5a5b0a8b7c6a 100644
@@ -3,11 +3,11 @@
 # Makefile for the linux kernel.
 #
 
-extra-y                := head.o vmlinux.lds
+extra-y                := vmlinux.lds
 asflags-y      := $(KBUILD_CFLAGS)
 ccflags-y      := -Wno-sign-compare
 
-obj-y    := entry.o traps.o process.o osf_sys.o irq.o \
+obj-y    := head.o entry.o traps.o process.o osf_sys.o irq.o \
            irq_alpha.o signal.o setup.o ptrace.o time.o \
            systbls.o err_common.o io.o bugs.o
 
arch/arc/kernel/Makefile +2 -2
index 8c4fc4b54c14..0723d888ac44 100644
@@ -3,7 +3,7 @@
 # Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 #
 
-obj-y  := arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o
+obj-y  := head.o arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o
 obj-y  += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o
 obj-$(CONFIG_ISA_ARCOMPACT)            += entry-compact.o intc-compact.o
 obj-$(CONFIG_ISA_ARCV2)                        += entry-arcv2.o intc-arcv2.o
@@ -31,4 +31,4 @@ else
 obj-y += ctx_sw_asm.o
 endif
 
-extra-y := vmlinux.lds head.o
+extra-y := vmlinux.lds
arch/arm/kernel/Makefile +2 -2
index 553866751e1a..8feaa3217ec5 100644
@@ -89,7 +89,7 @@ obj-$(CONFIG_VDSO)            += vdso.o
 obj-$(CONFIG_EFI)              += efi.o
 obj-$(CONFIG_PARAVIRT) += paravirt.o
 
-head-y                 := head$(MMUEXT).o
+obj-y                  += head$(MMUEXT).o
 obj-$(CONFIG_DEBUG_LL) += debug.o
 obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
 obj-$(CONFIG_ARM_PATCH_PHYS_VIRT)      += phys2virt.o
@@ -109,4 +109,4 @@ obj-$(CONFIG_HAVE_ARM_SMCCC)        += smccc-call.o
 
 obj-$(CONFIG_GENERIC_CPU_VULNERABILITIES) += spectre.o
 
-extra-y := $(head-y) vmlinux.lds
+extra-y := vmlinux.lds
arch/arm64/kernel/Makefile +2 -2
index 1add7b01efa7..b619ff207a57 100644
@@ -85,8 +85,8 @@ $(obj)/vdso-wrap.o: $(obj)/vdso/vdso.so
 $(obj)/vdso32-wrap.o: $(obj)/vdso32/vdso.so
 
 obj-y                                  += probes/
-head-y                                 := head.o
-extra-y                                        += $(head-y) vmlinux.lds
+obj-y                                  += head.o
+extra-y                                        += vmlinux.lds
 
 ifeq ($(CONFIG_DEBUG_EFI),y)
 AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\""
arch/csky/kernel/Makefile +2 -2
index 6f14c924b20d..8a868316b912 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
-extra-y := head.o vmlinux.lds
+extra-y := vmlinux.lds
 
-obj-y += entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/
+obj-y += head.o entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/
 obj-y += power.o syscall.o syscall_table.o setup.o io.o
 obj-y += process.o cpu-probe.o ptrace.o stacktrace.o
 obj-y += probes/
arch/hexagon/kernel/Makefile +2 -1
index fae3dce32fde..e73cb321630e 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
-extra-y := head.o vmlinux.lds
+extra-y := vmlinux.lds
 
+obj-y += head.o
 obj-$(CONFIG_SMP) += smp.o
 
 obj-y += setup.o irq_cpu.o traps.o syscalltab.o signal.o time.o
arch/ia64/kernel/Makefile +2 -2
index 08d4a2ba0652..4a1fcb121dda 100644
@@ -7,9 +7,9 @@ ifdef CONFIG_DYNAMIC_FTRACE
 CFLAGS_REMOVE_ftrace.o = -pg
 endif
 
-extra-y        := head.o vmlinux.lds
+extra-y        := vmlinux.lds
 
-obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o irq.o irq_ia64.o  \
+obj-y := head.o entry.o efi.o efi_stub.o gate-data.o fsys.o irq.o irq_ia64.o   \
         irq_lsapic.o ivt.o pal.o patch.o process.o ptrace.o sal.o              \
         salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \
         unwind.o mca.o mca_asm.o topology.o dma-mapping.o iosapic.o acpi.o \
arch/loongarch/kernel/Makefile +2 -2
index e5be17009fe8..6c33b5c45573 100644
@@ -3,9 +3,9 @@
 # Makefile for the Linux/LoongArch kernel.
 #
 
-extra-y                := head.o vmlinux.lds
+extra-y                := vmlinux.lds
 
-obj-y          += cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
+obj-y          += head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
                   traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \
                   elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o
 
arch/m68k/68000/Makefile +1 -1
index 674541fdf5b8..279560add577 100644
@@ -17,4 +17,4 @@ obj-$(CONFIG_DRAGEN2) += dragen2.o
 obj-$(CONFIG_UCSIMM)   += ucsimm.o
 obj-$(CONFIG_UCDIMM)   += ucsimm.o
 
-extra-y                := head.o
+obj-y                  += head.o
arch/m68k/coldfire/Makefile +1 -1
index 9419a6c1f036..c56bc0dc7f2e 100644
@@ -45,4 +45,4 @@ obj-$(CONFIG_STMARK2) += stmark2.o
 obj-$(CONFIG_PCI)      += pci.o
 
 obj-y                  += gpio.o
-extra-y := head.o
+obj-y                  += head.o
arch/m68k/kernel/Makefile +11 -10
index c0833da6a2ca..1755e6cd309f 100644
@@ -3,18 +3,19 @@
 # Makefile for the linux kernel.
 #
 
-extra-$(CONFIG_AMIGA)  := head.o
-extra-$(CONFIG_ATARI)  := head.o
-extra-$(CONFIG_MAC)    := head.o
-extra-$(CONFIG_APOLLO) := head.o
-extra-$(CONFIG_VME)    := head.o
-extra-$(CONFIG_HP300)  := head.o
-extra-$(CONFIG_Q40)    := head.o
-extra-$(CONFIG_SUN3X)  := head.o
-extra-$(CONFIG_VIRT)   := head.o
-extra-$(CONFIG_SUN3)   := sun3-head.o
 extra-y                        += vmlinux.lds
 
+obj-$(CONFIG_AMIGA)    := head.o
+obj-$(CONFIG_ATARI)    := head.o
+obj-$(CONFIG_MAC)      := head.o
+obj-$(CONFIG_APOLLO)   := head.o
+obj-$(CONFIG_VME)      := head.o
+obj-$(CONFIG_HP300)    := head.o
+obj-$(CONFIG_Q40)      := head.o
+obj-$(CONFIG_SUN3X)    := head.o
+obj-$(CONFIG_VIRT)     := head.o
+obj-$(CONFIG_SUN3)     := sun3-head.o
+
 obj-y  := entry.o irq.o module.o process.o ptrace.o
 obj-y  += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
 
arch/microblaze/kernel/Makefile +2 -2
index 15a20eb814ce..4393bee64eaf 100644
@@ -12,9 +12,9 @@ CFLAGS_REMOVE_ftrace.o = -pg
 CFLAGS_REMOVE_process.o = -pg
 endif
 
-extra-y := head.o vmlinux.lds
+extra-y := vmlinux.lds
 
-obj-y += dma.o exceptions.o \
+obj-y += head.o dma.o exceptions.o \
        hw_exception_handler.o irq.o \
        process.o prom.o ptrace.o \
        reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o
arch/mips/kernel/Makefile +2 -2
index 7c96282bff2e..5d1addac5e28 100644
@@ -3,9 +3,9 @@
 # Makefile for the Linux/MIPS kernel.
 #
 
-extra-y                := head.o vmlinux.lds
+extra-y                := vmlinux.lds
 
-obj-y          += branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \
+obj-y          += head.o branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \
                   process.o prom.o ptrace.o reset.o setup.o signal.o \
                   syscall.o time.o topology.o traps.o unaligned.o watch.o \
                   vdso.o cacheinfo.o
arch/nios2/kernel/Makefile +1 -1
index 0b645e1e3158..78a913181fa1 100644
@@ -3,9 +3,9 @@
 # Makefile for the nios2 linux kernel.
 #
 
-extra-y        += head.o
 extra-y        += vmlinux.lds
 
+obj-y  += head.o
 obj-y  += cpuinfo.o
 obj-y  += entry.o
 obj-y  += insnemu.o
arch/openrisc/kernel/Makefile +2 -2
index 2d172e79f58d..79129161f3e0 100644
@@ -3,9 +3,9 @@
 # Makefile for the linux kernel.
 #
 
-extra-y        := head.o vmlinux.lds
+extra-y        := vmlinux.lds
 
-obj-y  := setup.o or32_ksyms.o process.o dma.o \
+obj-y  := head.o setup.o or32_ksyms.o process.o dma.o \
           traps.o time.o irq.o entry.o ptrace.o signal.o \
           sys_call_table.o unwinder.o
 
arch/parisc/kernel/Makefile +2 -2
index d0bfac89a842..3d138c9cf9ce 100644
@@ -3,9 +3,9 @@
 # Makefile for arch/parisc/kernel
 #
 
-extra-y                        := head.o vmlinux.lds
+extra-y                := vmlinux.lds
 
-obj-y          := cache.o pacache.o setup.o pdt.o traps.o time.o irq.o \
+obj-y          := head.o cache.o pacache.o setup.o pdt.o traps.o time.o irq.o \
                   pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \
                   ptrace.o hardware.o inventory.o drivers.o alternative.o \
                   signal.o hpmc.o real2.o parisc_ksyms.o unaligned.o \
arch/powerpc/kernel/Makefile +11 -11
index 06d2d1f78f71..f264d9b2cb63 100644
@@ -118,12 +118,12 @@ obj-$(CONFIG_PPC_FSL_BOOK3E)      += cpu_setup_fsl_booke.o
 obj-$(CONFIG_PPC_DOORBELL)     += dbell.o
 obj-$(CONFIG_JUMP_LABEL)       += jump_label.o
 
-extra-$(CONFIG_PPC64)          := head_64.o
-extra-$(CONFIG_PPC_BOOK3S_32)  := head_book3s_32.o
-extra-$(CONFIG_40x)            := head_40x.o
-extra-$(CONFIG_44x)            := head_44x.o
-extra-$(CONFIG_FSL_BOOKE)      := head_fsl_booke.o
-extra-$(CONFIG_PPC_8xx)                := head_8xx.o
+obj-$(CONFIG_PPC64)            += head_64.o
+obj-$(CONFIG_PPC_BOOK3S_32)    += head_book3s_32.o
+obj-$(CONFIG_40x)              += head_40x.o
+obj-$(CONFIG_44x)              += head_44x.o
+obj-$(CONFIG_FSL_BOOKE)                += head_fsl_booke.o
+obj-$(CONFIG_PPC_8xx)          += head_8xx.o
 extra-y                                += vmlinux.lds
 
 obj-$(CONFIG_RELOCATABLE)      += reloc_$(BITS).o
@@ -198,12 +198,12 @@ KCOV_INSTRUMENT_paca.o := n
 CFLAGS_setup_64.o              += -fno-stack-protector
 CFLAGS_paca.o                  += -fno-stack-protector
 
-extra-$(CONFIG_PPC_FPU)                += fpu.o
-extra-$(CONFIG_ALTIVEC)                += vector.o
-extra-$(CONFIG_PPC64)          += entry_64.o
-extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init.o
+obj-$(CONFIG_PPC_FPU)          += fpu.o
+obj-$(CONFIG_ALTIVEC)          += vector.o
+obj-$(CONFIG_PPC64)            += entry_64.o
+obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)   += prom_init.o
 
-extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init_check
+obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)   += prom_init_check
 
 quiet_cmd_prom_init_check = PROMCHK $@
       cmd_prom_init_check = $(CONFIG_SHELL) $< "$(NM)" $(obj)/prom_init.o; touch $@
arch/riscv/kernel/Makefile +1 -1
index 33bb60a354cd..db6e4b1294ba 100644
@@ -28,9 +28,9 @@ KASAN_SANITIZE_cpufeature.o := n
 endif
 endif
 
-extra-y += head.o
 extra-y += vmlinux.lds
 
+obj-y  += head.o
 obj-y  += soc.o
 obj-$(CONFIG_RISCV_ALTERNATIVE) += alternative.o
 obj-y  += cpu.o
arch/s390/kernel/Makefile +2 -2
index 3cbfa9fddd9a..7ce00816b8df 100644
@@ -33,7 +33,7 @@ CFLAGS_stacktrace.o   += -fno-optimize-sibling-calls
 CFLAGS_dumpstack.o     += -fno-optimize-sibling-calls
 CFLAGS_unwind_bc.o     += -fno-optimize-sibling-calls
 
-obj-y  := traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
+obj-y  := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
 obj-y  += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
 obj-y  += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
 obj-y  += sysinfo.o lgr.o os_info.o machine_kexec.o
@@ -42,7 +42,7 @@ obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
 obj-y  += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
 obj-y  += smp.o text_amode31.o stacktrace.o
 
-extra-y                                += head64.o vmlinux.lds
+extra-y                                += vmlinux.lds
 
 obj-$(CONFIG_SYSFS)            += nospec-sysfs.o
 CFLAGS_REMOVE_nospec-branch.o  += $(CC_FLAGS_EXPOLINE)
arch/sh/kernel/Makefile +2 -2
index aa0fbc9202b1..69cd9ac4b2ab 100644
@@ -3,7 +3,7 @@
 # Makefile for the Linux/SuperH kernel.
 #
 
-extra-y        := head_32.o vmlinux.lds
+extra-y        := vmlinux.lds
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not profile debug and lowlevel utilities
@@ -12,7 +12,7 @@ endif
 
 CFLAGS_REMOVE_return_address.o = -pg
 
-obj-y  := debugtraps.o dumpstack.o             \
+obj-y  := head_32.o debugtraps.o dumpstack.o                           \
           idle.o io.o irq.o irq_32.o kdebugfs.o                        \
           machvec.o nmi_debug.o process.o                              \
           process_32.o ptrace.o ptrace_32.o                            \
arch/sparc/kernel/Makefile +1 -2
index d3a0e072ebe8..b328e4a0bd57 100644
@@ -7,8 +7,6 @@
 asflags-y := -ansi
 ccflags-y := -Werror
 
-extra-y     := head_$(BITS).o
-
 # Undefine sparc when processing vmlinux.lds - it is used
 # And teach CPP we are doing $(BITS) builds (for this case)
 CPPFLAGS_vmlinux.lds := -Usparc -m$(BITS)
@@ -22,6 +20,7 @@ CFLAGS_REMOVE_perf_event.o := -pg
 CFLAGS_REMOVE_pcr.o := -pg
 endif
 
+obj-y                   := head_$(BITS).o
 obj-$(CONFIG_SPARC64)   += urtt_fill.o
 obj-$(CONFIG_SPARC32)   += entry.o wof.o wuf.o
 obj-$(CONFIG_SPARC32)   += etrap_32.o
arch/x86/kernel/Makefile +5 -5
index a20a5ebfacd7..956e50ca06e0 100644
@@ -3,10 +3,6 @@
 # Makefile for the linux kernel.
 #
 
-extra-y        := head_$(BITS).o
-extra-y        += head$(BITS).o
-extra-y        += ebda.o
-extra-y        += platform-quirks.o
 extra-y        += vmlinux.lds
 
 CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE)
@@ -42,7 +38,11 @@ KCOV_INSTRUMENT              := n
 
 CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace
 
-obj-y                  := process_$(BITS).o signal.o
+obj-y                  += head_$(BITS).o
+obj-y                  += head$(BITS).o
+obj-y                  += ebda.o
+obj-y                  += platform-quirks.o
+obj-y                  += process_$(BITS).o signal.o
 obj-$(CONFIG_COMPAT)   += signal_compat.o
 obj-y                  += traps.o idt.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y                  += time.o ioport.o dumpstack.o nmi.o
arch/xtensa/kernel/Makefile +2 -2
index 897c1c741058..f28b8e3d717e 100644
@@ -3,9 +3,9 @@
 # Makefile for the Linux/Xtensa kernel.
 #
 
-extra-y := head.o vmlinux.lds
+extra-y := vmlinux.lds
 
-obj-y := align.o coprocessor.o entry.o irq.o platform.o process.o \
+obj-y := head.o align.o coprocessor.o entry.o irq.o platform.o process.o \
         ptrace.o setup.o signal.o stacktrace.o syscall.o time.o traps.o \
         vectors.o
 
scripts/Makefile.modpost +2 -3
index d7d3138c5ecc..4f74370ad1ee 100644
@@ -70,13 +70,12 @@ quiet_cmd_vmlinux_objs = GEN     $@
        for f in $(real-prereqs); do    \
                case $${f} in           \
                *libgcc.a) ;;           \
-               *.a) $(AR) t $${f} ;;   \
-               *) echo $${f} ;;        \
+               *) $(AR) t $${f} ;;     \
                esac                    \
        done > $@
 
 targets += .vmlinux.objs
-.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+.vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
        $(call if_changed,vmlinux_objs)
 
 vmlinux.o-if-present := $(wildcard vmlinux.o)
scripts/Makefile.vmlinux_o +3 -3
index 84019814f33f..81a4e0484457 100644
@@ -18,7 +18,7 @@ quiet_cmd_gen_initcalls_lds = GEN     $@
        $(PERL) $(real-prereqs) > $@
 
 .tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \
-               $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+               vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
        $(call if_changed,gen_initcalls_lds)
 
 targets := .tmp_initcalls.lds
@@ -55,7 +55,7 @@ quiet_cmd_ld_vmlinux.o = LD      $@
       cmd_ld_vmlinux.o = \
        $(LD) ${KBUILD_LDFLAGS} -r -o $@ \
        $(addprefix -T , $(initcalls-lds)) \
-       --whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \
+       --whole-archive vmlinux.a --no-whole-archive \
        --start-group $(KBUILD_VMLINUX_LIBS) --end-group \
        $(cmd_objtool)
 
@@ -64,7 +64,7 @@ define rule_ld_vmlinux.o
        $(call cmd,gen_objtooldep)
 endef
 
-vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
        $(call if_changed_rule,ld_vmlinux.o)
 
 targets += vmlinux.o
scripts/clang-tools/gen_compile_commands.py +1 -18
index 47da25b3ba7d..d800b2c0af97 100755
@@ -109,20 +109,6 @@ def to_cmdfile(path):
     return os.path.join(dir, '.' + base + '.cmd')
 
 
-def cmdfiles_for_o(obj):
-    """Generate the iterator of .cmd files associated with the object
-
-    Yield the .cmd file used to build the given object
-
-    Args:
-        obj: The object path
-
-    Yields:
-        The path to .cmd file
-    """
-    yield to_cmdfile(obj)
-
-
 def cmdfiles_for_a(archive, ar):
     """Generate the iterator of .cmd files associated with the archive.
 
@@ -211,13 +197,10 @@ def main():
     for path in paths:
         # If 'path' is a directory, handle all .cmd files under it.
         # Otherwise, handle .cmd files associated with the file.
-        # Most of built-in objects are linked via archives (built-in.a or lib.a)
-        # but some objects are linked to vmlinux directly.
+        # built-in objects are linked via vmlinux.a
         # Modules are listed in modules.order.
         if os.path.isdir(path):
             cmdfiles = cmdfiles_in_dir(path)
-        elif path.endswith('.o'):
-            cmdfiles = cmdfiles_for_o(path)
         elif path.endswith('.a'):
             cmdfiles = cmdfiles_for_a(path, ar)
         elif path.endswith('modules.order'):
scripts/link-vmlinux.sh +4 -7
index 6a197d8a88ac..23ac13fd9d89 100755
@@ -3,17 +3,15 @@
 #
 # link vmlinux
 #
-# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and
-# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories
-# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
+# vmlinux is linked from the objects in vmlinux.a and $(KBUILD_VMLINUX_LIBS).
+# vmlinux.a contains objects that are linked unconditionally.
 # $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
 # (not within --whole-archive), and do not require symbol indexes added.
 #
 # vmlinux
 #   ^
 #   |
-#   +--< $(KBUILD_VMLINUX_OBJS)
-#   |    +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
+#   +--< vmlinux.a
 #   |
 #   +--< $(KBUILD_VMLINUX_LIBS)
 #   |    +--< lib/lib.a + more
@@ -67,7 +65,7 @@ vmlinux_link()
                objs=vmlinux.o
                libs=
        else
-               objs="${KBUILD_VMLINUX_OBJS}"
+               objs=vmlinux.a
                libs="${KBUILD_VMLINUX_LIBS}"
        fi
 
--
Quoted 2 lines

2.34.1

--
Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#15 lore raw

Re: [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head

Quoted 25 lines · Geert Uytterhoeven

Hi Yamada-san,

Quoted 21 lines · Masahiro Yamada

The objects placed at the head of vmlinux need special treatments:

- arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line.

- arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'.

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects.

There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py.

Thanks for the report.

I will squash the following:

arch/m68k/kernel/Makefile +1 -1
index 1755e6cd309f..af015447dfb4 100644
@@ -16,7 +16,7 @@ obj-$(CONFIG_SUN3X)   := head.o
 obj-$(CONFIG_VIRT)     := head.o
 obj-$(CONFIG_SUN3)     := sun3-head.o
 
-obj-y  := entry.o irq.o module.o process.o ptrace.o
+obj-y  += entry.o irq.o module.o process.o ptrace.o
 obj-y  += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
 
 obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o

--
Best Regards
Masahiro Yamada

maintainer Reviewed-by
#16 lore raw

Re: [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head

Hi Yamada-san,

Quoted 35 lines · Masahiro Yamada
Quoted 15 lines · Geert Uytterhoeven
Quoted 14 lines · Masahiro Yamada

The objects placed at the head of vmlinux need special treatments:

- arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line.

- arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'.

Quoted 7 lines
Quoted 7 lines

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects.

There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py.

Thanks for the report.

I will squash the following:

arch/m68k/kernel/Makefile +0 -0
index 1755e6cd309f..af015447dfb4 100644

arch/m68k/kernel/Makefile obj-$(CONFIG_SUN3X) := head.o · line 22

Quoted 8 lines
arch/m68k/kernel/Makefile +1 -1
@@ -16,7 +16,7 @@ obj-$(CONFIG_SUN3X)   := head.o
 obj-$(CONFIG_VIRT)     := head.o
 obj-$(CONFIG_SUN3)     := sun3-head.o
 
-obj-y  := entry.o irq.o module.o process.o ptrace.o
+obj-y  += entry.o irq.o module.o process.o ptrace.o
 obj-y  += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
 
 obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o

Thank you, that fixed the build.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#17 lore raw

Re: [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head

In reply to Masahiro Yamada

Hi,

Quoted 14 lines · Masahiro Yamada

The objects placed at the head of vmlinux need special treatments:

- arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line.

- arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'.

Quoted 8 lines

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects.

There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py.

The following build failure is seen when building m68k:defconfig in next-20220919.

m68k-linux-ld: arch/m68k/kernel/setup.o: in function `setup_arch':
setup.c:(.init.text+0x2dc): undefined reference to `availmem'
m68k-linux-ld: arch/m68k/kernel/early_printk.o: in function `debug_cons_write':
early_printk.c:(.ref.text+0x28): undefined reference to `debug_cons_nputs'
m68k-linux-ld: arch/m68k/mm/init.o: in function `mem_init':
init.c:(.init.text+0x6e): undefined reference to `kernel_pg_dir'
m68k-linux-ld: init.c:(.init.text+0x10): undefined reference to `kernel_pg_dir'
m68k-linux-ld: init.c:(.init.text+0x1e): undefined reference to `kernel_pg_dir'
m68k-linux-ld: arch/m68k/mm/motorola.o: in function `cache_page':
motorola.c:(.text+0xfc): undefined reference to `m68k_supervisor_cachemode'
m68k-linux-ld: arch/m68k/mm/motorola.o: in function `mmu_page_ctor':
motorola.c:(.text+0x162): undefined reference to `m68k_pgtable_cachemode'
m68k-linux-ld: arch/m68k/mm/motorola.o: in function `paging_init':
motorola.c:(.init.text+0x3d2): undefined reference to `kernel_pg_dir'
m68k-linux-ld: motorola.c:(.init.text+0x1d8): undefined reference to `availmem'
m68k-linux-ld: motorola.c:(.init.text+0x32e): undefined reference to `m68k_supervisor_cachemode'
m68k-linux-ld: motorola.c:(.init.text+0x3a8): undefined reference to `kernel_pg_dir'
m68k-linux-ld: arch/m68k/q40/config.o: in function `q40_mem_console_write':
config.c:(.text+0x25c): undefined reference to `q40_mem_cptr'
m68k-linux-ld: config.c:(.text+0x254): undefined reference to `q40_mem_cptr'
m68k-linux-ld: arch/m68k/q40/config.o: in function `q40_debug_setup':
config.c:(.init.text+0x28): undefined reference to `q40_mem_cptr'
m68k-linux-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_abort_int':
config.c:(.text+0x4): undefined reference to `mvme_bdid'
m68k-linux-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_get_model':
config.c:(.text+0xc8): undefined reference to `mvme_bdid'
m68k-linux-ld: config.c:(.text+0xce): undefined reference to `mvme_bdid'
m68k-linux-ld: config.c:(.text+0xea): undefined reference to `mvme_bdid'
m68k-linux-ld: arch/m68k/mvme16x/config.o: in function `mvme16x_get_hardware_list':
config.c:(.text+0x148): undefined reference to `mvme_bdid'
m68k-linux-ld: arch/m68k/mvme16x/config.o:config.c:(.text+0x1d0): more undefined references to `mvme_bdid' follow
m68k-linux-ld: kernel/extable.o: in function `core_kernel_text':
extable.c:(.text+0x52): undefined reference to `_stext'
m68k-linux-ld: kernel/kallsyms.o: in function `is_ksym_addr':
kallsyms.c:(.text+0x31c): undefined reference to `_stext'
m68k-linux-ld: kernel/crash_core.o: in function `crash_save_vmcoreinfo_init':
crash_core.c:(.init.text+0x4d4): undefined reference to `_stext'
m68k-linux-ld: crash_core.c:(.init.text+0x4bc): undefined reference to `kernel_pg_dir'
m68k-linux-ld: mm/page_alloc.o: in function `mem_init_print_info':
page_alloc.c:(.init.text+0xff8): undefined reference to `_stext'
m68k-linux-ld: page_alloc.c:(.init.text+0x1050): undefined reference to `_stext'
m68k-linux-ld: mm/init-mm.o:(.data+0x18): undefined reference to `kernel_pg_dir'
m68k-linux-ld: mm/usercopy.o: in function `__check_object_size':
usercopy.c:(.text+0x15a): undefined reference to `_stext'

Bisect points to this patch (or its equivalent in next-20220919).

Guenter

---
# bad: [4c9ca5b1597e3222177ba2a94658f78fa5ef4f58] Add linux-next specific files for 20220919
# good: [521a547ced6477c54b4b0cc206000406c221b4d6] Linux 6.0-rc6
git bisect start 'HEAD' 'v6.0-rc6'
# bad: [8b4141305a585c4cb1147dcc164059dc3b5489e2] Merge branch 'drm-next' of git://git.freedesktop.org/git/drm/drm.git
git bisect bad 8b4141305a585c4cb1147dcc164059dc3b5489e2
# bad: [03e33baab7f2c3459bd268639af383cafe0c0a4b] Merge branch 'docs-next' of git://git.lwn.net/linux.git
git bisect bad 03e33baab7f2c3459bd268639af383cafe0c0a4b
# bad: [c1a464c761e4098899873c472b3756f557a3b73c] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
git bisect bad c1a464c761e4098899873c472b3756f557a3b73c
# bad: [59d922adf1c023a84bd4dd4fad0442221fd6347f] Merge branch 'for-next/core' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
git bisect bad 59d922adf1c023a84bd4dd4fad0442221fd6347f
# good: [166f57a723e13d816b09b2f27433f2c8ba2f06fe] Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git
git bisect good 166f57a723e13d816b09b2f27433f2c8ba2f06fe
# bad: [aaa38e8ca1345b2369051a6213f706d5107a20ba] Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git
git bisect bad aaa38e8ca1345b2369051a6213f706d5107a20ba
# good: [1081fb0f6d6e68186e1088db33396b11770a0710] perf vendor events arm64: Move REMOTE_ACCESS to "memory" category
git bisect good 1081fb0f6d6e68186e1088db33396b11770a0710
# bad: [4aaa1766cf8d19becdade98bff3960c6583b8d09] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git
git bisect bad 4aaa1766cf8d19becdade98bff3960c6583b8d09
# good: [a521c97e2a63490c238865763fc86942dce8d6bb] kbuild: rewrite check-local-export in sh/awk
git bisect good a521c97e2a63490c238865763fc86942dce8d6bb
# bad: [6676e2cdd7c339dc40331faccbaac1112d2c1d78] kbuild: use obj-y instead extra-y for objects placed at the head
git bisect bad 6676e2cdd7c339dc40331faccbaac1112d2c1d78
# good: [10d1d4b75525f3172c6930fb20445f669762ea95] kbuild: move core-y and drivers-y to ./Kbuild
git bisect good 10d1d4b75525f3172c6930fb20445f669762ea95
# good: [b8d366ae69fe633e697776b839ac52d3eecf07d3] kbuild: move vmlinux.o rule to the top Makefile
git bisect good b8d366ae69fe633e697776b839ac52d3eecf07d3
# good: [165b718fdd8c5a9165b4485019729c0cd8728120] kbuild: unify two modpost invocations
git bisect good 165b718fdd8c5a9165b4485019729c0cd8728120

# first bad commit: [6676e2cdd7c339dc40331faccbaac1112d2c1d78] kbuild: use obj-y instead extra-y for objects placed at the head
#18 lore raw

Re: [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head

Hi Günter,

Quoted 15 lines · Guenter Roeck
Quoted 14 lines · Masahiro Yamada

The objects placed at the head of vmlinux need special treatments:

- arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line.

- arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'.

Quoted 8 lines
Quoted 8 lines

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects.

There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py.

Where does this R-b come from? It was not present in Yamada-san's posting. Added by b4?

Quoted 2 lines

The following build failure is seen when building m68k:defconfig in next-20220919.

[...]

Quoted 1 line
# first bad commit: [6676e2cdd7c339dc40331faccbaac1112d2c1d78] kbuild: use obj-y instead extra-y for objects placed at the head

I did provide my R-b on Yamada-san's fix for this issue, which was sent later in this thread.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#19 lore raw

Re: [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head

Quoted 21 lines · Geert Uytterhoeven

Hi Günter,

Quoted 18 lines · Guenter Roeck
Quoted 17 lines · Masahiro Yamada

The objects placed at the head of vmlinux need special treatments:

- arch/$(SRCARCH)/Makefile adds them to head-y in order to place them before other archives in the linker command line.

- arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally linked to vmlinux. The objects listed in head-y are moved to the head of vmlinux.a by using 'ar m'.

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y for builtin objects.

Quoted 9 lines
Quoted 5 lines
Quoted 5 lines

There is no *.o that is directly linked to vmlinux. Drop unneeded code in scripts/clang-tools/gen_compile_commands.py.

Where does this R-b come from? It was not present in Yamada-san's posting. Added by b4?

Maybe added by patchwork ? That is where I picked up the mbox.

Guenter

Quoted 20 lines
Quoted 2 lines

The following build failure is seen when building m68k:defconfig in next-20220919.

[...]

Quoted 1 line
# first bad commit: [6676e2cdd7c339dc40331faccbaac1112d2c1d78] kbuild: use obj-y instead extra-y for objects placed at the head

I did provide my R-b on Yamada-san's fix for this issue, which was sent later in this thread.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#20 lore raw

PATCH v2 8/8 kbuild: remove head-y syntax

In reply to Masahiro Yamada

Kbuild puts the objects listed in head-y at the head of vmlinux. Conventionally, we do this for head*.S, which contains the kernel entry point.

A counter approach is to control the section order by the linker script. Actually, the code marked as __HEAD goes into the ".head.text" section, which is placed before the normal ".text" section.

I do not know if both of them are needed. From the build system perspective, head-y is not mandatory. If you can achieve the proper code placement by the linker script only, it would be cleaner.

I collected the current head-y objects into head-object-list.txt. It is a whitelist. My hope is it will be reduced in the long run.

---

(no changes since v1)

 Documentation/kbuild/makefiles.rst |  9 ++---
 Makefile                           |  4 +--
 arch/alpha/Makefile                |  2 --
 arch/arc/Makefile                  |  2 --
 arch/arm/Makefile                  |  3 --
 arch/arm64/Makefile                |  3 --
 arch/csky/Makefile                 |  2 --
 arch/hexagon/Makefile              |  2 --
 arch/ia64/Makefile                 |  1 -
 arch/loongarch/Makefile            |  2 --
 arch/m68k/Makefile                 |  9 -----
 arch/microblaze/Makefile           |  1 -
 arch/mips/Makefile                 |  2 --
 arch/nios2/Makefile                |  1 -
 arch/openrisc/Makefile             |  2 --
 arch/parisc/Makefile               |  2 --
 arch/powerpc/Makefile              | 12 -------
 arch/riscv/Makefile                |  2 --
 arch/s390/Makefile                 |  2 --
 arch/sh/Makefile                   |  2 --
 arch/sparc/Makefile                |  2 --
 arch/x86/Makefile                  |  5 ---
 arch/xtensa/Makefile               |  2 --
 scripts/head-object-list.txt       | 53 ++++++++++++++++++++++++++++++
 24 files changed, 60 insertions(+), 67 deletions(-)
 create mode 100644 scripts/head-object-list.txt
Documentation/kbuild/makefiles.rst +5 -4
index 07c7e5a843c1..528c54d56c09 100644
@@ -1065,8 +1065,7 @@ When kbuild executes, the following steps are followed (roughly):
    - The values of the above variables are expanded in arch/$(SRCARCH)/Makefile.
 5) All object files are then linked and the resulting file vmlinux is
    located at the root of the obj tree.
-   The very first objects linked are listed in head-y, assigned by
-   arch/$(SRCARCH)/Makefile.
+   The very first objects linked are listed in scripts/head-object-list.txt.
 6) Finally, the architecture-specific part does any required post processing
    and builds the final bootimage.
    - This includes building boot records
@@ -1214,6 +1213,9 @@ When kbuild executes, the following steps are followed (roughly):
 	All object files for vmlinux. They are linked to vmlinux in the same
 	order as listed in KBUILD_VMLINUX_OBJS.
 
+	The objects listed in scripts/head-object-list.txt are exceptions;
+	they are placed before the other objects.
+
     KBUILD_VMLINUX_LIBS
 
 	All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and
@@ -1257,8 +1259,7 @@ When kbuild executes, the following steps are followed (roughly):
 	machinery is all architecture-independent.
 
 
-	head-y, core-y, libs-y, drivers-y
-	    $(head-y) lists objects to be linked first in vmlinux.
+	core-y, libs-y, drivers-y
 
 	    $(libs-y) lists directories where a lib.a archive can be located.
 
Makefile +2 -2
index f2d06aaaefd3..e96ee00609b7 100644
@@ -1155,10 +1155,10 @@ quiet_cmd_ar_vmlinux.a = AR      $@
       cmd_ar_vmlinux.a = \
 	rm -f $@; \
 	$(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
-	$(AR) mPi $$($(AR) t $@ | head -n1) $@ $(head-y)
+	$(AR) mPi $$($(AR) t $@ | head -n1) $@ $$($(AR) t $@ | grep -F --file=$(srctree)/scripts/head-object-list.txt)
 
 targets += vmlinux.a
-vmlinux.a: $(KBUILD_VMLINUX_OBJS) FORCE
+vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt FORCE
 	$(call if_changed,ar_vmlinux.a)
 
 targets += vmlinux.o
arch/alpha/Makefile +0 -2
index 881cb913e23a..45158024085e 100644
@@ -36,8 +36,6 @@ cflags-y				+= $(cpuflags-y)
 # BWX is most important, but we don't really want any emulation ever.
 KBUILD_CFLAGS += $(cflags-y) -Wa,-mev6
 
-head-y := arch/alpha/kernel/head.o
-
 libs-y				+= arch/alpha/lib/
 
 # export what is needed by arch/alpha/boot/Makefile
arch/arc/Makefile +0 -2
index efc54f3e35e0..329400a1c355 100644
@@ -82,8 +82,6 @@ KBUILD_CFLAGS	+= $(cflags-y)
 KBUILD_AFLAGS	+= $(KBUILD_CFLAGS)
 KBUILD_LDFLAGS	+= $(ldflags-y)
 
-head-y		:= arch/arc/kernel/head.o
-
 # w/o this dtb won't embed into kernel binary
 core-y		+= arch/arc/boot/dts/
 
arch/arm/Makefile +0 -3
index 56f655deebb1..29d15c9a433e 100644
@@ -134,9 +134,6 @@ KBUILD_AFLAGS	+=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/uni
 
 CHECKFLAGS	+= -D__arm__
 
-#Default value
-head-y		:= arch/arm/kernel/head$(MMUEXT).o
-
 # Text offset. This list is sorted numerically by address in order to
 # provide a means to avoid/resolve conflicts in multi-arch kernels.
 # Note: the 32kB below this value is reserved for use by the kernel
arch/arm64/Makefile +0 -3
index 6d9d4a58b898..6e03f15bb041 100644
@@ -133,9 +133,6 @@ ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y)
   CC_FLAGS_FTRACE := -fpatchable-function-entry=2
 endif
 
-# Default value
-head-y		:= arch/arm64/kernel/head.o
-
 ifeq ($(CONFIG_KASAN_SW_TAGS), y)
 KASAN_SHADOW_SCALE_SHIFT := 4
 else ifeq ($(CONFIG_KASAN_GENERIC), y)
arch/csky/Makefile +0 -2
index 4e1d619fd5c6..0e4237e55758 100644
@@ -59,8 +59,6 @@ LDFLAGS += -EL
 
 KBUILD_AFLAGS += $(KBUILD_CFLAGS)
 
-head-y := arch/csky/kernel/head.o
-
 core-y += arch/csky/$(CSKYABI)/
 
 libs-y += arch/csky/lib/ \
arch/hexagon/Makefile +0 -2
index 44312bc147d8..92d005958dfb 100644
@@ -32,5 +32,3 @@ KBUILD_LDFLAGS += $(ldflags-y)
 TIR_NAME := r19
 KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__
 KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME)
-
-head-y := arch/hexagon/kernel/head.o
arch/ia64/Makefile +0 -1
index e55c2f138656..56c4bb276b6e 100644
@@ -44,7 +44,6 @@ quiet_cmd_objcopy = OBJCOPY $@
 cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
 
 KBUILD_CFLAGS += $(cflags-y)
-head-y := arch/ia64/kernel/head.o
 
 libs-y				+= arch/ia64/lib/
 
arch/loongarch/Makefile +0 -2
index ec3de6191276..131fc210c2bf 100644
@@ -72,8 +72,6 @@ CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
 	sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
 endif
 
-head-y := arch/loongarch/kernel/head.o
-
 libs-y += arch/loongarch/lib/
 
 ifeq ($(KBUILD_EXTMOD),)
arch/m68k/Makefile +0 -9
index e358605b70ba..43e39040d3ac 100644
@@ -86,15 +86,6 @@ ifdef CONFIG_KGDB
 KBUILD_CFLAGS := $(subst -fomit-frame-pointer,,$(KBUILD_CFLAGS)) -g
 endif
 
-#
-# Select the assembler head startup code. Order is important. The default
-# head code is first, processor specific selections can override it after.
-#
-head-y				:= arch/m68k/kernel/head.o
-head-$(CONFIG_SUN3)		:= arch/m68k/kernel/sun3-head.o
-head-$(CONFIG_M68000)		:= arch/m68k/68000/head.o
-head-$(CONFIG_COLDFIRE)		:= arch/m68k/coldfire/head.o
-
 libs-y				+= arch/m68k/lib/
 
 
arch/microblaze/Makefile +0 -1
index 1826d9ce4459..3f8a86c4336a 100644
@@ -48,7 +48,6 @@ CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
 # r31 holds current when in kernel mode
 KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
 
-head-y := arch/microblaze/kernel/head.o
 libs-y += arch/microblaze/lib/
 
 boot := arch/microblaze/boot
arch/mips/Makefile +0 -2
index 4d2a3e73fc45..b296e33f8e33 100644
@@ -324,8 +324,6 @@ endif
 
 OBJCOPYFLAGS		+= --remove-section=.reginfo
 
-head-y := arch/mips/kernel/head.o
-
 libs-y			+= arch/mips/lib/
 libs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/
 
arch/nios2/Makefile +0 -1
index 3f34e6831863..f1ff4ce0f1a2 100644
@@ -37,7 +37,6 @@ KBUILD_CFLAGS += -DUTS_SYSNAME=\"$(UTS_SYSNAME)\"
 KBUILD_CFLAGS += -fno-builtin
 KBUILD_CFLAGS += -G 0
 
-head-y		:= arch/nios2/kernel/head.o
 libs-y		+= arch/nios2/lib/ $(LIBGCC)
 
 INSTALL_PATH ?= /tftpboot
arch/openrisc/Makefile +0 -2
index b446510173cd..68249521db5a 100644
@@ -55,8 +55,6 @@ ifeq ($(CONFIG_OPENRISC_HAVE_INST_SEXT),y)
 	KBUILD_CFLAGS += $(call cc-option,-msext)
 endif
 
-head-y 		:= arch/openrisc/kernel/head.o
-
 libs-y		+= $(LIBGCC)
 
 PHONY += vmlinux.bin
arch/parisc/Makefile +0 -2
index e38d993d87f2..a2d8600521f9 100644
@@ -113,8 +113,6 @@ cflags-$(CONFIG_PA7100LC)	+= -march=1.1 -mschedule=7100LC
 cflags-$(CONFIG_PA7300LC)	+= -march=1.1 -mschedule=7300
 cflags-$(CONFIG_PA8X00)		+= -march=2.0 -mschedule=8000
 
-head-y			:= arch/parisc/kernel/head.o 
-
 KBUILD_CFLAGS	+= $(cflags-y)
 LIBGCC		:= $(shell $(CC) -print-libgcc-file-name)
 export LIBGCC
arch/powerpc/Makefile +0 -12
index 02742facf895..89c27827a11f 100644
@@ -226,18 +226,6 @@ KBUILD_CFLAGS += $(cpu-as-y)
 KBUILD_AFLAGS += $(aflags-y)
 KBUILD_CFLAGS += $(cflags-y)
 
-head-$(CONFIG_PPC64)		:= arch/powerpc/kernel/head_64.o
-head-$(CONFIG_PPC_BOOK3S_32)	:= arch/powerpc/kernel/head_book3s_32.o
-head-$(CONFIG_PPC_8xx)		:= arch/powerpc/kernel/head_8xx.o
-head-$(CONFIG_40x)		:= arch/powerpc/kernel/head_40x.o
-head-$(CONFIG_44x)		:= arch/powerpc/kernel/head_44x.o
-head-$(CONFIG_FSL_BOOKE)	:= arch/powerpc/kernel/head_fsl_booke.o
-
-head-$(CONFIG_PPC64)		+= arch/powerpc/kernel/entry_64.o
-head-$(CONFIG_PPC_FPU)		+= arch/powerpc/kernel/fpu.o
-head-$(CONFIG_ALTIVEC)		+= arch/powerpc/kernel/vector.o
-head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)  += arch/powerpc/kernel/prom_init.o
-
 # Default to zImage, override when needed
 all: zImage
 
arch/riscv/Makefile +0 -2
index 3fa8ef336822..e013df8e7b8b 100644
@@ -110,8 +110,6 @@ else
 KBUILD_IMAGE	:= $(boot)/Image.gz
 endif
 
-head-y := arch/riscv/kernel/head.o
-
 libs-y += arch/riscv/lib/
 libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
 
arch/s390/Makefile +0 -2
index 4cb5d17e7ead..de6d8b2ea4d8 100644
@@ -119,8 +119,6 @@ export KBUILD_CFLAGS_DECOMPRESSOR
 
 OBJCOPYFLAGS	:= -O binary
 
-head-y		:= arch/s390/kernel/head64.o
-
 libs-y		+= arch/s390/lib/
 drivers-y	+= drivers/s390/
 
arch/sh/Makefile +0 -2
index b39412bf91fb..5c8776482530 100644
@@ -114,8 +114,6 @@ endif
 
 export ld-bfd
 
-head-y	:= arch/sh/kernel/head_32.o
-
 # Mach groups
 machdir-$(CONFIG_SOLUTION_ENGINE)		+= mach-se
 machdir-$(CONFIG_SH_HP6XX)			+= mach-hp6xx
arch/sparc/Makefile +0 -2
index fe58a410b4ce..a4ea5b05f288 100644
@@ -56,8 +56,6 @@ endif
 
 endif
 
-head-y                 := arch/sparc/kernel/head_$(BITS).o
-
 libs-y                 += arch/sparc/prom/
 libs-y                 += arch/sparc/lib/
 
arch/x86/Makefile +0 -5
index bafbd905e6e7..9afd323c6916 100644
@@ -234,11 +234,6 @@ archheaders:
 ###
 # Kernel objects
 
-head-y := arch/x86/kernel/head_$(BITS).o
-head-y += arch/x86/kernel/head$(BITS).o
-head-y += arch/x86/kernel/ebda.o
-head-y += arch/x86/kernel/platform-quirks.o
-
 libs-y  += arch/x86/lib/
 
 # drivers-y are linked after core-y
arch/xtensa/Makefile +0 -2
index 5097caa7bf0c..bfd8e433ed62 100644
@@ -55,8 +55,6 @@ KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs))
 
 KBUILD_DEFCONFIG := iss_defconfig
 
-head-y		:= arch/xtensa/kernel/head.o
-
 libs-y		+= arch/xtensa/lib/
 
 boot		:= arch/xtensa/boot
scripts/head-object-list.txt new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#21 lore raw

Re: [PATCH v2 8/8] kbuild: remove head-y syntax

Quoted 12 lines · Masahiro Yamada

Kbuild puts the objects listed in head-y at the head of vmlinux. Conventionally, we do this for head*.S, which contains the kernel entry point.

A counter approach is to control the section order by the linker script. Actually, the code marked as __HEAD goes into the ".head.text" section, which is placed before the normal ".text" section.

I do not know if both of them are needed. From the build system perspective, head-y is not mandatory. If you can achieve the proper code placement by the linker script only, it would be cleaner.

Quoted 5 lines

I collected the current head-y objects into head-object-list.txt. It is a whitelist. My hope is it will be reduced in the long run.

---

The scripts/head-object-list.txt approach feels a little awkward, so overall I'm not convinced that this is an improvement as long as there is no final decision for what should be done instead.

If the .head.text section approach works, maybe convert at a minimum the x86 and arm64 architectures to provide an example of what it should look like in the end, otherwise I doubt that any architecture maintainers are going to work on removing their architectures from the head-object-list.txt file.

Quoted 30 lines
scripts/head-object-list.txt new file +30 -0
+arch/alpha/kernel/head.o
+arch/arc/kernel/head.o
+arch/arm/kernel/head-nommu.o
+arch/arm/kernel/head.o
+arch/arm64/kernel/head.o
+arch/csky/kernel/head.o
+arch/hexagon/kernel/head.o
+arch/ia64/kernel/head.o
+arch/loongarch/kernel/head.o
+arch/m68k/68000/head.o
+arch/m68k/coldfire/head.o
+arch/m68k/kernel/head.o
+arch/m68k/kernel/sun3-head.o
+arch/microblaze/kernel/head.o
+arch/mips/kernel/head.o
+arch/nios2/kernel/head.o
+arch/openrisc/kernel/head.o
+arch/parisc/kernel/head.o
+arch/powerpc/kernel/head_40x.o
+arch/powerpc/kernel/head_44x.o
+arch/powerpc/kernel/head_64.o
+arch/powerpc/kernel/head_8xx.o
+arch/powerpc/kernel/head_book3s_32.o
+arch/powerpc/kernel/head_fsl_booke.o
+arch/powerpc/kernel/entry_64.o
+arch/powerpc/kernel/fpu.o
+arch/powerpc/kernel/vector.o
+arch/powerpc/kernel/prom_init.o
+arch/riscv/kernel/head.o
+arch/s390/kernel/head64.o

scripts/head-object-list.txt line 53

Quoted 10 lines
scripts/head-object-list.txt new file +10 -0
+arch/sh/kernel/head_32.o
+arch/sparc/kernel/head_32.o
+arch/sparc/kernel/head_64.o
+arch/x86/kernel/head_32.o
+arch/x86/kernel/head_64.o
+arch/x86/kernel/head32.o
+arch/x86/kernel/head64.o
+arch/x86/kernel/ebda.o
+arch/x86/kernel/platform-quirks.o
+arch/xtensa/kernel/head.o

Seeing that almost all of these have the same naming convention, another alternative would be to have a special case exclusively for arch/*/kernel/head.S and make that either an assembly file that includes all the other files from your current list, or use an intermediate object to link head-*.o into head.o before putting that first.

Arnd

#22 lore raw

Re: [PATCH v2 8/8] kbuild: remove head-y syntax

Quoted 17 lines · Arnd Bergmann
Quoted 15 lines · Masahiro Yamada

Kbuild puts the objects listed in head-y at the head of vmlinux. Conventionally, we do this for head*.S, which contains the kernel entry point.

A counter approach is to control the section order by the linker script. Actually, the code marked as __HEAD goes into the ".head.text" section, which is placed before the normal ".text" section.

I do not know if both of them are needed. From the build system perspective, head-y is not mandatory. If you can achieve the proper code placement by the linker script only, it would be cleaner.

I collected the current head-y objects into head-object-list.txt. It is a whitelist. My hope is it will be reduced in the long run.

Quoted 7 lines
Quoted 2 lines

---

The scripts/head-object-list.txt approach feels a little awkward, so overall I'm not convinced that this is an improvement as long as there is no final decision for what should be done instead.

Agree with Arnd here - having an exhaustive list that spans all arch/* subdirectories goes against the divide-and-conquer nature of arch/, where each architecture manages such things themselves

Quoted 6 lines

If the .head.text section approach works, maybe convert at a minimum the x86 and arm64 architectures to provide an example of what it should look like in the end, otherwise I doubt that any architecture maintainers are going to work on removing their architectures from the head-object-list.txt file.

For the arm64 case, I seriously doubt whether head.o needs any special treatment - the layout is section based, and the only piece that must appear right at the start of the binary image is the image header (which is emitted into .head.text IIRC), everything else appearing in head.S is placed in .text, .idmap.text or .init.text, and does not require any special treatment.

Quoted 50 lines
Quoted 30 lines
scripts/head-object-list.txt new file +30 -0
+arch/alpha/kernel/head.o
+arch/arc/kernel/head.o
+arch/arm/kernel/head-nommu.o
+arch/arm/kernel/head.o
+arch/arm64/kernel/head.o
+arch/csky/kernel/head.o
+arch/hexagon/kernel/head.o
+arch/ia64/kernel/head.o
+arch/loongarch/kernel/head.o
+arch/m68k/68000/head.o
+arch/m68k/coldfire/head.o
+arch/m68k/kernel/head.o
+arch/m68k/kernel/sun3-head.o
+arch/microblaze/kernel/head.o
+arch/mips/kernel/head.o
+arch/nios2/kernel/head.o
+arch/openrisc/kernel/head.o
+arch/parisc/kernel/head.o
+arch/powerpc/kernel/head_40x.o
+arch/powerpc/kernel/head_44x.o
+arch/powerpc/kernel/head_64.o
+arch/powerpc/kernel/head_8xx.o
+arch/powerpc/kernel/head_book3s_32.o
+arch/powerpc/kernel/head_fsl_booke.o
+arch/powerpc/kernel/entry_64.o
+arch/powerpc/kernel/fpu.o
+arch/powerpc/kernel/vector.o
+arch/powerpc/kernel/prom_init.o
+arch/riscv/kernel/head.o
+arch/s390/kernel/head64.o

scripts/head-object-list.txt line 53

Quoted 10 lines
scripts/head-object-list.txt new file +10 -0
+arch/sh/kernel/head_32.o
+arch/sparc/kernel/head_32.o
+arch/sparc/kernel/head_64.o
+arch/x86/kernel/head_32.o
+arch/x86/kernel/head_64.o
+arch/x86/kernel/head32.o
+arch/x86/kernel/head64.o
+arch/x86/kernel/ebda.o
+arch/x86/kernel/platform-quirks.o
+arch/xtensa/kernel/head.o

Seeing that almost all of these have the same naming convention, another alternative would be to have a special case exclusively for arch/*/kernel/head.S and make that either an assembly file that includes all the other files from your current list, or use an intermediate object to link head-*.o into head.o before putting that first.

Arnd

#23 lore raw

Re: [PATCH v2 8/8] kbuild: remove head-y syntax

In reply to Arnd Bergmann
Quoted 24 lines · Arnd Bergmann
Quoted 12 lines · Masahiro Yamada

Kbuild puts the objects listed in head-y at the head of vmlinux. Conventionally, we do this for head*.S, which contains the kernel entry point.

A counter approach is to control the section order by the linker script. Actually, the code marked as __HEAD goes into the ".head.text" section, which is placed before the normal ".text" section.

I do not know if both of them are needed. From the build system perspective, head-y is not mandatory. If you can achieve the proper code placement by the linker script only, it would be cleaner.

Quoted 5 lines

I collected the current head-y objects into head-object-list.txt. It is a whitelist. My hope is it will be reduced in the long run.

---

The scripts/head-object-list.txt approach feels a little awkward, so overall I'm not convinced that this is an improvement as long as there is no final decision for what should be done instead.

Quoted 5 lines

If the .head.text section approach works, maybe convert at a minimum the x86 and arm64 architectures to provide an example of what it should look like in the end, otherwise I doubt that any architecture maintainers are going to work on removing their architectures from the head-object-list.txt file.

I wish I had done this before fa96b57c149061f71a70bd6582d995f6424fbbf4. Maybe I would have been able to avoid loongarch adding a head-y.

When people port a new arch, they mimic other arch implementations, and apparently they assume having head-y is mandatory, and the right thing to do.

So, we need something to make arch maintainers realize "when you add a new head-y entry, very likely you are doing wrong".

So, collecting the current ones into a whitelist can prevent the list from growing at least, even if nobody strives to reduce it.

I did a similar approach for

scripts/headers_install.sh
usr/include/Makefile

It was successful because we did not get a new breakage.

Do you have a better idea to avoid bad code slipping in?

See the next arch port.

If somebody upsteams arch/kvx/, they will be very likely to add arch/kvx/kernel/head.o to head-y.

They are already doing it.
https://github.com/kalray/linux_coolidge/blob/coolidge/arch/kvx/Makefile

People never re-think "why do we need head-y in the first place?"

Quoted 50 lines
Quoted 31 lines
scripts/head-object-list.txt new file +30 -0
+arch/alpha/kernel/head.o
+arch/arc/kernel/head.o
+arch/arm/kernel/head-nommu.o
+arch/arm/kernel/head.o
+arch/arm64/kernel/head.o
+arch/csky/kernel/head.o
+arch/hexagon/kernel/head.o
+arch/ia64/kernel/head.o
+arch/loongarch/kernel/head.o
+arch/m68k/68000/head.o
+arch/m68k/coldfire/head.o
+arch/m68k/kernel/head.o
+arch/m68k/kernel/sun3-head.o
+arch/microblaze/kernel/head.o
+arch/mips/kernel/head.o
+arch/nios2/kernel/head.o
+arch/openrisc/kernel/head.o
+arch/parisc/kernel/head.o
+arch/powerpc/kernel/head_40x.o
+arch/powerpc/kernel/head_44x.o
+arch/powerpc/kernel/head_64.o
+arch/powerpc/kernel/head_8xx.o
+arch/powerpc/kernel/head_book3s_32.o
+arch/powerpc/kernel/head_fsl_booke.o
+arch/powerpc/kernel/entry_64.o
+arch/powerpc/kernel/fpu.o
+arch/powerpc/kernel/vector.o
+arch/powerpc/kernel/prom_init.o
+arch/riscv/kernel/head.o
+arch/s390/kernel/head64.o

scripts/head-object-list.txt line 53

Quoted 10 lines
scripts/head-object-list.txt new file +10 -0
+arch/sh/kernel/head_32.o
+arch/sparc/kernel/head_32.o
+arch/sparc/kernel/head_64.o
+arch/x86/kernel/head_32.o
+arch/x86/kernel/head_64.o
+arch/x86/kernel/head32.o
+arch/x86/kernel/head64.o
+arch/x86/kernel/ebda.o
+arch/x86/kernel/platform-quirks.o
+arch/xtensa/kernel/head.o

Seeing that almost all of these have the same naming convention, another alternative would be to have a special case exclusively for arch/*/kernel/head.S and make that either an assembly file that includes all the other files from your current list, or use an intermediate object to link head-*.o into head.o before putting that first.

Quoted 1 line

Arnd

I prefer a simple list of objects, so that people
can work on it one by one.

As Ard pointed out, we can remove
arch/arm64/kernel/head.o
but it requires deep arch-specific knowledge.

Signature · 2 lines
Best Regards
Masahiro Yamada
#24 lore raw
In reply to Masahiro Yamada
Quoted 6 lines · On Tue, 6 Sep 2022 15:13:05 +0900 Masahiro Yamada wrote:

- Refactor single target build to make it work more correctly
- Link vmlinux and modules in parallel
- Remove head-y syntax

Quoted 9 lines

Masahiro Yamada (8):
kbuild: fix and refactor single target build
kbuild: rename modules.order in sub-directories to .modules.order
kbuild: move core-y and drivers-y to ./Kbuild
kbuild: move .vmlinux.objs rule to Makefile.modpost
kbuild: move vmlinux.o rule to the top Makefile
kbuild: unify two modpost invocations
kbuild: use obj-y instead extra-y for objects placed at the head
kbuild: remove head-y syntax

I'm not able to apply the patchset, neither on your current kbuild branch nor on for-next. What am I missing here? Could you give me a hint for a patchset base?

Thanks and kind regards,
Nicolas

#25 lore raw
Quoted 17 lines · On Wed, 7 Sep 2022 22:15:57 +0200 Nicolas Schier wrote:
Quoted 6 lines · On Tue, 6 Sep 2022 15:13:05 +0900 Masahiro Yamada wrote:

- Refactor single target build to make it work more correctly
- Link vmlinux and modules in parallel
- Remove head-y syntax

Quoted 9 lines

Masahiro Yamada (8):
kbuild: fix and refactor single target build
kbuild: rename modules.order in sub-directories to .modules.order
kbuild: move core-y and drivers-y to ./Kbuild
kbuild: move .vmlinux.objs rule to Makefile.modpost
kbuild: move vmlinux.o rule to the top Makefile
kbuild: unify two modpost invocations
kbuild: use obj-y instead extra-y for objects placed at the head
kbuild: remove head-y syntax

Quoted 6 lines

I'm not able to apply the patchset, neither on your current kbuild branch nor on for-next. What am I missing here? Could you give me a hint for a patchset base?

Thanks and kind regards,
Nicolas

ooops. It _is_ already on kbuild, sorry for the noise.

#26 lore raw
Quoted 23 lines · Nicolas Schier
Quoted 21 lines · On Wed, 7 Sep 2022 22:15:57 +0200 Nicolas Schier wrote:
Quoted 6 lines · On Tue, 6 Sep 2022 15:13:05 +0900 Masahiro Yamada wrote:

- Refactor single target build to make it work more correctly
- Link vmlinux and modules in parallel
- Remove head-y syntax

Quoted 9 lines

Masahiro Yamada (8):
kbuild: fix and refactor single target build
kbuild: rename modules.order in sub-directories to .modules.order
kbuild: move core-y and drivers-y to ./Kbuild
kbuild: move .vmlinux.objs rule to Makefile.modpost
kbuild: move vmlinux.o rule to the top Makefile
kbuild: unify two modpost invocations
kbuild: use obj-y instead extra-y for objects placed at the head
kbuild: remove head-y syntax

I'm not able to apply the patchset, neither on your current kbuild branch nor on for-next. What am I missing here? Could you give me a hint for a patchset base?

Quoted 5 lines
Quoted 2 lines

Thanks and kind regards,
Nicolas

ooops. It _is_ already on kbuild, sorry for the noise.

Yes.
If you are happy to review and/or test the branch, I will add Reviewed-by/Tested-by when I rebase it.

Signature · 2 lines
Best Regards
Masahiro Yamada
#27 lore raw
In reply to Masahiro Yamada
Quoted 7 lines · Masahiro Yamada

- Refactor single target build to make it work more correctly
- Link vmlinux and modules in parallel
- Remove head-y syntax

Quoted 9 lines

Masahiro Yamada (8):
kbuild: fix and refactor single target build
kbuild: rename modules.order in sub-directories to .modules.order
kbuild: move core-y and drivers-y to ./Kbuild
kbuild: move .vmlinux.objs rule to Makefile.modpost
kbuild: move vmlinux.o rule to the top Makefile
kbuild: unify two modpost invocations
kbuild: use obj-y instead extra-y for objects placed at the head
kbuild: remove head-y syntax

Various bugs have been reported for v2.

I applied 1/8.
dropped 2/8.
will send v3 for the rest.

Signature · 2 lines
Best Regards
Masahiro Yamada