Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jun 30, 2024
  2. Jun 23, 2024
  3. Jun 16, 2024
  4. Jun 09, 2024
  5. Jun 02, 2024
  6. May 26, 2024
  7. May 19, 2024
    • Samuel Holland's avatar
      arch: add ARCH_HAS_KERNEL_FPU_SUPPORT · 6cbd1d6d
      Samuel Holland authored
      Several architectures provide an API to enable the FPU and run
      floating-point SIMD code in kernel space.  However, the function names,
      header locations, and semantics are inconsistent across architectures, and
      FPU support may be gated behind other Kconfig options.
      
      provide a standard way for architectures to declare that kernel space
      FPU support is available. Architectures selecting this option must
      implement what is currently the most common API (kernel_fpu_begin() and
      kernel_fpu_end(), plus a new function kernel_fpu_available()) and
      provide the appropriate CFLAGS for compiling floating-point C code.
      
      Link: https://lkml.kernel.org/r/20240329072441.591471-2-samuel.holland@sifive.com
      
      
      Signed-off-by: default avatarSamuel Holland <samuel.holland@sifive.com>
      Suggested-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: default avatarChristian König <christian.koenig@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: Borislav Petkov (AMD) <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicolas Schier <nicolas@fjasle.eu>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: WANG Xuerui <git@xen0n.name>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      6cbd1d6d
  8. May 12, 2024
  9. May 09, 2024
    • Masahiro Yamada's avatar
      kbuild: add 'private' to target-specific variables · d98dba88
      Masahiro Yamada authored
      
      Currently, Kbuild produces inconsistent results in some cases.
      
      You can do an interesting experiment using the --shuffle option, which
      is supported by GNU Make 4.4 or later.
      
      Set CONFIG_KVM_INTEL=y and CONFIG_KVM_AMD=m (or vice versa), and repeat
      incremental builds w/wo --shuffle=reverse.
      
        $ make
          [ snip ]
          CC      arch/x86/kvm/kvm-asm-offsets.s
      
        $ make --shuffle=reverse
          [ snip ]
          CC [M]  arch/x86/kvm/kvm-asm-offsets.s
      
        $ make
          [ snip ]
          CC      arch/x86/kvm/kvm-asm-offsets.s
      
      arch/x86/kvm/kvm-asm-offsets.s is rebuilt every time w/wo the [M] marker.
      
      arch/x86/kvm/kvm-asm-offsets.s is built as built-in when it is built as
      a prerequisite of arch/x86/kvm/kvm-intel.o, which is built-in.
      
      arch/x86/kvm/kvm-asm-offsets.s is built as modular when it is built as
      a prerequisite of arch/x86/kvm/kvm-amd.o, which is a module.
      
      Another odd example is single target builds.
      
      When CONFIG_LKDTM=m, drivers/misc/lkdtm/rodata.o can be built as
      built-in or modular, depending on how it is built.
      
        $ make drivers/misc/lkdtm/lkdtm.o
          [ snip ]
          CC [M]  drivers/misc/lkdtm/rodata.o
      
        $ make drivers/misc/lkdtm/rodata.o
          [ snip ]
          CC      drivers/misc/lkdtm/rodata.o
      
      drivers/misc/lkdtm/rodata.o is built as modular when it is built as a
      prerequisite of another, but built as built-in when it is a final
      target.
      
      The same thing happens to drivers/memory/emif-asm-offsets.s when
      CONFIG_TI_EMIF_SRAM=m.
      
        $ make drivers/memory/ti-emif-sram.o
          [ snip ]
          CC [M]  drivers/memory/emif-asm-offsets.s
      
        $ make drivers/memory/emif-asm-offsets.s
          [ snip ]
          CC      drivers/memory/emif-asm-offsets.s
      
      This is because the part-of-module=y flag defined for the modules is
      inherited by its prerequisites.
      
      Target-specific variables are likely intended only for local use.
      This commit adds 'private' to them.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <n.schier@avm.de>
      d98dba88
    • Masahiro Yamada's avatar
      kbuild: remove redundant $(wildcard ) for rm-files · 770202a2
      Masahiro Yamada authored
      
      The $(wildcard ) is called in quiet_cmd_rmfiles.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <n.schier@avm.de>
      770202a2
    • Masahiro Yamada's avatar
      kbuild: use $(src) instead of $(srctree)/$(src) for source directory · b1992c37
      Masahiro Yamada authored
      Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for
      checked-in source files. It is merely a convention without any functional
      difference. In fact, $(obj) and $(src) are exactly the same, as defined
      in scripts/Makefile.build:
      
          src := $(obj)
      
      When the kernel is built in a separate output directory, $(src) does
      not accurately reflect the source directory location. While Kbuild
      resolves this discrepancy by specifying VPATH=$(srctree) to search for
      source files, it does not cover all cases. For example, when adding a
      header search path for local headers, -I$(srctree)/$(src) is typically
      passed to the compiler.
      
      This introduces inconsistency between upstream and downstream Makefiles
      because $(src) is used instead of $(srctree)/$(src) for the latter.
      
      To address this inconsistency, this commit changes the semantics of
      $(src) so that it always points to the directory in the source tree.
      
      Going forward, the variables used ...
      b1992c37
  10. May 05, 2024
  11. May 02, 2024
    • Nathan Chancellor's avatar
      kbuild: Remove support for Clang's ThinLTO caching · aba09154
      Nathan Chancellor authored
      There is an issue in clang's ThinLTO caching (enabled for the kernel via
      '--thinlto-cache-dir') with .incbin, which the kernel occasionally uses
      to include data within the kernel, such as the .config file for
      /proc/config.gz. For example, when changing the .config and rebuilding
      vmlinux, the copy of .config in vmlinux does not match the copy of
      .config in the build folder:
      
        $ echo 'CONFIG_LTO_NONE=n
        CONFIG_LTO_CLANG_THIN=y
        CONFIG_IKCONFIG=y
        CONFIG_HEADERS_INSTALL=y' >kernel/configs/repro.config
      
        $ make -skj"$(nproc)" ARCH=x86_64 LLVM=1 clean defconfig repro.config vmlinux
        ...
      
        $ grep CONFIG_HEADERS_INSTALL .config
        CONFIG_HEADERS_INSTALL=y
      
        $ scripts/extract-ikconfig vmlinux | grep CONFIG_HEADERS_INSTALL
        CONFIG_HEADERS_INSTALL=y
      
        $ scripts/config -d HEADERS_INSTALL
      
        $ make -kj"$(nproc)" ARCH=x86_64 LLVM=1 vmlinux
        ...
          UPD     kernel/config_data
          GZIP    kernel/config_data.gz
          CC      kernel/configs.o
        ...
          LD      vmlinux
        ...
      
        $ grep CONFIG_HEADERS_INSTALL .config
        # CONFIG_HEADERS_INSTALL is not set
      
        $ scripts/extract-ikconfig vmlinux | grep CONFIG_HEADERS_INSTALL
        CONFIG_HEADERS_INSTALL=y
      
      Without '--thinlto-cache-dir' or when using full LTO, this issue does
      not occur.
      
      Benchmarking incremental builds on a few different machines with and
      without the cache shows a 20% increase in incremental build time without
      the cache when measured by touching init/main.c and running 'make all'.
      
      ARCH=arm64 defconfig + CONFIG_LTO_CLANG_THIN=y on an arm64 host:
      
        Benchmark 1: With ThinLTO cache
          Time (mean ± σ):     56.347 s ±  0.163 s    [User: 83.768 s, System: 24.661 s]
          Range (min … max):   56.109 s … 56.594 s    10 runs
      
        Benchmark 2: Without ThinLTO cache
          Time (mean ± σ):     67.740 s ±  0.479 s    [User: 718.458 s, System: 31.797 s]
          Range (min … max):   67.059 s … 68.556 s    10 runs
      
        Summary
          With ThinLTO cache ran
            1.20 ± 0.01 times faster than Without ThinLTO cache
      
      ARCH=x86_64 defconfig + CONFIG_LTO_CLANG_THIN=y on an x86_64 host:
      
        Benchmark 1: With ThinLTO cache
          Time (mean ± σ):     85.772 s ±  0.252 s    [User: 91.505 s, System: 8.408 s]
          Range (min … max):   85.447 s … 86.244 s    10 runs
      
        Benchmark 2: Without ThinLTO cache
          Time (mean ± σ):     103.833 s ±  0.288 s    [User: 232.058 s, System: 8.569 s]
          Range (min … max):   103.286 s … 104.124 s    10 runs
      
        Summary
          With ThinLTO cache ran
            1.21 ± 0.00 times faster than Without ThinLTO cache
      
      While it is unfortunate to take this performance improvement off the
      table, correctness is more important. If/when this is fixed in LLVM, it
      can potentially be brought back in a conditional manner. Alternatively,
      a developer can just disable LTO if doing incremental compiles quickly
      is important, as a full compile cycle can still take over a minute even
      with the cache and it is unlikely that LTO will result in functional
      differences for a kernel change.
      
      Cc: stable@vger.kernel.org
      Fixes: dc5723b0
      
       ("kbuild: add support for Clang LTO")
      Reported-by: default avatarYifan Hong <elsk@google.com>
      Closes: https://github.com/ClangBuiltLinux/linux/issues/2021
      
      
      Reported-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Closes: https://lore.kernel.org/r/20220327115526.cc4b0ff55fc53c97683c3e4d@kernel.org/
      
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      aba09154
    • Rob Herring's avatar
      dt-bindings: kbuild: Add separate target/dependency for processed-schema.json · 604a57ba
      Rob Herring authored
      
      Running dtbs_check and dt_compatible_check targets really only depend
      on processed-schema.json, but the dependency is 'dt_binding_check'. That
      was sort worked around with the CHECK_DT_BINDING variable in order to
      skip some of the work that 'dt_binding_check' does. It still runs the
      full checks of the schemas which is not necessary and adds 10s of
      seconds to the build time. That's significant when checking only a few
      DTBs and with recent changes that have improved the validation time by
      6-7x.
      
      Add a new target, dt_binding_schema, which just builds
      processed-schema.json and can be used as the dependency for other
      targets. The scripts_dtc dependency isn't needed either as the examples
      aren't built for it.
      
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Tested-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      604a57ba
  12. Apr 28, 2024
  13. Apr 21, 2024
  14. Apr 14, 2024
  15. Apr 07, 2024
  16. Mar 31, 2024
  17. Mar 24, 2024
  18. Mar 10, 2024
  19. Mar 09, 2024
  20. Mar 03, 2024
  21. Feb 29, 2024
    • Miguel Ojeda's avatar
      kbuild: mark `rustc` (and others) invocations as recursive · ecab4115
      Miguel Ojeda authored
      `rustc` (like Cargo) may take advantage of the jobserver at any time
      (e.g. for backend parallelism, or eventually frontend too). In the kernel,
      we call `rustc` with `-Ccodegen-units=1` (and `-Zthreads` is 1 so far),
      so we do not expect parallelism. However, in the upcoming Rust 1.76.0, a
      warning is emitted by `rustc` [1] when it cannot connect to the jobserver
      it was passed (in many cases, but not all: compiling and `--print sysroot`
      do, but `--version` does not). And given GNU Make always passes
      the jobserver in the environment variable (even when a line is deemed
      non-recursive), `rustc` will end up complaining about it (in particular
      in Make 4.3 where there is only the simple pipe jobserver style).
      
      One solution is to remove the jobserver from `MAKEFLAGS`. However, we
      can mark the lines with calls to `rustc` (and Cargo) as recursive, which
      looks simpler. This is being documented as a recommendation in `rustc`
      [2] and allows us to be ready for the time we may use parallelism inside
      `rustc` (potentially now, if a user passes `-Zthreads`). Thus do so.
      
      Similarly, do the same for `rustdoc` and `cargo` calls.
      
      Finally, there is one case that the solution does not cover, which is the
      `$(shell ...)` call we have. Thus, for that one, set an empty `MAKEFLAGS`
      environment variable.
      
      Link: https://github.com/rust-lang/rust/issues/120515
      
       [1]
      Acked-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Link: https://github.com/rust-lang/rust/pull/121564 [2]
      Link: https://lore.kernel.org/r/20240217002638.57373-1-ojeda@kernel.org
      
      
      [ Reworded to add link to PR documenting the recommendation. ]
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      ecab4115
  22. Feb 25, 2024
  23. Feb 22, 2024
    • Nathan Chancellor's avatar
      Makefile: drop warn-stack-size plugin opt · c6d9a4a9
      Nathan Chancellor authored
      Now that the minimum supported version of LLVM for building the kernel has
      been bumped to 13.0.1, the inner ifeq statement is always false, as the
      build will fail during the configuration stage for older LLVM versions.
      
      This effectively reverts commit 24845dcb ("Makefile: LTO: have linker
      check -Wframe-larger-than") and its follow up fix, commit 0236526d
      ("Makefile: lto: Pass -warn-stack-size only on LLD < 13.0.0").
      
      Link: https://lkml.kernel.org/r/20240125-bump-min-llvm-ver-to-13-0-1-v1-2-f5ff9bda41c5@kernel.org
      
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: "Aneesh Kumar K.V (IBM)" <aneesh.kumar@kernel.org>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Borislav Petkov (AMD) <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Conor Dooley <conor@kernel.org>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Nicolas Schier <nicolas@fjasle.eu>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      c6d9a4a9
  24. Feb 19, 2024
    • Masahiro Yamada's avatar
      kbuild: simplify dtbs_install by reading the list of compiled DTBs · 8f66864c
      Masahiro Yamada authored
      
      Retrieve the list of *.dtb(o) files from arch/*/boot/dts/dtbs-list
      instead of traversing the directory tree again.
      
      Please note that 'make dtbs_install' installs *.dtb(o) files directly
      added to dtb-y because scripts/Makefile.dtbinst installs $(dtb-y)
      without expanding the -dtbs suffix.
      
      This commit preserves this behavior.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      8f66864c
    • Masahiro Yamada's avatar
      kbuild: create a list of all built DTB files · 24507871
      Masahiro Yamada authored
      
      It is useful to have a list of all *.dtb and *.dtbo files generated
      from the current build.
      
      With this commit, 'make dtbs' creates arch/*/boot/dts/dtbs-list, which
      lists the dtb(o) files created in the current build. It maintains the
      order of the dtb-y additions in Makefiles although the order is not
      important for DTBs. It is a (good) side effect through the reuse of the
      modules.order rule.
      
      Please note this list only includes the files directly added to dtb-y.
      
      For example, consider this case:
      
          foo-dtbs := foo_base.dtb foo_overlay.dtbo
          dtb-y := foo.dtb
      
      In this example, the list will include foo.dtb, but not foo_base.dtb
      or foo_overlay.dtbo.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      24507871
  25. Feb 18, 2024
  26. Feb 14, 2024
  27. Feb 11, 2024
  28. Feb 09, 2024
  29. Feb 04, 2024
  30. Jan 31, 2024
  31. Jan 28, 2024
  32. Jan 21, 2024