1. 13 Mar, 2024 2 commits
  2. 28 Feb, 2024 1 commit
  3. 27 Feb, 2024 7 commits
  4. 15 Feb, 2024 3 commits
  5. 14 Feb, 2024 2 commits
    • Linus Torvalds's avatar
      Merge tag 'for-6.8-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 1f3a3e2a
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
       "A few regular fixes and one fix for space reservation regression since
        6.7 that users have been reporting:
      
         - fix over-reservation of metadata chunks due to not keeping proper
           balance between global block reserve and delayed refs reserve; in
           practice this leaves behind empty metadata block groups, the
           workaround is to reclaim them by using the '-musage=1' balance
           filter
      
         - other space reservation fixes:
            - do not delete unused block group if it may be used soon
            - do not reserve space for checksums for NOCOW files
      
         - fix extent map assertion failure when writing out free space inode
      
         - reject encoded write if inode has nodatasum flag set
      
         - fix chunk map leak when loading block group zone info"
      
      * tag 'for-6.8-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: don't refill whole delayed refs block reserve when starting transaction
        btrfs: zoned: fix chunk map leak when loading block group zone info
        btrfs: reject encoded write if inode has nodatasum flag set
        btrfs: don't reserve space for checksums when writing to nocow files
        btrfs: add new unused block groups to the list of unused block groups
        btrfs: do not delete unused block group if it may be used soon
        btrfs: add and use helper to check if block group is used
        btrfs: don't drop extent_map for free space inode on write error
      1f3a3e2a
    • Linus Torvalds's avatar
      Merge tag 'linux_kselftest-kunit-fixes-6.8-rc5' of... · 91f842ff
      Linus Torvalds authored
      Merge tag 'linux_kselftest-kunit-fixes-6.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull KUnit fix from Shuah Khan:
       "One important fix to unregister kunit_bus when KUnit module is
        unloaded.
      
        Not doing so causes an error when KUnit module tries to re-register
        the bus when it gets reloaded"
      
      * tag 'linux_kselftest-kunit-fixes-6.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        kunit: device: Unregister the kunit_bus on shutdown
      91f842ff
  6. 13 Feb, 2024 8 commits
    • Filipe Manana's avatar
      btrfs: don't refill whole delayed refs block reserve when starting transaction · 2f6397e4
      Filipe Manana authored
      Since commit 28270e25 ("btrfs: always reserve space for delayed refs
      when starting transaction") we started not only to reserve metadata space
      for the delayed refs a caller of btrfs_start_transaction() might generate
      but also to try to fully refill the delayed refs block reserve, because
      there are several case where we generate delayed refs and haven't reserved
      space for them, relying on the global block reserve. Relying too much on
      the global block reserve is not always safe, and can result in hitting
      -ENOSPC during transaction commits or worst, in rare cases, being unable
      to mount a filesystem that needs to do orphan cleanup or anything that
      requires modifying the filesystem during mount, and has no more
      unallocated space and the metadata space is nearly full. This was
      explained in detail in that commit's change log.
      
      However the gap between the reserved amount and the size of the delayed
      refs block reserve can be huge, so attempting to reserve space for such
      a gap can result in allocating many metadata block groups that end up
      not being used. After a recent patch, with the subject:
      
        "btrfs: add new unused block groups to the list of unused block groups"
      
      We started to add new block groups that are unused to the list of unused
      block groups, to avoid having them around for a very long time in case
      they are never used, because a block group is only added to the list of
      unused block groups when we deallocate the last extent or when mounting
      the filesystem and the block group has 0 bytes used. This is not a problem
      introduced by the commit mentioned earlier, it always existed as our
      metadata space reservations are, most of the time, pessimistic and end up
      not using all the space they reserved, so we can occasionally end up with
      one or two unused metadata block groups for a long period. However after
      that commit mentioned earlier, we are just more pessimistic in the
      metadata space reservations when starting a transaction and therefore the
      issue is more likely to happen.
      
      This however is not always enough because we might create unused metadata
      block groups when reserving metadata space at a high rate if there's
      always a gap in the delayed refs block reserve and the cleaner kthread
      isn't triggered often enough or is busy with other work (running delayed
      iputs, cleaning deleted roots, etc), not to mention the block group's
      allocated space is only usable for a new block group after the transaction
      used to remove it is committed.
      
      A user reported that he's getting a lot of allocated metadata block groups
      but the usage percentage of metadata space was very low compared to the
      total allocated space, specially after running a series of block group
      relocations.
      
      So for now stop trying to refill the gap in the delayed refs block reserve
      and reserve space only for the delayed refs we are expected to generate
      when starting a transaction.
      
      CC: stable@vger.kernel.org # 6.7+
      Reported-by: default avatarIvan Shapovalov <intelfx@intelfx.name>
      Link: https://lore.kernel.org/linux-btrfs/9cdbf0ca9cdda1b4c84e15e548af7d7f9f926382.camel@intelfx.name/
      Link: https://lore.kernel.org/linux-btrfs/CAL3q7H6802ayLHUJFztzZAVzBLJAGdFx=6FHNNy87+obZXXZpQ@mail.gmail.com/Tested-by: default avatarIvan Shapovalov <intelfx@intelfx.name>
      Reported-by: default avatarHeddxh <g311571057@gmail.com>
      Link: https://lore.kernel.org/linux-btrfs/CAE93xANEby6RezOD=zcofENYZOT-wpYygJyauyUAZkLv6XVFOA@mail.gmail.com/Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      2f6397e4
    • Filipe Manana's avatar
      btrfs: zoned: fix chunk map leak when loading block group zone info · 88e81a67
      Filipe Manana authored
      At btrfs_load_block_group_zone_info() we never drop a reference on the
      chunk map we have looked up, therefore leaking a reference on it. So
      add the missing btrfs_free_chunk_map() at the end of the function.
      
      Fixes: 7dc66abb ("btrfs: use a dedicated data structure for chunk maps")
      Reported-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Tested-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      88e81a67
    • Filipe Manana's avatar
      btrfs: reject encoded write if inode has nodatasum flag set · 1bd96c92
      Filipe Manana authored
      Currently we allow an encoded write against inodes that have the NODATASUM
      flag set, either because they are NOCOW files or they were created while
      the filesystem was mounted with "-o nodatasum". This results in having
      compressed extents without corresponding checksums, which is a filesystem
      inconsistency reported by 'btrfs check'.
      
      For example, running btrfs/281 with MOUNT_OPTIONS="-o nodatacow" triggers
      this and 'btrfs check' errors out with:
      
         [1/7] checking root items
         [2/7] checking extents
         [3/7] checking free space tree
         [4/7] checking fs roots
         root 256 inode 257 errors 1040, bad file extent, some csum missing
         root 256 inode 258 errors 1040, bad file extent, some csum missing
         ERROR: errors found in fs roots
         (...)
      
      So reject encoded writes if the target inode has NODATASUM set.
      
      CC: stable@vger.kernel.org # 6.1+
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      1bd96c92
    • Filipe Manana's avatar
      btrfs: don't reserve space for checksums when writing to nocow files · feefe1f4
      Filipe Manana authored
      Currently when doing a write to a file we always reserve metadata space
      for inserting data checksums. However we don't need to do it if we have
      a nodatacow file (-o nodatacow mount option or chattr +C) or if checksums
      are disabled (-o nodatasum mount option), as in that case we are only
      adding unnecessary pressure to metadata reservations.
      
      For example on x86_64, with the default node size of 16K, a 4K buffered
      write into a nodatacow file is reserving 655360 bytes of metadata space,
      as it's accounting for checksums. After this change, which stops reserving
      space for checksums if we have a nodatacow file or checksums are disabled,
      we only need to reserve 393216 bytes of metadata.
      
      CC: stable@vger.kernel.org # 6.1+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      feefe1f4
    • Linus Torvalds's avatar
      Merge tag 'trace-tools-v6.8-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace · 7e90b5c2
      Linus Torvalds authored
      Pull tracing tooling fixes from Steven Rostedt:
       "RTLA:
      
         - rtla tools are exiting with a positive value when usage() is
           called. Make them return 0 if the usage was called via -h/--help
      
         - the -P priority sets the sched priority for rtla workload. When the
           SCHED_OTHER scheduler is selected, it sets the rt_priority instead
           of the nice parameter. Setting the nice value is the correct thing,
           so fix it
      
         - rtla is failing to compile with clang due to unsupported options
           from gcc. Adjusting the compiler/linker options makes clang work
           properly
      
         - Remove the sched_getattr() unused function on utils.c
      
         - Fixes for variable initialization and size, reported by clang
      
        Verification:
      
         - rv is failing to compile with clang due to unsupported options from
           gcc. Adjusting the compiler/linker options makes clang work
           properly
      
         - Fix an uninitialized variable on in_kernel.c reported by clang"
      
      * tag 'trace-tools-v6.8-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
        tools/rtla: Exit with EXIT_SUCCESS when help is invoked
        tools/rtla: Replace setting prio with nice for SCHED_OTHER
        tools/rv: Fix curr_reactor uninitialized variable
        tools/rv: Fix Makefile compiler options for clang
        tools/rtla: Remove unused sched_getattr() function
        tools/rtla: Fix clang warning about mount_point var size
        tools/rtla: Fix uninitialized bucket/data->bucket_size warning
        tools/rtla: Fix Makefile compiler options for clang
      7e90b5c2
    • Tatsunosuke Tobita's avatar
      HID: wacom: generic: Avoid reporting a serial of '0' to userspace · ab41a31d
      Tatsunosuke Tobita authored
      The xf86-input-wacom driver does not treat '0' as a valid serial
      number and will drop any input report which contains an
      MSC_SERIAL = 0 event. The kernel driver already takes care to
      avoid sending any MSC_SERIAL event if the value of serial[0] == 0
      (which is the case for devices that don't actually report a
      serial number), but this is not quite sufficient.
      Only the lower 32 bits of the serial get reported to userspace,
      so if this portion of the serial is zero then there can still
      be problems.
      
      This commit allows the driver to report either the lower 32 bits
      if they are non-zero or the upper 32 bits otherwise.
      Signed-off-by: default avatarJason Gerecke <jason.gerecke@wacom.com>
      Signed-off-by: default avatarTatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
      Fixes: f85c9dc6 ("HID: wacom: generic: Support tool ID and additional tool types")
      CC: stable@vger.kernel.org # v4.10
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
      ab41a31d
    • Even Xu's avatar
      HID: Intel-ish-hid: Ishtp: Fix sensor reads after ACPI S3 suspend · bdab6c94
      Even Xu authored
      After legacy suspend/resume via ACPI S3, sensor read operation fails
      with timeout. Also, it will cause delay in resume operation as there
      will be retries on failure.
      
      This is caused by commit f645a90e ("HID: intel-ish-hid:
      ishtp-hid-client: use helper functions for connection"), which used
      helper functions to simplify connect, reset and disconnect process.
      Also avoid freeing and allocating client buffers again during reconnect
      process.
      
      But there is a case, when ISH firmware resets after ACPI S3 suspend,
      ishtp bus driver frees client buffers. Since there is no realloc again
      during reconnect, there are no client buffers available to send connection
      requests to the firmware. Without successful connection to the firmware,
      subsequent sensor reads will timeout.
      
      To address this issue, ishtp bus driver does not free client buffers on
      warm reset after S3 resume. Simply add the buffers from the read list
      to free list of buffers.
      
      Fixes: f645a90e ("HID: intel-ish-hid: ishtp-hid-client: use helper functions for connection")
      Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218442Signed-off-by: default avatarEven Xu <even.xu@intel.com>
      Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
      bdab6c94
    • Manuel Fombuena's avatar
      HID: multitouch: Add required quirk for Synaptics 0xcddc device · 1741a826
      Manuel Fombuena authored
      Add support for the pointing stick (Accupoint) and 2 mouse buttons.
      
      Present on some Toshiba/dynabook Portege X30 and X40 laptops.
      
      It should close https://bugzilla.kernel.org/show_bug.cgi?id=205817Signed-off-by: default avatarManuel Fombuena <fombuena@outlook.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
      1741a826
  7. 12 Feb, 2024 14 commits
    • Linus Torvalds's avatar
      Merge tag 'docs-6.8-fixes2' of git://git.lwn.net/linux · c664e16b
      Linus Torvalds authored
      Pull documentation fix from Jonathan Corbet:
       "A single fix to the kernel_feat extension for a bug that will crash
        the docs build in some situations"
      
      * tag 'docs-6.8-fixes2' of git://git.lwn.net/linux:
        docs: kernel_feat.py: fix build error for missing files
      c664e16b
    • Jiaxun Yang's avatar
      mm/memory: Use exception ip to search exception tables · 8fa50708
      Jiaxun Yang authored
      On architectures with delay slot, instruction_pointer() may differ
      from where exception was triggered.
      
      Use exception_ip we just introduced to search exception tables to
      get rid of the problem.
      
      Fixes: 4bce37a6 ("mips/mm: Convert to using lock_mm_and_find_vma()")
      Reported-by: default avatarXi Ruoyao <xry111@xry111.site>
      Link: https://lore.kernel.org/r/75e9fd7b08562ad9b456a5bdaacb7cc220311cc9.camel@xry111.site/Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      8fa50708
    • Jiaxun Yang's avatar
      MIPS: Clear Cause.BD in instruction_pointer_set · 9d6e21dd
      Jiaxun Yang authored
      Clear Cause.BD after we use instruction_pointer_set to override
      EPC.
      
      This can prevent exception_epc check against instruction code at
      new return address.
      It won't be considered as "in delay slot" after epc being overridden
      anyway.
      Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      9d6e21dd
    • Jiaxun Yang's avatar
      ptrace: Introduce exception_ip arch hook · 11ba1728
      Jiaxun Yang authored
      On architectures with delay slot, architecture level instruction
      pointer (or program counter) in pt_regs may differ from where
      exception was triggered.
      
      Introduce exception_ip hook to invoke architecture code and determine
      actual instruction pointer to the exception.
      
      Link: https://lore.kernel.org/lkml/00d1b813-c55f-4365-8d81-d70258e10b16@app.fastmail.com/Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      11ba1728
    • Guenter Roeck's avatar
      MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler · d55347bf
      Guenter Roeck authored
      After 'lib: checksum: Use aligned accesses for ip_fast_csum and
      csum_ipv6_magic tests' was applied, the test_csum_ipv6_magic unit test
      started failing for all mips platforms, both little and bit endian.
      Oddly enough, adding debug code into test_csum_ipv6_magic() made the
      problem disappear.
      
      The gcc manual says:
      
      "The "memory" clobber tells the compiler that the assembly code performs
       memory reads or writes to items other than those listed in the input
       and output operands (for example, accessing the memory pointed to by one
       of the input parameters)
      "
      
      This is definitely the case for csum_ipv6_magic(). Indeed, adding the
      'memory' clobber fixes the problem.
      
      Cc: Charlie Jenkins <charlie@rivosinc.com>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Reviewed-by: default avatarCharlie Jenkins <charlie@rivosinc.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      d55347bf
    • Linus Torvalds's avatar
      Merge tag 'vfs-6.8-rc5.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs · 716f4aaa
      Linus Torvalds authored
      Pull vfs fixes from Christian Brauner:
      
       - Fix performance regression introduced by moving the security
         permission hook out of do_clone_file_range() and into its caller
         vfs_clone_file_range().
      
         This causes the security hook to be called in situation were it
         wasn't called before as the fast permission checks were left in
         do_clone_file_range().
      
         Fix this by merging the two implementations back together and
         restoring the old ordering: fast permission checks first, expensive
         ones later.
      
       - Tweak mount_setattr() permission checking so that mount properties on
         the real rootfs can be changed.
      
         When we added mount_setattr() we added additional checks compared to
         legacy mount(2). If the mount had a parent then verify that the
         caller and the mount namespace the mount is attached to match and if
         not make sure that it's an anonymous mount.
      
         But the real rootfs falls into neither category. It is neither an
         anoymous mount because it is obviously attached to the initial mount
         namespace but it also obviously doesn't have a parent mount. So that
         means legacy mount(2) allows changing mount properties on the real
         rootfs but mount_setattr(2) blocks this. This causes regressions (See
         the commit for details).
      
         Fix this by relaxing the check. If the mount has a parent or if it
         isn't a detached mount, verify that the mount namespaces of the
         caller and the mount are the same. Technically, we could probably
         write this even simpler and check that the mount namespaces match if
         it isn't a detached mount. But the slightly longer check makes it
         clearer what conditions one needs to think about.
      
      * tag 'vfs-6.8-rc5.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
        fs: relax mount_setattr() permission checks
        remap_range: merge do_clone_file_range() into vfs_clone_file_range()
      716f4aaa
    • John Kacur's avatar
      tools/rtla: Exit with EXIT_SUCCESS when help is invoked · b5f31936
      John Kacur authored
      Fix rtla so that the following commands exit with 0 when help is invoked
      
      rtla osnoise top -h
      rtla osnoise hist -h
      rtla timerlat top -h
      rtla timerlat hist -h
      
      Link: https://lore.kernel.org/linux-trace-devel/20240203001607.69703-1-jkacur@redhat.com
      
      Cc: stable@vger.kernel.org
      Fixes: 1eeb6328 ("rtla/timerlat: Add timerlat hist mode")
      Signed-off-by: default avatarJohn Kacur <jkacur@redhat.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      b5f31936
    • limingming3's avatar
      tools/rtla: Replace setting prio with nice for SCHED_OTHER · 14f08c97
      limingming3 authored
      Since the sched_priority for SCHED_OTHER is always 0, it makes no
      sence to set it.
      Setting nice for SCHED_OTHER seems more meaningful.
      
      Link: https://lkml.kernel.org/r/20240207065142.1753909-1-limingming3@lixiang.com
      
      Cc: stable@vger.kernel.org
      Fixes: b1696371 ("rtla: Helper functions for rtla")
      Signed-off-by: default avatarlimingming3 <limingming3@lixiang.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      14f08c97
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Fix curr_reactor uninitialized variable · 61ec586b
      Daniel Bristot de Oliveira authored
      clang is reporting:
      
      $ make HOSTCC=clang CC=clang LLVM_IAS=1
      
      clang -O -g -DVERSION=\"6.8.0-rc3\" -flto=auto -fexceptions
      	-fstack-protector-strong -fasynchronous-unwind-tables
      	-fstack-clash-protection  -Wall -Werror=format-security
      	-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
      	$(pkg-config --cflags libtracefs)  -I include
      	-c -o src/in_kernel.o src/in_kernel.c
      [...]
      
      src/in_kernel.c:227:6: warning: variable 'curr_reactor' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        227 |         if (!end)
            |             ^~~~
      src/in_kernel.c:242:9: note: uninitialized use occurs here
        242 |         return curr_reactor;
            |                ^~~~~~~~~~~~
      src/in_kernel.c:227:2: note: remove the 'if' if its condition is always false
        227 |         if (!end)
            |         ^~~~~~~~~
        228 |                 goto out_free;
            |                 ~~~~~~~~~~~~~
      src/in_kernel.c:221:6: warning: variable 'curr_reactor' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        221 |         if (!start)
            |             ^~~~~~
      src/in_kernel.c:242:9: note: uninitialized use occurs here
        242 |         return curr_reactor;
            |                ^~~~~~~~~~~~
      src/in_kernel.c:221:2: note: remove the 'if' if its condition is always false
        221 |         if (!start)
            |         ^~~~~~~~~~~
        222 |                 goto out_free;
            |                 ~~~~~~~~~~~~~
      src/in_kernel.c:215:20: note: initialize the variable 'curr_reactor' to silence this warning
        215 |         char *curr_reactor;
            |                           ^
            |                            = NULL
      2 warnings generated.
      
      Which is correct. Setting curr_reactor to NULL avoids the problem.
      
      Link: https://lkml.kernel.org/r/3a35551149e5ee0cb0950035afcb8082c3b5d05b.1707217097.git.bristot@kernel.org
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Justin Stitt <justinstitt@google.com>
      Cc: Donald Zickus <dzickus@redhat.com>
      Fixes: 6d60f896 ("tools/rv: Add in-kernel monitor interface")
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      61ec586b
    • Daniel Bristot de Oliveira's avatar
      tools/rv: Fix Makefile compiler options for clang · f9b2c871
      Daniel Bristot de Oliveira authored
      The following errors are showing up when compiling rv with clang:
      
       $ make HOSTCC=clang CC=clang LLVM_IAS=1
       [...]
        clang -O -g -DVERSION=\"6.8.0-rc1\" -flto=auto -ffat-lto-objects
        -fexceptions -fstack-protector-strong -fasynchronous-unwind-tables
        -fstack-clash-protection  -Wall -Werror=format-security
        -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
        -Wno-maybe-uninitialized $(pkg-config --cflags libtracefs)
        -I include   -c -o src/utils.o src/utils.c
        clang: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
        warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
        1 warning generated.
      
        clang -o rv -ggdb  src/in_kernel.o src/rv.o src/trace.o src/utils.o $(pkg-config --libs libtracefs)
        src/in_kernel.o: file not recognized: file format not recognized
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make: *** [Makefile:110: rv] Error 1
      
      Solve these issues by:
        - removing -ffat-lto-objects and -Wno-maybe-uninitialized if using clang
        - informing the linker about -flto=auto
      
      Link: https://lkml.kernel.org/r/ed94a8ddc2ca8c8ef663cfb7ae9dd196c4a66b33.1707217097.git.bristot@kernel.org
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Justin Stitt <justinstitt@google.com>
      Fixes: 4bc4b131 ("rv: Add rv tool")
      Suggested-by: default avatarDonald Zickus <dzickus@redhat.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      f9b2c871
    • Daniel Bristot de Oliveira's avatar
      tools/rtla: Remove unused sched_getattr() function · 084ce16d
      Daniel Bristot de Oliveira authored
      Clang is reporting:
      
      $ make HOSTCC=clang CC=clang LLVM_IAS=1
      [...]
      clang -O -g -DVERSION=\"6.8.0-rc3\" -flto=auto -fexceptions -fstack-protector-strong -fasynchronous-unwind-tables -fstack-clash-protection  -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS $(pkg-config --cflags libtracefs)    -c -o src/utils.o src/utils.c
      src/utils.c:241:19: warning: unused function 'sched_getattr' [-Wunused-function]
        241 | static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
            |                   ^~~~~~~~~~~~~
      1 warning generated.
      
      Which is correct, so remove the unused function.
      
      Link: https://lkml.kernel.org/r/eaed7ba122c4ae88ce71277c824ef41cbf789385.1707217097.git.bristot@kernel.org
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Justin Stitt <justinstitt@google.com>
      Cc: Donald Zickus <dzickus@redhat.com>
      Fixes: b1696371 ("rtla: Helper functions for rtla")
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      084ce16d
    • Daniel Bristot de Oliveira's avatar
      tools/rtla: Fix clang warning about mount_point var size · 30369084
      Daniel Bristot de Oliveira authored
      clang is reporting this warning:
      
      $ make HOSTCC=clang CC=clang LLVM_IAS=1
      [...]
      clang -O -g -DVERSION=\"6.8.0-rc3\" -flto=auto -fexceptions
      	-fstack-protector-strong -fasynchronous-unwind-tables
      	-fstack-clash-protection  -Wall -Werror=format-security
      	-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
      	$(pkg-config --cflags libtracefs)    -c -o src/utils.o src/utils.c
      
      src/utils.c:548:66: warning: 'fscanf' may overflow; destination buffer in argument 3 has size 1024, but the corresponding specifier may require size 1025 [-Wfortify-source]
        548 |         while (fscanf(fp, "%*s %" STR(MAX_PATH) "s %99s %*s %*d %*d\n", mount_point, type) == 2) {
            |                                                                         ^
      
      Increase mount_point variable size to MAX_PATH+1 to avoid the overflow.
      
      Link: https://lkml.kernel.org/r/1b46712e93a2f4153909514a36016959dcc4021c.1707217097.git.bristot@kernel.org
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Justin Stitt <justinstitt@google.com>
      Cc: Donald Zickus <dzickus@redhat.com>
      Fixes: a957cbc0 ("rtla: Add -C cgroup support")
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      30369084
    • Daniel Bristot de Oliveira's avatar
      tools/rtla: Fix uninitialized bucket/data->bucket_size warning · 64dc40f7
      Daniel Bristot de Oliveira authored
      When compiling rtla with clang, I am getting the following warnings:
      
      $ make HOSTCC=clang CC=clang LLVM_IAS=1
      
      [..]
      clang -O -g -DVERSION=\"6.8.0-rc3\" -flto=auto -fexceptions
      	-fstack-protector-strong -fasynchronous-unwind-tables
      	-fstack-clash-protection  -Wall -Werror=format-security
      	-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
      	$(pkg-config --cflags libtracefs)
      	-c -o src/osnoise_hist.o src/osnoise_hist.c
      src/osnoise_hist.c:138:6: warning: variable 'bucket' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        138 |         if (data->bucket_size)
            |             ^~~~~~~~~~~~~~~~~
      src/osnoise_hist.c:149:6: note: uninitialized use occurs here
        149 |         if (bucket < entries)
            |             ^~~~~~
      src/osnoise_hist.c:138:2: note: remove the 'if' if its condition is always true
        138 |         if (data->bucket_size)
            |         ^~~~~~~~~~~~~~~~~~~~~~
        139 |                 bucket = duration / data->bucket_size;
      src/osnoise_hist.c:132:12: note: initialize the variable 'bucket' to silence this warning
        132 |         int bucket;
            |                   ^
            |                    = 0
      1 warning generated.
      
      [...]
      
      clang -O -g -DVERSION=\"6.8.0-rc3\" -flto=auto -fexceptions
      	-fstack-protector-strong -fasynchronous-unwind-tables
      	-fstack-clash-protection  -Wall -Werror=format-security
      	-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS
      	$(pkg-config --cflags libtracefs)
      	-c -o src/timerlat_hist.o src/timerlat_hist.c
      src/timerlat_hist.c:181:6: warning: variable 'bucket' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        181 |         if (data->bucket_size)
            |             ^~~~~~~~~~~~~~~~~
      src/timerlat_hist.c:204:6: note: uninitialized use occurs here
        204 |         if (bucket < entries)
            |             ^~~~~~
      src/timerlat_hist.c:181:2: note: remove the 'if' if its condition is always true
        181 |         if (data->bucket_size)
            |         ^~~~~~~~~~~~~~~~~~~~~~
        182 |                 bucket = latency / data->bucket_size;
      src/timerlat_hist.c:175:12: note: initialize the variable 'bucket' to silence this warning
        175 |         int bucket;
            |                   ^
            |                    = 0
      1 warning generated.
      
      This is a legit warning, but data->bucket_size is always > 0 (see
      timerlat_hist_parse_args()), so the if is not necessary.
      
      Remove the unneeded if (data->bucket_size) to avoid the warning.
      
      Link: https://lkml.kernel.org/r/6e1b1665cd99042ae705b3e0fc410858c4c42346.1707217097.git.bristot@kernel.org
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Justin Stitt <justinstitt@google.com>
      Cc: Donald Zickus <dzickus@redhat.com>
      Fixes: 1eeb6328 ("rtla/timerlat: Add timerlat hist mode")
      Fixes: 829a6c0b ("rtla/osnoise: Add the hist mode")
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      64dc40f7
    • Daniel Bristot de Oliveira's avatar
      tools/rtla: Fix Makefile compiler options for clang · bc4cbc9d
      Daniel Bristot de Oliveira authored
      The following errors are showing up when compiling rtla with clang:
      
       $ make HOSTCC=clang CC=clang LLVM_IAS=1
       [...]
      
        clang -O -g -DVERSION=\"6.8.0-rc1\" -flto=auto -ffat-lto-objects
      	-fexceptions -fstack-protector-strong
      	-fasynchronous-unwind-tables -fstack-clash-protection  -Wall
      	-Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
      	-Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized
      	$(pkg-config --cflags libtracefs)    -c -o src/utils.o src/utils.c
      
        clang: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
        warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
        1 warning generated.
      
        clang -o rtla -ggdb  src/osnoise.o src/osnoise_hist.o src/osnoise_top.o
        src/rtla.o src/timerlat_aa.o src/timerlat.o src/timerlat_hist.o
        src/timerlat_top.o src/timerlat_u.o src/trace.o src/utils.o $(pkg-config --libs libtracefs)
      
        src/osnoise.o: file not recognized: file format not recognized
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make: *** [Makefile:110: rtla] Error 1
      
      Solve these issues by:
        - removing -ffat-lto-objects and -Wno-maybe-uninitialized if using clang
        - informing the linker about -flto=auto
      
      Link: https://lore.kernel.org/linux-trace-kernel/567ac1b94effc228ce9a0225b9df7232a9b35b55.1707217097.git.bristot@kernel.org
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Justin Stitt <justinstitt@google.com>
      Fixes: 1a7b22ab ("tools/rtla: Build with EXTRA_{C,LD}FLAGS")
      Suggested-by: default avatarDonald Zickus <dzickus@redhat.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      bc4cbc9d
  8. 11 Feb, 2024 3 commits