Skip to content
Snippets Groups Projects
  1. Sep 15, 2024
  2. Sep 08, 2024
  3. Sep 01, 2024
  4. Aug 27, 2024
    • Miguel Ojeda's avatar
      rust: allow `stable_features` lint · 8e95e53c
      Miguel Ojeda authored
      
      Support for several Rust compiler versions started in commit 63b27f4a
      ("rust: start supporting several compiler versions"). Since we currently
      need to use a number of unstable features in the kernel, it is a matter
      of time until one gets stabilized and the `stable_features` lint warns.
      
      For instance, the `new_uninit` feature may become stable soon, which
      would give us multiple warnings like the following:
      
          warning: the feature `new_uninit` has been stable since 1.82.0-dev
          and no longer requires an attribute to enable
            --> rust/kernel/lib.rs:17:12
             |
          17 | #![feature(new_uninit)]
             |            ^^^^^^^^^^
             |
             = note: `#[warn(stable_features)]` on by default
      
      Thus allow the `stable_features` lint to avoid such warnings. This is
      the simplest approach -- we do not have that many cases (and the goal
      is to stop using unstable features anyway) and cleanups can be easily
      done when we decide to update the minimum version.
      
      An alternative would be to conditionally enable them based on the
      compiler version (with the upcoming `RUSTC_VERSION` or maybe with the
      unstable `cfg(version(...))`, but that one apparently will not work for
      the nightly case). However, doing so is more complex and may not work
      well for different nightlies of the same version, unless we do not care
      about older nightlies.
      
      Another alternative is using explicit tests of the feature calling
      `rustc`, but that is also more complex and slower.
      
      Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
      Link: https://lore.kernel.org/r/20240827100403.376389-1-ojeda@kernel.org
      
      
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      8e95e53c
  5. Aug 25, 2024
  6. Aug 18, 2024
  7. Aug 11, 2024
  8. Aug 09, 2024
  9. Aug 06, 2024
  10. Aug 04, 2024
  11. Jul 28, 2024
  12. Jul 21, 2024
  13. Jul 20, 2024
  14. Jul 16, 2024
  15. Jul 14, 2024
  16. Jul 10, 2024
    • Arnd Bergmann's avatar
      kbuild: add syscall table generation to scripts/Makefile.asm-headers · fbb5c060
      Arnd Bergmann authored
      
      There are 11 copies of arch/*/kernel/syscalls/Makefile that all implement
      the same basic logic in a somewhat awkward way.
      
      I tried out various ways of unifying the existing copies and ended up
      with something that hooks into the logic for generating the redirections
      to asm-generic headers. This gives a nicer syntax of being able to list
      the generated files in $(syscall-y) inside of arch/*/include/asm/Kbuild
      instead of both $(generated-y) in that place and also in another
      Makefile.
      
      The configuration for which syscall.tbl file to use and which ABIs to
      enable is now done in arch/*/kernel/Makefile.syscalls. I have done
      patches for all architectures and made sure that the new generic
      rules implement a superset of all the architecture specific corner
      cases.
      
      ince the header file is not specific to asm-generic/*.h redirects
      now, I ended up renaming the file to scripts/Makefile.asm-headers.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      fbb5c060
    • Miguel Ojeda's avatar
      rust: simplify Clippy warning flags set · bb421b51
      Miguel Ojeda authored
      
      All Clippy lint groups that we enable, except `correctness`, have a
      default `warn` level, thus they may be removed now that we relaxed all
      lints to `warn`.
      
      Moreover, Clippy provides an `all` lint group that covers the groups
      we enable by default. Thus just use `all` instead -- the only change is
      that, if Clippy introduces a new lint group or splits an existing one,
      we will cover that one automatically.
      
      In addition, `let_unit_value` is in `style` since Rust 1.62.0, thus it
      does not need to be enabled manually.
      
      Reviewed-by: default avatarFinn Behrens <me@kloenk.dev>
      Tested-by: default avatarBenno Lossin <benno.lossin@proton.me>
      Tested-by: default avatarAndreas Hindborg <a.hindborg@samsung.com>
      Link: https://lore.kernel.org/r/20240709160615.998336-6-ojeda@kernel.org
      
      
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      bb421b51
    • Miguel Ojeda's avatar
      rust: relax most deny-level lints to warnings · f8f88aa2
      Miguel Ojeda authored
      Since we are starting to support several Rust toolchains, lints (including
      Clippy ones) now may behave differently and lint groups may include
      new lints.
      
      Therefore, to maximize the chances a given version works, relax some
      deny-level lints to warnings. It may also make our lives a bit easier
      while developing new code or refactoring.
      
      To be clear, the requirements for in-tree code are still the same, since
      Rust code still needs to be warning-free (patches should be clean under
      `WERROR=y`) and the set of lints is not changed.
      
      `unsafe_op_in_unsafe_fn` is left unmodified, i.e. as an error, since it is
      becoming the default in the language (warn-by-default in Rust 2024 [1] and
      ideally an error later on) and thus it should also be very well tested. In
      addition, it is simple enough that it should not have false positives
      (unlike e.g. `rust_2018_idioms`'s `explicit_outlives_requirements`).
      
      `non_ascii_idents` is left unmodified as well, i.e. as an error, since
      it is unlikely one gains any productivity during development if it
      were a warning (in fact, it may be worse, since it is likely one made
      a typo). In addition, it should not have false positives.
      
      Finally, put the two `-D` ones at the top and take the chance to do one
      per line.
      
      Link: https://github.com/rust-lang/rust/pull/112038
      
       [1]
      Reviewed-by: default avatarFinn Behrens <me@kloenk.dev>
      Tested-by: default avatarBenno Lossin <benno.lossin@proton.me>
      Tested-by: default avatarAndreas Hindborg <a.hindborg@samsung.com>
      Link: https://lore.kernel.org/r/20240709160615.998336-5-ojeda@kernel.org
      
      
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      f8f88aa2
  17. Jul 08, 2024
  18. Jul 07, 2024
  19. Jun 30, 2024
  20. Jun 25, 2024
    • Tejun Heo's avatar
      sched_ext: Drop tools_clean target from the top-level Makefile · eb4a3b62
      Tejun Heo authored
      
      2a52ca7c ("sched_ext: Add scx_simple and scx_example_qmap example
      schedulers") added the tools_clean target which is triggered by mrproper.
      The tools_clean target triggers the sched_ext_clean target in tools/. This
      unfortunately makes mrproper fail when no BTF enabled kernel image is found:
      
        Makefile:83: *** Cannot find a vmlinux for VMLINUX_BTF at any of "  ../../vmlinux /sys/kernel/btf/vmlinux/boot/vmlinux-4.15.0-136-generic".  Stop.
        Makefile:192: recipe for target 'sched_ext_clean' failed
        make[2]: *** [sched_ext_clean] Error 2
        Makefile:1361: recipe for target 'sched_ext' failed
        make[1]: *** [sched_ext] Error 2
        Makefile:240: recipe for target '__sub-make' failed
        make: *** [__sub-make] Error 2
      
      Clean targets shouldn't fail like this but also it's really odd for mrproper
      to single out and trigger the sched_ext_clean target when no other clean
      targets under tools/ are triggered.
      
      Fix builds by dropping the tools_clean target from the top-level Makefile.
      The offending Makefile line is shared across BPF targets under tools/. Let's
      revisit them later.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Link: http://lkml.kernel.org/r/ac065f1f-8754-4626-95db-2c9fcf02567b@nvidia.com
      Fixes: 2a52ca7c ("sched_ext: Add scx_simple and scx_example_qmap example schedulers")
      Cc: David Vernet <void@manifault.com>
      eb4a3b62
  21. Jun 23, 2024
  22. Jun 18, 2024
    • Tejun Heo's avatar
      sched_ext: Add scx_simple and scx_example_qmap example schedulers · 2a52ca7c
      Tejun Heo authored
      
      Add two simple example BPF schedulers - simple and qmap.
      
      * simple: In terms of scheduling, it behaves identical to not having any
        operation implemented at all. The two operations it implements are only to
        improve visibility and exit handling. On certain homogeneous
        configurations, this actually can perform pretty well.
      
      * qmap: A fixed five level priority scheduler to demonstrate queueing PIDs
        on BPF maps for scheduling. While not very practical, this is useful as a
        simple example and will be used to demonstrate different features.
      
      v7: - Compat helpers stripped out in prepartion of upstreaming as the
            upstreamed patchset will be the baselinfe. Utility macros that can be
            used to implement compat features are kept.
      
          - Explicitly disable map autoattach on struct_ops to avoid trying to
            attach twice while maintaining compatbility with older libbpf.
      
      v6: - Common header files reorganized and cleaned up. Compat helpers are
            added to demonstrate how schedulers can maintain backward
            compatibility with older kernels while making use of newly added
            features.
      
          - simple_select_cpu() added to keep track of the number of local
            dispatches. This is needed because the default ops.select_cpu()
            implementation is updated to dispatch directly and won't call
            ops.enqueue().
      
          - Updated to reflect the sched_ext API changes. Switching all tasks is
            the default behavior now and scx_qmap supports partial switching when
            `-p` is specified.
      
          - tools/sched_ext/Kconfig dropped. This will be included in the doc
            instead.
      
      v5: - Improve Makefile. Build artifects are now collected into a separate
            dir which change be changed. Install and help targets are added and
            clean actually cleans everything.
      
          - MEMBER_VPTR() improved to improve access to structs. ARRAY_ELEM_PTR()
            and RESIZEABLE_ARRAY() are added to support resizable arrays in .bss.
      
          - Add scx_common.h which provides common utilities to user code such as
            SCX_BUG[_ON]() and RESIZE_ARRAY().
      
          - Use SCX_BUG[_ON]() to simplify error handling.
      
      v4: - Dropped _example prefix from scheduler names.
      
      v3: - Rename scx_example_dummy to scx_example_simple and restructure a bit
            to ease later additions. Comment updates.
      
          - Added declarations for BPF inline iterators. In the future, hopefully,
            these will be consolidated into a generic BPF header so that they
            don't need to be replicated here.
      
      v2: - Updated with the generic BPF cpumask helpers.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-by: default avatarDavid Vernet <dvernet@meta.com>
      Acked-by: default avatarJosh Don <joshdon@google.com>
      Acked-by: default avatarHao Luo <haoluo@google.com>
      Acked-by: default avatarBarret Rhoden <brho@google.com>
      2a52ca7c
  23. Jun 16, 2024
  24. Jun 09, 2024
  25. Jun 02, 2024
  26. May 26, 2024
  27. 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
  28. May 12, 2024
  29. 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 in Makefiles will have the following
      meanings:
      
        $(obj)     - directory in the object tree
        $(src)     - directory in the source tree  (changed by this commit)
        $(objtree) - the top of the kernel object tree
        $(srctree) - the top of the kernel source tree
      
      Consequently, $(srctree)/$(src) in upstream Makefiles need to be replaced
      with $(src).
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <nicolas@fjasle.eu>
      b1992c37
  30. May 05, 2024
  31. 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
  32. Apr 28, 2024
Loading