1. 18 Mar, 2024 40 commits
    • Linus Torvalds's avatar
      Merge tag 'dlm-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm · b3603fcb
      Linus Torvalds authored
      Pull dlm updates from David Teigland:
      
       - Fix mistaken variable assignment that caused a refcounting problem
      
       - Revert a recent change that began using atomic counters where they
         were not needed (for lkb wait_count)
      
       - Add comments around forced state reset for waiting lock operations
         during recovery
      
      * tag 'dlm-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm:
        dlm: add comments about forced waiters reset
        dlm: revert atomic_t lkb_wait_count
        dlm: fix user space lkb refcounting
      b3603fcb
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · 6207b37e
      Linus Torvalds authored
      Pull rdma updates from Jason Gunthorpe:
       "Very small update this cycle:
      
         - Minor code improvements in fi, rxe, ipoib, mana, cxgb4, mlx5,
           irdma, rxe, rtrs, mana
      
         - Simplify the hns hem mechanism
      
         - Fix EFA's MSI-X allocation in resource constrained configurations
      
         - Fix a KASN splat in srpt
      
         - Narrow hns's congestion control selection to QPs granularity and
           allow userspace to select it
      
         - Solve a parallel module loading race between the CM module and a
           driver module
      
         - Flexible array cleanup
      
         - Dump hns's SCC Conext to 'rdma res' for debugging
      
         - Make mana build page lists for HW objects that require a 0 offset
           correctly
      
         - Stuck CM ID debugging"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (29 commits)
        RDMA/cm: add timeout to cm_destroy_id wait
        RDMA/mana_ib: Use virtual address in dma regions for MRs
        RDMA/mana_ib: Fix bug in creation of dma regions
        RDMA/hns: Append SCC context to the raw dump of QPC
        RDMA/uverbs: Avoid -Wflex-array-member-not-at-end warnings
        RDMA/hns: Support userspace configuring congestion control algorithm with QP granularity
        RDMA/rtrs-clt: Check strnlen return len in sysfs mpath_policy_store()
        RDMA/uverbs: Remove flexible arrays from struct *_filter
        RDMA/device: Fix a race between mad_client and cm_client init
        RDMA/hns: Fix mis-modifying default congestion control algorithm
        RDMA/rxe: Remove unused 'iova' parameter from rxe_mr_init_user
        RDMA/srpt: Do not register event handler until srpt device is fully setup
        RDMA/irdma: Remove duplicate assignment
        RDMA/efa: Limit EQs to available MSI-X vectors
        RDMA/mlx5: Delete unused mlx5_ib_copy_pas prototype
        RDMA/cxgb4: Delete unused c4iw_ep_redirect prototype
        RDMA/mana_ib: Introduce mana_ib_install_cq_cb helper function
        RDMA/mana_ib: Introduce mana_ib_get_netdev helper function
        RDMA/mana_ib: Introduce mdev_to_gc helper function
        RDMA/hns: Simplify 'struct hns_roce_hem' allocation
        ...
      6207b37e
    • Linus Torvalds's avatar
      Merge tag 'ktest-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest · 65b64246
      Linus Torvalds authored
      Pull ktest updates from Steven Rostedt:
      
       - Allow variables to contain variables. This makes the shell commands
         have a bit more flexibility to reuse existing variables.
      
       - Have make_warnings_file in build-only mode require limited variables
      
         The make_warnings_file test will create a file with all existing
         warnings (which can be used to compare against in builds with new
         commits). Add it to the build-only list that doesn't require other
         variables (like how to reset a machine), as the make_warnings_file
         makes the most sense on build only tests.
      
      * tag 'ktest-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest:
        ktest: force $buildonly = 1 for 'make_warnings_file' test type
        ktest.pl: Process variables within variables
      65b64246
    • Linus Torvalds's avatar
      Merge tag 'trace-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace · ad584d73
      Linus Torvalds authored
      Pull tracing updates from Steven Rostedt:
       "Main user visible change:
      
         - User events can now have "multi formats"
      
           The current user events have a single format. If another event is
           created with a different format, it will fail to be created. That
           is, once an event name is used, it cannot be used again with a
           different format. This can cause issues if a library is using an
           event and updates its format. An application using the older format
           will prevent an application using the new library from registering
           its event.
      
           A task could also DOS another application if it knows the event
           names, and it creates events with different formats.
      
           The multi-format event is in a different name space from the single
           format. Both the event name and its format are the unique
           identifier. This will allow two different applications to use the
           same user event name but with different payloads.
      
         - Added support to have ftrace_dump_on_oops dump out instances and
           not just the main top level tracing buffer.
      
        Other changes:
      
         - Add eventfs_root_inode
      
           Only the root inode has a dentry that is static (never goes away)
           and stores it upon creation. There's no reason that the thousands
           of other eventfs inodes should have a pointer that never gets set
           in its descriptor. Create a eventfs_root_inode desciptor that has a
           eventfs_inode descriptor and a dentry pointer, and only the root
           inode will use this.
      
         - Added WARN_ON()s in eventfs
      
           There's some conditionals remaining in eventfs that should never be
           hit, but instead of removing them, add WARN_ON() around them to
           make sure that they are never hit.
      
         - Have saved_cmdlines allocation also include the map_cmdline_to_pid
           array
      
           The saved_cmdlines structure allocates a large amount of data to
           hold its mappings. Within it, it has three arrays. Two are already
           apart of it: map_pid_to_cmdline[] and saved_cmdlines[]. More memory
           can be saved by also including the map_cmdline_to_pid[] array as
           well.
      
         - Restructure __string() and __assign_str() macros used in
           TRACE_EVENT()
      
           Dynamic strings in TRACE_EVENT() are declared with:
      
               __string(name, source)
      
           And assigned with:
      
              __assign_str(name, source)
      
           In the tracepoint callback of the event, the __string() is used to
           get the size needed to allocate on the ring buffer and
           __assign_str() is used to copy the string into the ring buffer.
           There's a helper structure that is created in the TRACE_EVENT()
           macro logic that will hold the string length and its position in
           the ring buffer which is created by __string().
      
           There are several trace events that have a function to create the
           string to save. This function is executed twice. Once for
           __string() and again for __assign_str(). There's no reason for
           this. The helper structure could also save the string it used in
           __string() and simply copy that into __assign_str() (it also
           already has its length).
      
           By using the structure to store the source string for the
           assignment, it means that the second argument to __assign_str() is
           no longer needed.
      
           It will be removed in the next merge window, but for now add a
           warning if the source string given to __string() is different than
           the source string given to __assign_str(), as the source to
           __assign_str() isn't even used and will be going away.
      
         - Added checks to make sure that the source of __string() is also the
           source of __assign_str() so that it can be safely removed in the
           next merge window.
      
           Included fixes that the above check found.
      
         - Other minor clean ups and fixes"
      
      * tag 'trace-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (34 commits)
        tracing: Add __string_src() helper to help compilers not to get confused
        tracing: Use strcmp() in __assign_str() WARN_ON() check
        tracepoints: Use WARN() and not WARN_ON() for warnings
        tracing: Use div64_u64() instead of do_div()
        tracing: Support to dump instance traces by ftrace_dump_on_oops
        tracing: Remove second parameter to __assign_rel_str()
        tracing: Add warning if string in __assign_str() does not match __string()
        tracing: Add __string_len() example
        tracing: Remove __assign_str_len()
        ftrace: Fix most kernel-doc warnings
        tracing: Decrement the snapshot if the snapshot trigger fails to register
        tracing: Fix snapshot counter going between two tracers that use it
        tracing: Use EVENT_NULL_STR macro instead of open coding "(null)"
        tracing: Use ? : shortcut in trace macros
        tracing: Do not calculate strlen() twice for __string() fields
        tracing: Rework __assign_str() and __string() to not duplicate getting the string
        cxl/trace: Properly initialize cxl_poison region name
        net: hns3: tracing: fix hclgevf trace event strings
        drm/i915: Add missing ; to __assign_str() macros in tracepoint code
        NFSD: Fix nfsd_clid_class use of __string_len() macro
        ...
      ad584d73
    • Linus Torvalds's avatar
      Merge tag 'sysctl-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl · 2cb5c868
      Linus Torvalds authored
      Pull sysctl updates from Joel Granados:
       "No functional changes - additional testing is required for the rest of
        the pending changes.
      
         - New shared repo for sysctl maintenance
      
         - check-sysctl-docs adjustment for API changes by Thomas Weißschuh"
      
      * tag 'sysctl-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl:
        scripts: check-sysctl-docs: handle per-namespace sysctls
        ipc: remove linebreaks from arguments of __register_sysctl_table
        scripts: check-sysctl-docs: adapt to new API
        MAINTAINERS: Update sysctl tree location
      2cb5c868
    • Linus Torvalds's avatar
      Merge tag 'for-linus-6.9-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux · bf3a69c6
      Linus Torvalds authored
      Pull orangefs updates from Mike Marshall:
       "One fix, one cleanup...
      
        Fix: Julia Lawall pointed out a null pointer dereference.
      
        Cleanup: Vlastimil Babka sent me a patch to remove some SLAB related
        code"
      
      * tag 'for-linus-6.9-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux:
        Julia Lawall reported this null pointer dereference, this should fix it.
        fs/orangefs: remove ORANGEFS_CACHE_CREATE_FLAGS
      bf3a69c6
    • Linus Torvalds's avatar
      Merge tag 'f2fs-for-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs · c5d9ab85
      Linus Torvalds authored
      Pull f2fs update from Jaegeuk Kim:
       "In this round, there are a number of updates on mainly two areas:
        Zoned block device support and Per-file compression. For example,
        we've found several issues to support Zoned block device especially
        having large sections regarding to GC and file pinning used for
        Android devices. In compression side, we've fixed many corner race
        conditions that had broken the design assumption.
      
        Enhancements:
         - Support file pinning for Zoned block device having large section
         - Enhance the data recovery after sudden power cut on Zoned block
           device
         - Add more error injection cases to easily detect the kernel panics
         - add a proc entry show the entire disk layout
         - Improve various error paths paniced by BUG_ON in block allocation
           and GC
         - support SEEK_DATA and SEEK_HOLE for compression files
      
        Bug fixes:
         - avoid use-after-free issue in f2fs_filemap_fault
         - fix some race conditions to break the atomic write design
           assumption
         - fix to truncate meta inode pages forcely
         - resolve various per-file compression issues wrt the space
           management and compression policies
         - fix some swap-related bugs
      
        In addition, we removed deprecated codes such as io_bits and
        heap_allocation, and also fixed minor error handling routines with
        neat debugging messages"
      
      * tag 'f2fs-for-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (60 commits)
        f2fs: fix to avoid use-after-free issue in f2fs_filemap_fault
        f2fs: truncate page cache before clearing flags when aborting atomic write
        f2fs: mark inode dirty for FI_ATOMIC_COMMITTED flag
        f2fs: prevent atomic write on pinned file
        f2fs: fix to handle error paths of {new,change}_curseg()
        f2fs: unify the error handling of f2fs_is_valid_blkaddr
        f2fs: zone: fix to remove pow2 check condition for zoned block device
        f2fs: fix to truncate meta inode pages forcely
        f2fs: compress: fix reserve_cblocks counting error when out of space
        f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks
        f2fs: add a proc entry show disk layout
        f2fs: introduce SEGS_TO_BLKS/BLKS_TO_SEGS for cleanup
        f2fs: fix to check return value of f2fs_gc_range
        f2fs: fix to check return value __allocate_new_segment
        f2fs: fix to do sanity check in update_sit_entry
        f2fs: fix to reset fields for unloaded curseg
        f2fs: clean up new_curseg()
        f2fs: relocate f2fs_precache_extents() in f2fs_swap_activate()
        f2fs: fix blkofs_end correctly in f2fs_migrate_blocks()
        f2fs: ro: don't start discard thread for readonly image
        ...
      c5d9ab85
    • Linus Torvalds's avatar
      Merge tag 'ovl-fixes-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs · 0d7ca657
      Linus Torvalds authored
      Pull overlayfs fixes from Amir Goldstein:
       "Only minor fixes:
      
         - Fix uncalled for WARN_ON from v6.8-rc1
      
         - Fix the overlayfs MAINTAINERS entry"
      
      * tag 'ovl-fixes-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs:
        ovl: relax WARN_ON in ovl_verify_area()
        MAINTAINERS: update overlayfs git tree
      0d7ca657
    • Linus Torvalds's avatar
      Merge tag 'vfs-6.9-rc1.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs · 0a7b0ace
      Linus Torvalds authored
      Pull vfs fixes from Christian Brauner:
       "This contains a few small fixes for this merge window:
      
         - Undo the hiding of silly-rename files in afs. If they're hidden
           they can't be deleted by rm manually anymore causing regressions
      
         - Avoid caching the preferred address for an afs server to avoid
           accidently overriding an explicitly specified preferred server
           address
      
         - Fix bad stat() and rmdir() interaction in afs
      
         - Take a passive reference on the superblock when opening a block
           device so the holder is available to concurrent callers from the
           block layer
      
         - Clear private data pointer in fscache_begin_operation() to avoid it
           being falsely treated as valid"
      
      * tag 'vfs-6.9-rc1.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
        fscache: Fix error handling in fscache_begin_operation()
        fs,block: get holder during claim
        afs: Fix occasional rmdir-then-VNOVNODE with generic/011
        afs: Don't cache preferred address
        afs: Revert "afs: Hide silly-rename files from userspace"
      0a7b0ace
    • Linus Torvalds's avatar
      Merge tag 'irq-urgent-2024-03-17' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 4ae3dc83
      Linus Torvalds authored
      Pull irq fix from Ingo Molnar:
       "A RISC-V irqchip driver fix"
      
      * tag 'irq-urgent-2024-03-17' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        irqchip/riscv-intc: Fix use of AIA interrupts 32-63 on riscv32
      4ae3dc83
    • Linus Torvalds's avatar
      Merge tag 'sound-fix-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 5574aaa3
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "Two regression fixes that had been introduced in this merge window,
        additional HD-audio quirks, and a further enhancement for the new
        kunit"
      
      * tag 'sound-fix-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ALSA: core: add kunitconfig
        ALSA: hda/realtek: add in quirk for Acer Swift Go 16 - SFG16-71
        Revert "ALSA: usb-audio: Name feature ctl using output if input is PCM"
        ALSA: timer: Fix missing irq-disable at closing
        ALSA: hda/realtek: Add quirk for Lenovo Yoga 9 14IMH9
      5574aaa3
    • Steven Rostedt (Google)'s avatar
      tracing: Add __string_src() helper to help compilers not to get confused · 7604256c
      Steven Rostedt (Google) authored
      The __string() helper macro of the TRACE_EVENT() macro is used to
      determine how much of the ring buffer needs to be allocated to fit the
      given source string. Some trace events have a string that is dependent on
      another variable that could be NULL, and in those cases the string is
      passed in to be NULL.
      
      The __string() macro can handle being passed in a NULL pointer for which
      it will turn it into "(null)". It does that with:
      
        strlen((src) ? (const char *)(src) : "(null)") + 1
      
      But if src itself has the same conditional type it can confuse the
      compiler. That is:
      
        __string(r ? dev(r)->name : NULL)
      
      Would turn into:
      
       strlen((r ? dev(r)->name : NULL) ? (r ? dev(r)->name : NULL) : "(null)" + 1
      
      For which the compiler thinks that NULL is being passed to strlen() and
      gives this kind of warning:
      
      ./include/trace/stages/stage5_get_offsets.h:50:21: warning: argument 1 null where non-null expected [-Wnonnull]
         50 |                     strlen((src) ? (const char *)(src) : "(null)") + 1)
      
      Instead, create a static inline function that takes the src string and
      will return the string if it is not NULL and will return "(null)" if it
      is. This will then make the strlen() line:
      
       strlen(__string_src(src)) + 1
      
      Where the compiler can see that strlen() will not end up with NULL and
      does not warn about it.
      
      Note that this depends on commit 51270d57 ("tracing/net_sched: Fix
      tracepoints that save qdisc_dev() as a string") being applied, as passing
      the qdisc_dev() into __string_src() will give an error.
      
      Link: https://lore.kernel.org/all/ZfNmfCmgCs4Nc+EH@aschofie-mobl2/
      Link: https://lore.kernel.org/linux-trace-kernel/20240314232754.345cea82@rorschach.local.home
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Reported-by: default avatarAlison Schofield <alison.schofield@intel.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      7604256c
    • Steven Rostedt (Google)'s avatar
      tracing: Use strcmp() in __assign_str() WARN_ON() check · b1afefa6
      Steven Rostedt (Google) authored
      The WARN_ON() check in __assign_str() to catch where the source variable
      to the macro doesn't match the source variable to __string() gives an
      error in clang:
      
      >> include/trace/events/sunrpc.h:703:4: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
           670 |                         __assign_str(progname, "unknown");
      
      That's because the __assign_str() macro has:
      
         WARN_ON_ONCE((src) != __data_offsets.dst##_ptr_);
      
      Where "src" is a string literal. Clang warns when comparing a string
      literal directly as it is undefined to what the value of the literal is.
      
      Since this is still to make sure the same string that goes to __string()
      is the same as __assign_str(), for string literals do a test for that and
      then use strcmp() in those cases
      
      Note that this depends on commit 51270d57 ("tracing/net_sched: Fix
      tracepoints that save qdisc_dev() as a string") being applied, as this was
      what found that bug.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240312113002.00031668@gandalf.local.home
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/oe-kbuild-all/202402292111.KIdExylU-lkp@intel.com/
      Fixes: 433e1d88a3be ("tracing: Add warning if string in __assign_str() does not match __string()")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      b1afefa6
    • Steven Rostedt (Google)'s avatar
      tracepoints: Use WARN() and not WARN_ON() for warnings · 1b273124
      Steven Rostedt (Google) authored
      There are two WARN_ON*() warnings in tracepoint.h that deal with RCU
      usage. But when they trigger, especially from using a TRACE_EVENT()
      macro, the information is not very helpful and is confusing:
      
       ------------[ cut here ]------------
       WARNING: CPU: 0 PID: 0 at include/trace/events/lock.h:24 lock_acquire+0x2b2/0x2d0
      
      Where the above warning takes you to:
      
       TRACE_EVENT(lock_acquire,  <<<--- line 24 in lock.h
      
      	TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
      		int trylock, int read, int check,
      		struct lockdep_map *next_lock, unsigned long ip),
      	[..]
      
      Change the WARN_ON_ONCE() to WARN_ONCE() and add a string that allows
      someone to search for exactly where the bug happened.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240228133112.0d64fb1b@gandalf.local.home
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Reported-by: default avatarBorislav Petkov <bp@alien8.de>
      Tested-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Reviewed-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      1b273124
    • Thorsten Blum's avatar
      tracing: Use div64_u64() instead of do_div() · d6cb38e1
      Thorsten Blum authored
      Fixes Coccinelle/coccicheck warnings reported by do_div.cocci.
      
      Compared to do_div(), div64_u64() does not implicitly cast the divisor and
      does not unnecessarily calculate the remainder.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240225164507.232942-2-thorsten.blum@toblux.com
      
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarThorsten Blum <thorsten.blum@toblux.com>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      d6cb38e1
    • Huang Yiwei's avatar
      tracing: Support to dump instance traces by ftrace_dump_on_oops · 19f0423f
      Huang Yiwei authored
      Currently ftrace only dumps the global trace buffer on an OOPs. For
      debugging a production usecase, instance trace will be helpful to
      check specific problems since global trace buffer may be used for
      other purposes.
      
      This patch extend the ftrace_dump_on_oops parameter to dump a specific
      or multiple trace instances:
      
        - ftrace_dump_on_oops=0: as before -- don't dump
        - ftrace_dump_on_oops[=1]: as before -- dump the global trace buffer
        on all CPUs
        - ftrace_dump_on_oops=2 or =orig_cpu: as before -- dump the global
        trace buffer on CPU that triggered the oops
        - ftrace_dump_on_oops=<instance_name>: new behavior -- dump the
        tracing instance matching <instance_name>
        - ftrace_dump_on_oops[=2/orig_cpu],<instance1_name>[=2/orig_cpu],
        <instrance2_name>[=2/orig_cpu]: new behavior -- dump the global trace
        buffer and multiple instance buffer on all CPUs, or only dump on CPU
        that triggered the oops if =2 or =orig_cpu is given
      
      Also, the sysctl node can handle the input accordingly.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240223083126.1817731-1-quic_hyiwei@quicinc.com
      
      Cc: Ross Zwisler <zwisler@google.com>
      Cc: <mhiramat@kernel.org>
      Cc: <mark.rutland@arm.com>
      Cc: <mcgrof@kernel.org>
      Cc: <keescook@chromium.org>
      Cc: <j.granados@samsung.com>
      Cc: <mathieu.desnoyers@efficios.com>
      Cc: <corbet@lwn.net>
      Signed-off-by: default avatarHuang Yiwei <quic_hyiwei@quicinc.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      19f0423f
    • Steven Rostedt (Google)'s avatar
      tracing: Remove second parameter to __assign_rel_str() · 0bdfb68c
      Steven Rostedt (Google) authored
      The second parameter of __assign_rel_str() is no longer used. It can be removed.
      
      Note, the only real users of rel_string is user events. This code is just
      in the sample code for testing purposes.
      
      This makes __assign_rel_str() different than __assign_str() but that's
      fine. __assign_str() is used over 700 places and has a larger impact. That
      change will come later.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240223162519.2beb8112@gandalf.local.home
      
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Reviewed-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      0bdfb68c
    • Steven Rostedt (Google)'s avatar
      tracing: Add warning if string in __assign_str() does not match __string() · cf986e57
      Steven Rostedt (Google) authored
      In preparation to remove the second parameter of __assign_str(), make sure
      it is really a duplicate of __string() by adding a WARN_ON_ONCE().
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240223161356.63b72403@gandalf.local.home
      
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Reviewed-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      cf986e57
    • Steven Rostedt (Google)'s avatar
      tracing: Add __string_len() example · dd6ae6d9
      Steven Rostedt (Google) authored
      There's no example code that uses __string_len(), and since the sample
      code is used for testing the event logic, add a use case.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240223152827.5f9f78e2@gandalf.local.home
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      dd6ae6d9
    • Steven Rostedt (Google)'s avatar
      tracing: Remove __assign_str_len() · c759e609
      Steven Rostedt (Google) authored
      Now that __assign_str() gets the length from the __string() (and
      __string_len()) macros, there's no reason to have a separate
      __assign_str_len() macro as __assign_str() can get the length of the
      string needed.
      
      Also remove __assign_rel_str() although it had no users anyway.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240223152206.0b650659@gandalf.local.home
      
      Cc: Jeff Layton <jlayton@kernel.org>
      Acked-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      c759e609
    • Randy Dunlap's avatar
      ftrace: Fix most kernel-doc warnings · d1530413
      Randy Dunlap authored
      Reduce the number of kernel-doc warnings from 52 down to 10, i.e.,
      fix 42 kernel-doc warnings by (a) using the Returns: format for
      function return values or (b) using "@var:" instead of "@var -"
      for function parameter descriptions.
      
      Fix one return values list so that it is formatted correctly when
      rendered for output.
      
      Spell "non-zero" with a hyphen in several places.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240223054833.15471-1-rdunlap@infradead.org
      
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Link: https://lore.kernel.org/oe-kbuild-all/202312180518.X6fRyDSN-lkp@intel.com/Reported-by: default avatarkernel test robot <lkp@intel.com>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      d1530413
    • Steven Rostedt (Google)'s avatar
      tracing: Decrement the snapshot if the snapshot trigger fails to register · 2048fdc2
      Steven Rostedt (Google) authored
      Running the ftrace selftests caused the ring buffer mapping test to fail.
      Investigating, I found that the snapshot counter would be incremented
      every time a snapshot trigger was added, even if that snapshot trigger
      failed.
      
       # cd /sys/kernel/tracing
       # echo "snapshot" > events/sched/sched_process_fork/trigger
       # echo "snapshot" > events/sched/sched_process_fork/trigger
       -bash: echo: write error: File exists
      
      That second one that fails increments the snapshot counter but doesn't
      decrement it. It needs to be decremented when the snapshot fails.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240223013344.729055907@goodmis.org
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Vincent Donnefort <vdonnefort@google.com>
      Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      2048fdc2
    • Steven Rostedt (Google)'s avatar
      tracing: Fix snapshot counter going between two tracers that use it · cca990c7
      Steven Rostedt (Google) authored
      Running the ftrace selftests caused the ring buffer mapping test to fail.
      Investigating, I found that the snapshot counter would be incremented
      every time a tracer that uses the snapshot is enabled even if the snapshot
      was used by the previous tracer.
      
      That is:
      
       # cd /sys/kernel/tracing
       # echo wakeup_rt > current_tracer
       # echo wakeup_dl > current_tracer
       # echo nop > current_tracer
      
      would leave the snapshot counter at 1 and not zero. That's because the
      enabling of wakeup_dl would increment the counter again but the setting
      the tracer to nop would only decrement it once.
      
      Do not arm the snapshot for a tracer if the previous tracer already had it
      armed.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240223013344.570525723@goodmis.org
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Vincent Donnefort <vdonnefort@google.com>
      Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      cca990c7
    • Steven Rostedt (Google)'s avatar
      tracing: Use EVENT_NULL_STR macro instead of open coding "(null)" · 70a6ed55
      Steven Rostedt (Google) authored
      The TRACE_EVENT macros has some dependency if a __string() field is NULL,
      where it will save "(null)" as the string. This string is also used by
      __assign_str(). It's better to create a single macro instead of having
      something that will not be caught by the compiler if there is an
      unfortunate typo.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222211443.106216915@goodmis.org
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Chuck Lever <chuck.lever@oracle.com>
      Suggested-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      70a6ed55
    • Steven Rostedt (Google)'s avatar
      tracing: Use ? : shortcut in trace macros · 91684986
      Steven Rostedt (Google) authored
      Instead of having:
      
        #define __assign_str(dst, src)					\
      	memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ?		\
      		__data_offsets.dst##_ptr_ : "(null)",			\
      		__get_dynamic_array_len(dst))
      
      Use the ? : shortcut and compact it down to:
      
        #define __assign_str(dst, src)					\
      	memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? : "(null)",	\
      	       __get_dynamic_array_len(dst))
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222211442.949327725@goodmis.org
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Chuck Lever <chuck.lever@oracle.com>
      Suggested-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      91684986
    • Steven Rostedt (Google)'s avatar
      tracing: Do not calculate strlen() twice for __string() fields · e8b737bf
      Steven Rostedt (Google) authored
      The TRACE_EVENT() macro handles dynamic strings by having:
      
        TP_PROTO(struct some_struct *s),
        TP_ARGS(s),
        TP_STRUCT__entry(
              __string(my_string, s->string)
       ),
       TP_fast_assign(
              __assign_str(my_string, s->string);
       )
       TP_printk("%s", __get_str(my_string))
      
      There's even some code that may call a function helper to find the
      s->string value. The problem with the above is that the work to get the
      s->string is done twice. Once at the __string() and again in the
      __assign_str().
      
      The length of the string is calculated via a strlen(), not once, but
      twice. Once during the __string() macro and again in __assign_str(). But
      the length is actually already recorded in the data location and here's no
      reason to call strlen() again.
      
      Just use the saved length that was saved in the __string() code for the
      __assign_str() code.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222211442.793074999@goodmis.org
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Chuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      e8b737bf
    • Steven Rostedt (Google)'s avatar
      tracing: Rework __assign_str() and __string() to not duplicate getting the string · c1fa617c
      Steven Rostedt (Google) authored
      The TRACE_EVENT() macro handles dynamic strings by having:
      
        TP_PROTO(struct some_struct *s),
        TP_ARGS(s),
        TP_STRUCT__entry(
      	__string(my_string, s->string)
       ),
       TP_fast_assign(
      	__assign_str(my_string, s->string);
       )
       TP_printk("%s", __get_str(my_string))
      
      There's even some code that may call a function helper to find the
      s->string value. The problem with the above is that the work to get the
      s->string is done twice. Once at the __string() and again in the
      __assign_str().
      
      But the __string() uses dynamic_array() which has a helper structure that
      is created holding the offsets and length of the string fields. Instead of
      finding the string twice, just save it off in another field from that
      helper structure, and have __assign_str() use that instead.
      
      Note, this also means that the second parameter of __assign_str() isn't
      even used anymore, and may be removed in the future.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222211442.634192653@goodmis.org
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Chuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      c1fa617c
    • Alison Schofield's avatar
      cxl/trace: Properly initialize cxl_poison region name · 6c871260
      Alison Schofield authored
      The TP_STRUCT__entry that gets assigned the region name, or an
      empty string if no region is present, is erroneously initialized
      to the cxl_region pointer. It needs to be properly initialized
      otherwise it's length is wrong and garbage chars can appear in
      the kernel trace output: /sys/kernel/tracing/trace
      
      The bad initialization was due in part to a naming conflict with
      the parameter: struct cxl_region *region. The field 'region' is
      already exposed externally as the region name, so changing that
      to something logical, like 'region_name' is not an option. Instead
      rename the internal only struct cxl_region to the commonly used
      'cxlr'.
      
      Impact is that tooling depending on that trace data can miss
      picking up a valid event when searching by region name. The
      TP_printk() output, if enabled, does emit the correct region
      names in the dmesg log.
      
      This was found during testing of the cxl-list option to report
      media-errors for a region.
      
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
      Cc: Dave Jiang <dave.jiang@intel.com>
      Cc: Vishal Verma <vishal.l.verma@intel.com>
      Cc: stable@vger.kernel.org
      Fixes: ddf49d57 ("cxl/trace: Add TRACE support for CXL media-error records")
      Signed-off-by: default avatarAlison Schofield <alison.schofield@intel.com>
      Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
      Acked-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      6c871260
    • Steven Rostedt (Google)'s avatar
      net: hns3: tracing: fix hclgevf trace event strings · 3f9952e8
      Steven Rostedt (Google) authored
      The __string() and __assign_str() helper macros of the TRACE_EVENT() macro
      are going through some optimizations where only the source string of
      __string() will be used and the __assign_str() source will be ignored and
      later removed.
      
      To make sure that there's no issues, a new check is added between the
      __string() src argument and the __assign_str() src argument that does a
      strcmp() to make sure they are the same string.
      
      The hclgevf trace events have:
      
        __assign_str(devname, &hdev->nic.kinfo.netdev->name);
      
      Which triggers the warning:
      
      hclgevf_trace.h:34:39: error: passing argument 1 of ‘strcmp’ from incompatible pointer type [-Werror=incompatible-pointer-types]
         34 |                 __assign_str(devname, &hdev->nic.kinfo.netdev->name);
       [..]
      arch/x86/include/asm/string_64.h:75:24: note: expected ‘const char *’ but argument is of type ‘char (*)[16]’
         75 | int strcmp(const char *cs, const char *ct);
            |            ~~~~~~~~~~~~^~
      
      Because __assign_str() now has:
      
      	WARN_ON_ONCE(__builtin_constant_p(src) ?		\
      		     strcmp((src), __data_offsets.dst##_ptr_) :	\
      		     (src) != __data_offsets.dst##_ptr_);	\
      
      The problem is the '&' on hdev->nic.kinfo.netdev->name. That's because
      that name is:
      
      	char			name[IFNAMSIZ]
      
      Where passing an address '&' of a char array is not compatible with strcmp().
      
      The '&' is not necessary, remove it.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240313093454.3909afe7@gandalf.local.home
      
      Cc: netdev <netdev@vger.kernel.org>
      Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
      Cc: Salil Mehta <salil.mehta@huawei.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Yufeng Mo <moyufeng@huawei.com>
      Cc: Huazhong Tan <tanhuazhong@huawei.com>
      Cc: stable@vger.kernel.org
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarJijie Shao <shaojijie@huawei.com>
      Fixes: d8355240 ("net: hns3: add trace event support for PF/VF mailbox")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      3f9952e8
    • Steven Rostedt (Google)'s avatar
      drm/i915: Add missing ; to __assign_str() macros in tracepoint code · 0df4c388
      Steven Rostedt (Google) authored
      I'm working on improving the __assign_str() and __string() macros to be
      more efficient, and removed some unneeded semicolons. This triggered a bug
      in the build as some of the __assign_str() macros in intel_display_trace
      was missing a terminating semicolon.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222133057.2af72a19@gandalf.local.home
      
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@gmail.com>
      Cc: stable@vger.kernel.org
      Fixes: 2ceea5d8 ("drm/i915: Print plane name in fbc tracepoints")
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Acked-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      0df4c388
    • Steven Rostedt (Google)'s avatar
      NFSD: Fix nfsd_clid_class use of __string_len() macro · 9388a2aa
      Steven Rostedt (Google) authored
      I'm working on restructuring the __string* macros so that it doesn't need
      to recalculate the string twice. That is, it will save it off when
      processing __string() and the __assign_str() will not need to do the work
      again as it currently does.
      
      Currently __string_len(item, src, len) doesn't actually use "src", but my
      changes will require src to be correct as that is where the __assign_str()
      will get its value from.
      
      The event class nfsd_clid_class has:
      
        __string_len(name, name, clp->cl_name.len)
      
      But the second "name" does not exist and causes my changes to fail to
      build. That second parameter should be: clp->cl_name.data.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222122828.3d8d213c@gandalf.local.home
      
      Cc: Neil Brown <neilb@suse.de>
      Cc: Olga Kornievskaia <kolga@netapp.com>
      Cc: Dai Ngo <Dai.Ngo@oracle.com>
      Cc: Tom Talpey <tom@talpey.com>
      Cc: stable@vger.kernel.org
      Fixes: d27b74a8 ("NFSD: Use new __string_len C macros for nfsd_clid_class")
      Acked-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Acked-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      9388a2aa
    • John Garry's avatar
      tracing: Use init_utsname()->release · ed896837
      John Garry authored
      Instead of using UTS_RELEASE, use init_utsname()->release, which means that
      we don't need to rebuild the code just for the git head commit changing.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222124639.65629-1-john.g.garry@oracle.comSigned-off-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      ed896837
    • Beau Belgrave's avatar
      tracing/user_events: Document multi-format flag · 3727db1c
      Beau Belgrave authored
      User programs can now ask user_events to handle the synchronization of
      multiple different formats for an event with the same name via the new
      USER_EVENT_REG_MULTI_FORMAT flag.
      
      Add a section for USER_EVENT_REG_MULTI_FORMAT that explains the intended
      purpose and caveats of using it. Explain how deletion works in these
      cases and how to use /sys/kernel/tracing/dynamic_events for per-version
      deletion.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-5-beaub@linux.microsoft.comSigned-off-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      3727db1c
    • Beau Belgrave's avatar
      selftests/user_events: Test multi-format events · bcb7bdcc
      Beau Belgrave authored
      User_events now has multi-format events which allow for the same
      register name, but with different formats. When this occurs, different
      tracepoints are created with unique names.
      
      Add a new test that ensures the same name can be used for two different
      formats. Ensure they are isolated from each other and that name and arg
      matching still works if yet another register comes in with the same
      format as one of the two.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-4-beaub@linux.microsoft.comSigned-off-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      bcb7bdcc
    • Beau Belgrave's avatar
      tracing/user_events: Introduce multi-format events · 64805e40
      Beau Belgrave authored
      Currently user_events supports 1 event with the same name and must have
      the exact same format when referenced by multiple programs. This opens
      an opportunity for malicious or poorly thought through programs to
      create events that others use with different formats. Another scenario
      is user programs wishing to use the same event name but add more fields
      later when the software updates. Various versions of a program may be
      running side-by-side, which is prevented by the current single format
      requirement.
      
      Add a new register flag (USER_EVENT_REG_MULTI_FORMAT) which indicates
      the user program wishes to use the same user_event name, but may have
      several different formats of the event. When this flag is used, create
      the underlying tracepoint backing the user_event with a unique name
      per-version of the format. It's important that existing ABI users do
      not get this logic automatically, even if one of the multi format
      events matches the format. This ensures existing programs that create
      events and assume the tracepoint name will match exactly continue to
      work as expected. Add logic to only check multi-format events with
      other multi-format events and single-format events to only check
      single-format events during find.
      
      Change system name of the multi-format event tracepoint to ensure that
      multi-format events are isolated completely from single-format events.
      This prevents single-format names from conflicting with multi-format
      events if they end with the same suffix as the multi-format events.
      
      Add a register_name (reg_name) to the user_event struct which allows for
      split naming of events. We now have the name that was used to register
      within user_events as well as the unique name for the tracepoint. Upon
      registering events ensure matches based on first the reg_name, followed
      by the fields and format of the event. This allows for multiple events
      with the same registered name to have different formats. The underlying
      tracepoint will have a unique name in the format of {reg_name}.{unique_id}.
      
      For example, if both "test u32 value" and "test u64 value" are used with
      the USER_EVENT_REG_MULTI_FORMAT the system would have 2 unique
      tracepoints. The dynamic_events file would then show the following:
        u:test u64 count
        u:test u32 count
      
      The actual tracepoint names look like this:
        test.0
        test.1
      
      Both would be under the new user_events_multi system name to prevent the
      older ABI from being used to squat on multi-formatted events and block
      their use.
      
      Deleting events via "!u:test u64 count" would only delete the first
      tracepoint that matched that format. When the delete ABI is used all
      events with the same name will be attempted to be deleted. If
      per-version deletion is required, user programs should either not use
      persistent events or delete them via dynamic_events.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-3-beaub@linux.microsoft.comSigned-off-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      64805e40
    • Beau Belgrave's avatar
      tracing/user_events: Prepare find/delete for same name events · 1e953de9
      Beau Belgrave authored
      The current code for finding and deleting events assumes that there will
      never be cases when user_events are registered with the same name, but
      different formats. Scenarios exist where programs want to use the same
      name but have different formats. An example is multiple versions of a
      program running side-by-side using the same event name, but with updated
      formats in each version.
      
      This change does not yet allow for multi-format events. If user_events
      are registered with the same name but different arguments the programs
      see the same return values as before. This change simply makes it
      possible to easily accommodate for this.
      
      Update find_user_event() to take in argument parameters and register
      flags to accommodate future multi-format event scenarios. Have find
      validate argument matching and return error pointers to cover when
      an existing event has the same name but different format. Update
      callers to handle error pointer logic.
      
      Move delete_user_event() to use hash walking directly now that
      find_user_event() has changed. Delete all events found that match the
      register name, stop if an error occurs and report back to the user.
      
      Update user_fields_match() to cover list_empty() scenarios now that
      find_user_event() uses it directly. This makes the logic consistent
      across several callsites.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240222001807.1463-2-beaub@linux.microsoft.comSigned-off-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      1e953de9
    • Vincent Donnefort's avatar
      tracing: Add snapshot refcount · 180e4e39
      Vincent Donnefort authored
      When a ring-buffer is memory mapped by user-space, no trace or
      ring-buffer swap is possible. This means the snapshot feature is
      mutually exclusive with the memory mapping. Having a refcount on
      snapshot users will help to know if a mapping is possible or not.
      
      Instead of relying on the global trace_types_lock, a new spinlock is
      introduced to serialize accesses to trace_array->snapshot. This intends
      to allow access to that variable in a context where the mmap lock is
      already held.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240220202310.2489614-4-vdonnefort@google.comSigned-off-by: default avatarVincent Donnefort <vdonnefort@google.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      180e4e39
    • Steven Rostedt (Google)'s avatar
      ring-buffer: Make wake once of ring_buffer_wait() more robust · b70f2938
      Steven Rostedt (Google) authored
      The default behavior of ring_buffer_wait() when passed a NULL "cond"
      parameter is to exit the function the first time it is woken up. The
      current implementation uses a counter that starts at zero and when it is
      greater than one it exits the wait_event_interruptible().
      
      But this relies on the internal working of wait_event_interruptible() as
      that code basically has:
      
        if (cond)
          return;
        prepare_to_wait();
        if (!cond)
          schedule();
        finish_wait();
      
      That is, cond is called twice before it sleeps. The default cond of
      ring_buffer_wait() needs to account for that and wait for its counter to
      increment twice before exiting.
      
      Instead, use the seq/atomic_inc logic that is used by the tracing code
      that calls this function. Add an atomic_t seq to rb_irq_work and when cond
      is NULL, have the default callback take a descriptor as its data that
      holds the rbwork and the value of the seq when it started.
      
      The wakeups will now increment the rbwork->seq and the cond callback will
      simply check if that number is different, and no longer have to rely on
      the implementation of wait_event_interruptible().
      
      Link: https://lore.kernel.org/linux-trace-kernel/20240315063115.6cb5d205@gandalf.local.home
      
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Fixes: 7af9ded0 ("ring-buffer: Use wait_event_interruptible() in ring_buffer_wait()")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      b70f2938
    • David Howells's avatar
      fscache: Fix error handling in fscache_begin_operation() · 449ac551
      David Howells authored
      Fix fscache_begin_operation() to clear cres->cache_priv on error, otherwise
      fscache_resources_valid() will report it as being valid.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Link: https://lore.kernel.org/r/3933237.1710514106@warthog.procyon.org.ukReviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Reported-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      cc: Jeff Layton <jlayton@kernel.org>
      cc: netfs@lists.linux.dev
      cc: linux-fsdevel@vger.kernel.org
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      449ac551
    • Christian Brauner's avatar
      fs,block: get holder during claim · 59a55a63
      Christian Brauner authored
      Now that we open block devices as files we need to deal with the
      realities that closing is a deferred operation. An operation on the
      block device such as e.g., freeze, thaw, or removal that runs
      concurrently with umount, tries to acquire a stable reference on the
      holder. The holder might already be gone though. Make that reliable by
      grabbing a passive reference to the holder during bdev_open() and
      releasing it during bdev_release().
      
      Fixes: f3a60882 ("bdev: open block device as files") # mainline only
      Reported-by: default avatarChristoph Hellwig <hch@infradead.org>
      Link: https://lore.kernel.org/r/ZfEQQ9jZZVes0WCZ@infradead.orgReviewed-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarChristoph Hellwig <hch@infradead.org>
      Tested-by: default avatarYi Zhang <yi.zhang@redhat.com>
      Reported-by: https://lore.kernel.org/r/CAHj4cs8tbDwKRwfS1=DmooP73ysM__xAb2PQc6XsAmWR+VuYmg@mail.gmail.com
      Link: https://lore.kernel.org/r/20240315-freibad-annehmbar-ca68c375af91@braunerSigned-off-by: default avatarChristian Brauner <brauner@kernel.org>
      59a55a63