summaryrefslogtreecommitdiff
path: root/kernel
AgeCommit message (Collapse)Author
7 hourssched/wait: kill leftover bookmark logic in __wake_up_common()Oleg Nesterov
The manual list head check and list_for_each_entry_safe_from() in __wake_up_common() are leftovers from commit 2554db916586 ("sched/wait: Break up long wake list walk"). This logic was later removed by commit 37acade0ce89 ("sched: remove wait bookmarks") but the now-unnecessary list hacks were left behind. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
20 hoursMerge tag 'probes-fixes-v7.4-rc5' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace Pull probes fixes from Masami Hiramatsu: - Do not let KASAN check the $stackN read Use READ_ONCE_NOCHECK() in ftrace_regs_get_kernel_stack_nth() so reading $stackN entries that fall in another frame's redzone does not trigger KASAN stack-out-of-bounds splats under CONFIG_KASAN_STACK - Zero out faulted dereferenced fields Zero the destination in probe_mem_read() and probe_mem_read_user() on read failure and continue storing zero in process_fetch_insn_bottom() instead of leaving stale ring-buffer contents when a dereference faults * tag 'probes-fixes-v7.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing/probes: Zero out faulted dereferenced fields tracing/fprobe: Do not let KASAN check the $stackN read
28 hoursMerge tag 'sched_ext-for-7.4-rc4-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext Pull sched_ext fixes from Tejun Heo: - Scheduler enable and disable could race with tasks changing class: on enable, a task could switch to sched_ext before the scheduler core started picking sched_ext tasks and be left runnable while its CPU went idle. On disable, an RT task could starve the tasks falling back to the fair class and stall the disable itself. - BPF schedulers failed to load on architectures whose BPF JIT doesn't support private stacks, such as riscv64. Only sub-schedulers need them and are now refused there instead. - The debug dump and CPU ID layout callbacks could call kfuncs that move tasks around. They are now rejected at load time. - Smaller fixes: a task's first enqueue after fork didn't tell the BPF scheduler that CPU selection had already run, and two kfuncs raised a false RCU lockdep warning in BPF timer callbacks. * tag 'sched_ext-for-7.4-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext: sched_ext: Attach fair_server before tasks fall back to fair on disable selftests/sched_ext: Add unlocked_kfunc test sched_ext: Don't allow unlocked kfuncs from ops.dump() and ops.init_cids() sched_ext: Don't request private stacks the JIT can't provide sched_ext: Fix suspicious RCU usage in KF_RCU_PROTECTED kfuncs sched/core: Pass ENQUEUE_RQ_SELECTED on initial enqueue sched_ext: Don't route tasks to SCX before __scx_enabled is fully patched
28 hoursMerge tag 'cgroup-for-7.4-rc4-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup Pull cgroup fixes from Tejun Heo: - A BPF program could queue a cgroup stat update with preemption enabled, tripping a lockdep assertion - When nohz_full= included the boot CPU, the tick code took the CPU back out of the nohz_full set but the housekeeping cpumask still excluded it. The fix is in the CPU isolation code. It comes through cgroup with Frederic's review as further cpuset changes build on it * tag 'cgroup-for-7.4-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup/rstat: disable preemption in css_rstat_updated() tick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistent
29 hoursMerge tag 'wq-for-7.4-rc4-fixes' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq Pull workqueue fixes from Tejun Heo: - Draining a workqueue could return while a work item queued by another work item was still pending, making workqueue destruction warn and leak the workqueue - CPU bringup during boot repeated unbound workqueue setup that can't change that early, at a cost quadratic in the CPU count * tag 'wq-for-7.4-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: workqueue: Skip redundant unbound updates during CPU bringup workqueue: Fix drain_workqueue() missing work items chained across pwqs
33 hourstracing/probes: Zero out faulted dereferenced fieldsSteven Rostedt
While looking at tasks global descriptor tables, I discovered the following anomaly: ~# echo 't:sched sched_switch prev=prev mm=(task_struct)prev->mm ppgd=(task_struct)prev->mm->pgd' > /sys/kernel/tracing/dynamic_events The above creates a tprobe on the sched_switch tracepoint and records the previous task_struct pointer, it's mm_struct and the pgd the mm_struct points to. ~# trace-cmd start -e tracepoints:sched bash-1050 [000] d..3. 90.829478: sched: (__probestub_sched_switch+0x0/0x10) prev=0xffff88d30b623600 mm=0xffff88d30108c600 ppgd=0xffff88d33352b000 <idle>-0 [002] d..3. 90.836024: sched: (__probestub_sched_switch+0x0/0x10) prev=0xffff88d301870000 mm=0x0 ppgd=0x0 rcu_preempt-15 [002] d..3. 90.836031: sched: (__probestub_sched_switch+0x0/0x10) prev=0xffff88d3013ad100 mm=0x0 ppgd=0xffff88d33352b000 The first event has is a user task that has both a valid mm_struct and a pgd. The second event is a kernel task where the mm_struct is NULL and so is the dereferenced pgd pointer. The third event is where things looked strange. The mm_struct is NULL but the dereferenced pgd has a value! That is: NULL->pgd produced something other than zero. The reason for this is that the probe_mem_read() and probe_mem_read_user() do not write to the destination on failure. The process_fetch_insn_bottom() loop does not check the return value of the dereference (as it is the last one), and does not update the event. That leaves the value for that failed field to be whatever was in the ring buffer at that time. Have both probe_mem_read() and probe_mem_read_user() set the destination to zero on failure to read the address. Now all pgd are zero when mm is zero. Also update the stage 2 of process_fetch_insn_bottom() to not return on fault but to just set the value to zero and also do not even bother dereferencing the address if the value is already zero. This allows the code to continue and fill in the zero into the memory location on the ring buffer. Link: https://lore.kernel.org/all/20261124092447.4dbf5233@gandalf.local.home/ Cc: stable@vger.kernel.org Fixes: 533059281ee59 ("tracing: probeevent: Introduce new argument fetching code") Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
39 hourssched_ext: Attach fair_server before tasks fall back to fair on disableHang Zhengyang
In full mode, the enable path detaches fair_server, since no task runs in the fair class. scx_root_disable() attaches it again only at the end, in the dl_server_swap_bw() loop. But tasks fall back to fair well before that. New forks and sched_setscheduler() calls do so once scx_switching_all is cleared, and the switch loop moves all other tasks. Until the swap, fair_server can't start, so an RT task that keeps a CPU starves the fair tasks there. Meanwhile, the disable path waits for RCU grace periods in percpu_down_write() of scx_fork_rwsem and scx_cgroup_ops_rwsem. A grace period can wait for a starved task, so the disable doesn't finish until the RT task stops. The starved task can be a reader preempted under PREEMPT_RCU, or the grace-period kthread itself. While the disable waits in the scx_cgroup_lock() after the switch loop, scx_fork_rwsem and cgroup_mutex are held, so forks wait too. To reproduce, load scx_simple, pin SCHED_NORMAL tasks (/proc walkers, stress-ng --fork) and a SCHED_FIFO spinner to CPU 1, and unload the scheduler 50 ms after the spinner starts. The disable can then get stuck in: synchronize_rcu_normal+0x1da/0x1f0 rcu_sync_enter+0x56/0x140 scx_root_disable+0x230/0x420 kthread_worker_fn+0xf0/0x270 until the spinner stops. Attach fair_server before tasks start to fall back, the same way the enable path attaches ext_server before tasks switch to it. If the root domain can't fit both servers, the swap attaches fair_server as before. Fixes: e7b63427fdb4 ("sched_ext: Auto-register/unregister dl_server reservations") Cc: stable@vger.kernel.org # v7.2+ Signed-off-by: Hang Zhengyang <hang.zhengyang1010@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2 daysworkqueue: Skip redundant unbound updates during CPU bringupSaurabh Sengar
Before workqueue_init_topology(), all CPUs share the SYSTEM pod, which contains every possible CPU. The effective cpumask and the per-pod cpumask of an unbound workqueue are therefore identical, regardless of which CPUs are online. During this stage, workqueue_online_cpu() walks every possible CPU for every unbound workqueue each time a secondary CPU comes online. The pwq mappings cannot change yet, so this repeats redundant work that scales quadratically with CPU count. On a 640-vCPU Hyper-V VM, each of the 639 secondary CPU-online callbacks walks all 640 possible CPUs for each of the 8 unbound workqueues, giving 3,271,680 unbound_wq_update_pwq() calls that took about 975 ms in total. Skip these updates until workqueue_init_topology(). The pwq mappings already match the effective cpumask, and wq_update_node_max_active() does nothing before topology initialization. workqueue_init_topology() will apply the topology-specific mappings and node limits once ready. Keep worker rebinding and restoration of unbound worker affinity before the guard. CPU hotplug after topology initialization is unchanged. On the same VM running a v7.3 kernel, smp_init() took 1054 ms with this change, compared to 2008 ms without it, a 47.5% reduction. Before After Reduction smp_init() 2008 ms 1054 ms 47.5% Fixes: 84193c07105c ("workqueue: Generalize unbound CPU pods") Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2 daysworkqueue: Fix drain_workqueue() missing work items chained across pwqsTejun Heo
drain_workqueue() flushes the workqueue, then checks each pwq under its pool's lock and returns once a pass finds every pwq empty. Only chained queueing is allowed meanwhile, and a chained work item can land on a pwq other than the one the queueing work item is executing on. The pass misses it when: 1. The pass finds pwq A empty. 2. A work item executing on pwq B queues a work item on pwq A. 3. The work item on pwq B finishes. 4. The pass finds pwq B empty. drain_workqueue() returns with the work item on pwq A pending, and destroy_workqueue() can then trip WARN_ON(pwq_busy()) and leak the workqueue. Add pwq->nr_started, which counts the work items a pwq has started executing, and check the pwqs twice after each flush. The drain is complete only if both passes find every pwq empty and no work item started in between. The counter is updated and read under pool->lock, and the queueing path is not touched. Verified with reproducers of both shapes: self-requeueing work items on an unbound workqueue and chained queue_work_on() of another work item on a per-cpu workqueue. Fixes: c8efcc258946 ("workqueue: allow chained queueing during destruction") Cc: stable@vger.kernel.org # v2.6.38+ Link: https://lore.kernel.org/all/CAHk-=wjm3vbiNYsR+aHxmM3KCEgsSWb379ZQbCuZEsN1dhvbKg@mail.gmail.com/ Originally-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Tejun Heo <tj@kernel.org>
2 dayssched_ext: Don't allow unlocked kfuncs from ops.dump() and ops.init_cids()Kuba Piecuch
scx_kf_allow_flags[] grants SCX_KF_ALLOW_UNLOCKED to ops.dump(). This allows ops.dump() to call scx_bpf_dsq_move*(), scx_bpf_dsq_reenq_task(), and scx_bpf_select_cpu_*(). When no rq is locked, these kfuncs acquire rq, DSQ, and pi locks and may invoke nested SCX ops such as ops.dequeue(). scx_dump_state() runs ops.dump() with IRQs disabled under scx_dump_lock. Callers include the hardirq disable irq_work and SysRq-D. With SCX_KF_ALLOW_UNLOCKED, a debug dump can migrate tasks and run nested scheduler callbacks instead of only inspecting state. ops.dump_cpu() and ops.dump_task() already deny these kfuncs. Remove SCX_KF_ALLOW_UNLOCKED from ops.dump(). ops.init_cids() runs before the cid tables are published and before the arena pool and pshards are set up. Its only job is to finalize the cid layout. SCX_KF_ALLOW_UNLOCKED also gave it scx_bpf_create_dsq(), scx_bpf_dsq_move*(), and scx_bpf_dsq_reenq_task(). Restrict ops.init_cids() to SCX_KF_ALLOW_INIT_CIDS. No in-tree scheduler calls these kfuncs from either op. Fixes: 4c30f5ce4f7a ("sched_ext: Implement scx_bpf_dispatch[_vtime]_from_dsq()") Fixes: 874fdc0e86e4 ("sched_ext: Add ops.init_cids() to finalize the cid layout before init") Cc: stable@vger.kernel.org # v7.3+ Signed-off-by: Kuba Piecuch <jpiecuch@google.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2 dayssched_ext: Don't request private stacks the JIT can't provideCheng-Yang Chou
Since commit 4f8b122848db ("sched_ext: Add basic building blocks for nested sub-scheduler dispatching"), bpf_scx_check_member() requests a private stack for ops.dispatch(), and later also for ops.sub_caps_updated(), whenever CONFIG_EXT_SUB_SCHED is set, which is the default. The verifier fails the load with -EACCES if the JIT doesn't support private stacks, so on architectures whose JIT doesn't, like riscv64, no BPF scheduler that implements ops.dispatch() can be loaded. The private stack is only needed when these operations nest, which only happens with sub-schedulers. Don't request it if the JIT can't provide it, and refuse to attach sub-schedulers in that case. Root schedulers then load as they did before sub-scheduler support was added. Fixes: 4f8b122848db ("sched_ext: Add basic building blocks for nested sub-scheduler dispatching") Cc: stable@vger.kernel.org # v7.1+ Reported-by: JaeJoon Jung <rgbi3307@gmail.com> Link: https://lore.kernel.org/all/20260810031418.95364-1-rgbi3307@gmail.com/ Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com> Reviewed-by: Andrea Righi <arighi@nvidia.com> [tj: Wrapped the switch in an if block instead of returning early.] Signed-off-by: Tejun Heo <tj@kernel.org>
2 dayssched_ext: Fix suspicious RCU usage in KF_RCU_PROTECTED kfuncsKuba Piecuch
scx_bpf_dsq_peek() and scx_bpf_tid_to_task() call rcu_dereference() without taking rcu_read_lock() and rely on KF_RCU_PROTECTED instead. However, the verifier treats every non-sleepable program as being in an RCU read-side section, including bpf_timer callbacks. bpf_timer_cb() runs those from hrtimer softirq without rcu_read_lock(), so calling either kfunc from a bpf_timer callback triggers: WARNING: suspicious RCU usage kernel/sched/ext/ext.c:11170 suspicious rcu_dereference_check() usage! ... scx_bpf_dsq_peek+0x7d/0xd0 bpf_timer_cb+0xf9/0x130 The same happens from a sleepable program inside bpf_preempt_disable(). Both contexts are RCU readers, so this is a lockdep false positive, not a use-after-free. Every context accepted by KF_RCU_PROTECTED satisfies rcu_read_lock_any_held(). Use rcu_dereference_all() in both kfuncs, matching scx_prog_sched() and rhashtable_lookup(), and convert scx_bpf_cpu_curr() and scx_bpf_cid_curr() from guard(rcu)() + rcu_dereference() to rcu_dereference_all() as well to avoid redundant per-call RCU read-side lock/unlock overhead. This patch was written with the help of an AI coding assistant. Fixes: 44f5c8ec5b9a ("sched_ext: Add lockless peek operation for DSQs") Fixes: 41e3312861ea ("sched_ext: add p->scx.tid and SCX_OPS_TID_TO_TASK lookup") Signed-off-by: Kuba Piecuch <jpiecuch@google.com> Reviewed-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
3 dayscgroup/rstat: disable preemption in css_rstat_updated()Karl Mehltretter
BPF programs can call css_rstat_updated() with preemption enabled. The kfunc calls __css_rstat_updated(), which requires preemption to be disabled while it queues an rstat update. A cgroup iterator can hit the lockdep assertion on both RT and non-RT kernels. The cgroup_hierarchical_stats selftest can also hit it on PREEMPT_RT: spin_lock_irqsave() on trace_cgroup_path_lock leaves preemption and interrupts enabled there. Disable preemption in the BPF wrapper after validating the CPU and before calling __css_rstat_updated(). Fixes: 36df6e3dbd7e ("cgroup: make css_rstat_updated nmi safe") Reported-by: Jiayuan Chen <jiayuan.chen@linux.dev> Closes: https://lore.kernel.org/r/20251119111402.153727-1-jiayuan.chen@linux.dev/ Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Signed-off-by: Tejun Heo <tj@kernel.org>
3 daystick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistentWaiman Long
When the nohz_full boot parameter is first set, the cpu list parameter is passed directly to tick_nohz_full_setup() to set up tick_nohz_full_mask cpumask. Then the HK_TYPE_KERNEL_NOISE cpumask will be set up as the inverse of given cpu list parameter. Some of the timer code and RCU uses tick_nohz_full_mask directly while other timer code, scheduler and other subsystems use the HK_TYPE_KERNEL_NOISE cpumask. With CONFIG_PM_SLEEP_SMP && !CONFIG_PM_SLEEP_SMP_NONZERO_CPU config options, the boot CPU will be cleared from tick_nohz_full_mask if set while the corresponding HK_TYPE_KERNEL_NOISE cpumask isn't touched. The nohz_full entry in kernel-parameters.txt does state that the boot CPU will be forced outside the range to maintain the timekeeping. So it makes sense that the HK_TYPE_KERNEL_NOISE should be modified accordingly. Fix this inconsistency problem by adding a new cpumask_set_cpu() init function to be called by tick_nohz_init() when the boot CPU is cleared from tick_nohz_full_mask. In the special case that "nohz_full=0" and CPU 0 is cleared in tick_nohz_init(), tick_nohz_full_running will be set to false. However, housekeeping_enabled(HK_TYPE_KERNEL_NOISE) will stil be true with housekeeping_cpumask(HK_TYPE_KERNEL_NOISE) equal to cpu_possible_mask. So some unneeded code paths will be activated, but no harm will be done other than wasting some CPU cycles. Another problem that needs further thought but is not handled in this patch is when arch_irq_work_has_interrupt() turns out to be false. When this happens, tick_nohz_full_mask will be cleared and tick_nohz_full_running will be set back to false in tick_nohz_init(). PM_SLEEP_SMP_NONZERO_CPU depends on ARCH_SUSPEND_NONZERO_CPU which can only be set for the PowerPC architecture. Moreover CONFIG_PM_SLEEP_SMP is on by default, it means most kernels will not allow CPU 0 to be set in the tick_nohz_full_mask and hence should be set in HK_TYPE_KERNEL_NOISE cpumask. Fixes: 6f1982fedd59 ("sched/isolation: Handle the nohz_full= parameter") Signed-off-by: Waiman Long <longman@redhat.com> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Reviewed-by: Ridong Chen <ridong.chen@linux.dev> Acked-by: Guopeng Zhang <zhangguopeng@kylinos.cn> Tested-by: Guopeng Zhang <zhangguopeng@kylinos.cn> Signed-off-by: Tejun Heo <tj@kernel.org>
4 daysMerge tag 'sched-urgent-2026-11-22' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull scheduler fixes from Ingo Molnar: - Fix cfs_rq::idle handling (Peter Zijlstra) - Avoid transient double accounting for delayed tasks (K Prateek Nayak) - Lift cgroup update locking to core to fix sched-ext locking divergence (Michal Blaszczyk) * tag 'sched-urgent-2026-11-22' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched: Lift cgroup update locking to core to prevent CFS/SCX divergence sched/fair: Avoid transient double accounting for delayed tasks sched/fair: Make cfs_rq::idle the sum of ancestor tg::idle sched/fair: Use guard in sched_group_set_idle()
5 daysMerge tag 'sysctl-7.04-fixes-rc4' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl Pull sysctl fix from Joel Granados: "Fix sysctl jiffy / milliseconds conversion: - Writing a previously read value "X" shall keep the same "X" value - Remove truncation that was causing incorrect saturation of valid timeouts" * tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl: sysctl: Do jiffy / ms conversion in ulong space
5 daysMerge tag 'trace-v7.4-rc3' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace Pull tracing fixes from Steven Rostedt: - Do not WARN when trace_rb_cpu_prepare() fails to allocate on CPU startup The per CPU ring buffers are allocated when a new CPU comes online. If the system is under memory pressure it shouldn't trigger a WARN_ON if the buffer fails to allocate. Switch the WARN to a pr_warn() message. - Copy trace_marker to all instances even if one fails Each instance can set a flag that it wants what is written into the trace_marker file to be copied to its ring buffer. Currently, if one of the instances has tracing disabled, the copy will fail. The loop that copies to each ring buffer detects this failure and stops copying to the rest of the instances. This is not what is expected as the copy should be tried to all instances even if it fails on one. - Prevent perf from using filter logic to read kernel memory Perf can use filtering on addresses supplied by user space system calls to look at kernel address space and depending on the result of the filter determine what was in that address. Prevent perf from this type of filter. - Fix filter logic on zero length dynamic strings The string filter match expects the length passed to it to include the nul terminating byte. Dynamic strings may be zero in length and have no nul byte. Have the filter logic for this strings pass in an empty string ("") instead. - Fix boot filtering on common fields of events The common fields (like the CPU or PID of the event) are initialized after boot filtering is processed. This prevents boot filters from using them. Initialized the common fields before processing the boot filters. - Fix ref counting of synthetic events When an instance is removed, it calls clear_event_triggers() on its events. This function does not properly release the synthetic event ref counters keeping them "busy" indefinitely. Fix the function to properly release the reference of the synthetic events they contain. - Reject the size of zero for histograms Make it an error if the user tries to create a histogram of size zero. Not only does it not make sense, it is invalid to call to roundup_pow_of_two() as it is undefined. - Fix tail matching of filtering fixed size strings The filtering of the end of string (*end) does not work properly for fixed sized string fields. This is because it matches the end of the fixed size and not the string itself. That is, if a fixed string field of 16 bytes has "abcd" and the match is to be "cd" the compare is done to the last three bytes of the 16 (including '\0'), which will likely not be the "cd". - Fix the filter match of not-equal for out of range CPU masks. When a compare of a cpumask is out of range, the test returns nr_cpus and the match function will return zero (not matched) on that. But if the filter has a negative value (!=) then it should be a match. Fix this by returning "pred->op == OP_NE" which would return true if it should be a negative match and false otherwise. - Fix out-of-bounds read in unfinished filter match If the filter passed in is "ip ==" without a value after the conditional, the parsing logic will increment one passed the nul byte and read the memory after it, possibly reading out-of-bounds memory. Detect this case and return an error immediately. - Fix false success when failing on filtering of system groups A filter may be placed on a system group where the filter is then applied to each event. This returns success if at least one event succeeds. But the logic in the loop of all events reset the failure condition at the end of each iteration meaning that it would always return success even if no event was successful at applying it. The only way it would fail is if the first event failed on a memory issue. - Free created option descriptors on instance creation failure If an instance were to fail to be created after creating its options, it would then leak them. Clean them up on failure. - Allocate shadow stacks inline when enabling function graph hooks The current method of allocating the shadow stacks used by function graph (and which is now the backend of kretprobes), allocates 32 stacks, iterates over all tasks under an RCU lock and adds the stacks to the tasks that do not have them yet. After it has depleted and assigned all 32 stacks, it would break out of the loop, allocate another 32 stacks and repeat. Unfortunately, this meant that it would iterate all the tasks it had already assigned stacks to before assigning new stacks. For machines running 1000s of tasks, this would take an exponential time to complete. This logic was created when the loop of all tasks required more locking and allocating during the loop wasn't recommended. Instead, still allocate the 32 stacks outside the RCU atomic but only use them if the allocation of a stack with GFP_NOWAIT fails. This brings down the time to enable a kretprobe from over 200 seconds down to 0.92 seconds on a machine with 400,000 tasks. - Do not start kthread in timerlat user space mode Timerlat has a mode that you can assign a user space task to it. Normally the code would not start a kernel thread in this case, but if a CPU comes online, it does not check if its in user space mode and starts a kernel thread regardless. This triggers a WARN_ON on clean up as timerlat is not expecting to have a kernel thread running. Prevent kernel thread start up when a CPU comes on line while timerlat is in user space mode. - Do not free user events when an event probe is attached to it Event probes can attach to any other event. User events are events created that can be controlled by user space. Event probes can attach to these events, but they currently do not add a reference to them when they do. This means that the user event can be destroyed leaving the event probe attached to a stale event which can cause a use-after-free bug. On destruction of the user event, return -EBUSY if there's a dynamic event attached to it. Also make it persistent so that the event can be destroyed once the last fd is closed for it. - Synchronize the clearing of the copy marker flag The marker_copies link list contains all the instances that are to copy the trace_marker writes. When the flag is cleared, and the instance is removed from the list, wait an RCU synchronization, otherwise if the flag is set again, it can cause the same write to be written twice as the instance would be added to the end of the list and a current copy walk of the list would hit the same instance again. - Use copy_from_user() and not __copy_from_user() when reading user addresses When a system call event reads the user space address (like reading the path string of an openat system call), it users __copy_from_user() which assumes the address has been verified. Use the copy_from_user() function instead to verify that the address is OK for user space to read. Note, this has no security concern as this data read is only visible by the tracing system which in turn is only visible by admins. - Fix shadow stack marking of the function graph infrastructure An old implementation of the shadow stack set bit zero of the shadow stack frame to denote tail function calls. This is no longer the case and the setting of the bit can trigger a WARN_ON in some cases. - Do not do a reader-page swap when head is on tail The remote ring buffer does not handle swapping the buffer when the head is on the tail page. Prevent it from happening. - Fix race between reader and writer of remote ring buffer reader page When there's data in the buffer, the reader first checks the meta page counter and then reads the data on the page. But because the writer updates the content of the pages before updating the meta data, the reader receives NULL unexpectedly. Swap the checks around so that the reader still returns the data if there is some before checking the meta data. Also fix the data ordering of remote buffer page time accounting. - Fix wrong unit used in hwlat tracer accounting The tr->max_latency stores nanoseconds (even though its updated from user space in microseconds, but its converted over). The hwlat tracer assumes that the tr->max_latency is in microseconds and updates it accordingly. This causes the output to user space to be off by 1000. Do all calculations in the hwlat in nanoseconds. - Properly match filter strings that start with numbers The set_ftrace_fiter file can take numbers to set functions via an index into the file instead of having to search all tens of thousands of files for a match. This code is shared with the event filtering logic as well. But this caused some of the event filters to get confused by strings matching numbers and turning it into an index which did not apply to events. Have the function tracing handle indexes directly and remove that logic from the event filtering so that the indexing only affects the set_ftrace_filter file and nothing else. - Protect the ring_buffer ioctl from concurrent readers The ring_buffer ioctl call that maps the ring buffer can race with concurrent readers. Have it take the trace_access_lock(). - Prevent user events from defining a system name Currently, user events is the one dynamic event that does not allow the API from defining its own system (all user events go into the "user_events" system). But nothing prevents the user from trying to create one. As systems are denoted with '/' to separate the system from the event name, the API simply takes the entire string (the '/' and all) as the event name and tries to create a file with it. This causes the tracefs file system to be corrupted. Have the system call fail with -EINVAL if '/' is used. - Do not use si_mem_available() in early boot for ring_buffer allocation When allocating the ring buffer, the amount allocated is compared to the amount of memory available so that it doesn't allocate too much and cause a system failure. It uses si_mem_available() to get an approximate amount of memory it can allocate. On systems with CONFIG_DEFERRED_STRUCT_PAGE_INIT and on early boot up, the value returned by si_mem_available() is derived by NR_FREE_PAGES and can under report the amount of free memory. This makes it nearly impossible to allocate the ring buffer and do early boot tracing on these systems. For this case, use LONG_MAX as the maximum amount available. If it allocates too much and crashes the system, that's on the sysadmin that asked for too much memory for the ring buffer on the kernel command line. - Add notrace to event functions that use function hooks A few options in the event code hooks into the ftrace function hook mechanism. These functions must be marked with notrace. When CONFIG_FUNCTION_SELF_TRACING is enabled, event functions can be traced by ftrace and because these functions are not marked as notrace when they are traced, it causes an infinite loop and the system triple faults. Normally this wasn't a problem because without the SELF_TRACING set, all files in the tracing directory are marked as notrace. Mark the individual functions that are used in the event code with ftrace as notrace so that the rest of the code can still be traced by ftrace. - Ignore .function field modifier if the event is already a function event Perf can hook to the ftrace function event which is special and is marked as a "function" event where its fields can be filtered against function names. If the perf uses adds a filter to the ftrace event and adds the ".function" modifier (which converts the field to a function field to be searched with function names), the double conversion confuses the logic as the code for the ".function" does not work with function events (only normal events with unsigned long fields). This can end up with a NULL pointer dereference. If the ".function" modifier is used on a function event, simply ignore it, as the processing will work the same. * tag 'trace-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: (32 commits) tracing: Ignore .function on the function trace event tracing: Add notrace to event functions that hook to ftrace ring-buffer: Do not check si_mem_available() before deferred init completes tracing: Do not allow user events to add a system name tracing: Take trace_access_lock() in tracing_buffers_ioctl() tracing: Add tests for globbing number-based strings tracing: Properly match strings that start with numbers tracing/hwlat: Do the latency calculations in nanoseconds ring-buffer: Increment pages_read on remote ring buffer page swap ring-buffer: Order remote page commit with data and timestamp ring-buffer: Check remote reader page commit before meta entries ring-buffer: Skip remote reader page swap when on tail fgraph: Do not mark index 0 in every shadow stack frame tracing: Validate user addresses in faultable buffer copies tracing: Wait for marker writers when copy_trace_marker is cleared tracing/user_events: Don't free an event that a dynamic event still references tracing/osnoise: Don't start a kthread in timerlat user-space mode fgraph: Read the task->ret_stack with a smp_load_acquire() fgraph: Use scoped_guard() for the task list walk fgraph: Allocate shadow stacks inline with GFP_NOWAIT ...
5 dayssched/core: Pass ENQUEUE_RQ_SELECTED on initial enqueueTao Cui
select_task_rq() sets WF_RQ_SELECTED and ttwu_do_activate() maps it to ENQUEUE_RQ_SELECTED so enqueue_task_scx() knows whether ops.select_cpu() ran. wake_up_new_task() also calls select_task_rq() but activates the new task without the flag, so on the fork path ops.enqueue() never sees SCX_ENQ_CPU_SELECTED and SCX_EV_SELECT_CPU_FALLBACK never counts a fork-path fallback: a misbehaving select_cpu() leaves no trace in the counters, and schedulers testing SCX_ENQ_CPU_SELECTED run a redundant select_cpu_dfl() on tasks select_cpu() already placed. Set ENQUEUE_RQ_SELECTED on the initial enqueue when select_task_rq() was called, matching the wakeup path. Only sched_ext consumes the flag. Fixes: 9b671793c7d9 ("sched_ext, scx_qmap: Add and use SCX_ENQ_CPU_SELECTED") Cc: stable@vger.kernel.org # v6.12+ Signed-off-by: Tao Cui <cuitao@kylinos.cn> Signed-off-by: Tejun Heo <tj@kernel.org>
6 daysMerge tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpfLinus Torvalds
Pull bpf fixes from Alexei Starovoitov: "Mostly sockmap fixes as promised, plus uprobe ctx rewrite via bpf and cgroup-bpf fixes. - Reject writable map iterators on read-only maps (Adethya Srinivasan) - Various sockmap fixes (Alexei Starovoitov): - Clear the redirect target before the sk_msg prog runs - Check that the redirected message is the cork - Leave sk_stream_wait_memory() once the socket is dead - Keep the rest of the cork after a redirect - Don't let an SK_PASS verdict cover the next message - Subtract all dropped bytes from the return value of sendmsg() - Clear the end mark of elements added by bpf_msg_push_data() and bpf_msg_pop_data() - Fix ring capacity invariant break in bpf_msg_push_data() (Bo Cao) - Report RCU-tasks quiescent states in do_check() to fix rcu_tasks stalls during a long verification (Breno Leitao) - Various sockmap fixes (Chris Mason): - Give no progs to a TCP listener - Check the target of an egress redirect before each send - Check the TCP state in recvmsg() - Reset the copy position when corking - Don't copy 0 bytes into a full cork - Use a dedicated workqueue for freeing BPF programs to fix a deadlock between pack_mutex waiters and the vmalloc purge work (Emil Tsalapatis) - Fix verifier model mismatch on a narrow read of __sk_buff.remote_port (Henry Martin) - Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate selftest (Jiayuan Chen) - Restrict uprobe ctx writes to the registers that ptrace can set (Jiri Olsa) - Various sockmap fixes (Josef Bacik): - Write sg.start when recvmsg() faults - Don't let an SK_DROP verdict stick - Clear the resume state of a stopped psock - Various fixes (Michal Luczaj): - Fix "unresolved symbol tcp_request_sock" build error with CONFIG_INET=n - Restrict iter-context sockmap updates to iter/sockmap - Restrict bpf_sock_destroy() to iter/{tcp,udp} - Mark bpf_iter__sockmap::sk as PTR_TRUSTED - Mark backing_file_alloc/free LSM hooks as untrusted (Sergei Nizovtsev) - Various cgroup-bpf fixes (Shakeel Butt): - Don't read freed effective arrays in BPF_PROG_QUERY - Don't attach to a removed cgroup - Protect cgroup_bpf state with its own mutex, so that queries and the release work don't wait for cgroup_mutex - Don't lose errors in effective BPF_LSM_CGROUP queries - Check variable-offset accesses against special fields (Shihuang Liu)" * tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: (38 commits) selftests/bpf: Test which ctx registers a uprobe prog can write bpf: Restrict uprobe ctx writes to the registers ptrace can set selftests/bpf: Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate bpf, cgroup: Don't lose errors in effective BPF_LSM_CGROUP queries bpf, cgroup: Protect cgroup_bpf state with its own mutex bpf, cgroup: Don't attach to a removed cgroup bpf, cgroup: Don't read freed effective arrays in BPF_PROG_QUERY bpf: Fix verifier model mismatch on __sk_buff.remote_port narrow read bpf: Fix "unresolved symbol tcp_request_sock" build error selftests/bpf: Add iter/sockmap bpf_sock_destroy() negative test bpf: Mark bpf_iter__sockmap::sk as PTR_TRUSTED bpf: Restrict bpf_sock_destroy() to iter/{tcp,udp} bpf, docs: Document BPF_ITER_NOSLEEP selftests/bpf: Add negative test for sockmap update from non-sockmap iter bpf, sockmap: Restrict iter-context sockmap updates to iter/sockmap selftests/bpf: Remove sockmap update from bpf_iter_unix bpf, lsm: Mark backing_file_alloc/free LSM hooks as untrusted bpf: Report RCU-tasks quiescent states in do_check() bpf: Check variable-offset accesses against special fields bpf: Use dedicated workqueue for freeing BPF programs ...
6 daystracing: Ignore .function on the function trace eventDavid Carlier
For the function event, parse_pred() handles the .function suffix before the ftrace_event_is_function() case, so "ip.function == schedule" builds a predicate with no regex. Setting it through perf then dereferences the NULL pred->regex in ftrace_function_set_filter_pred(). The "ip" field of that event already takes a function name, so ignore the suffix there and let the function event case handle it. Cc: stable@vger.kernel.org Fixes: cfb58e278c6a ("tracing/filters: Dynamically allocate filter_pred.regex") Link: https://patch.msgid.link/20261119080139.131834-1-devnexen@gmail.com Suggested-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: David Carlier <devnexen@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Add notrace to event functions that hook to ftraceSteven Rostedt
A few functions in trace_events.c are used to hook to the ftrace function hooks. Before CONFIG_FUNCTION_SELF_TRACING was added, these functions were not marked for tracing because the entire directory was set to "notrace". But now that certain files can be traced by ftrace when the CONFIG_FUNCTION_SELF_TRACING config is set, individual functions that use ftrace must be annotated with "notrace" otherwise they can trigger a triple fault when called. Annotate the trace_events.c functions that are attached to ftrace with "notrace. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261119124319.3a8bfe50@gandalf.local.home Fixes: f93a7d0caccd6 ("ftrace: Allow tracing of some of the tracing code") Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysring-buffer: Do not check si_mem_available() before deferred init completesAmit Machhiwal
With CONFIG_DEFERRED_STRUCT_PAGE_INIT=y, only about one memory section per node is initialized early in boot (16 MiB on powerpc). The rest is initialized on demand by deferred_grow_zone() when an allocation would otherwise fail, or later by page_alloc_init_late(). Until then NR_FREE_PAGES can be close to zero, because early allocations (SLUB, vmalloc, ftrace records) use up the first section. si_mem_available() is derived from NR_FREE_PAGES, so it under-reports. __rb_allocate_pages() returns -ENOMEM when si_mem_available() is below the requested size. This check wrongly fails the buffers allocated for the boot CPU in early_trace_init() and for secondary CPUs in smp_init(), both of which run before page_alloc_init_late(). The resulting boot log shows: ERROR: Failed to allocate trace buffer ERROR: tracer: failed to allocate ring buffer! Skip the check until SYSTEM_FREEING_INITMEM on CONFIG_DEFERRED_STRUCT_PAGE_INIT kernels. The allocation itself still fails if memory really is short. This is the second half of the fix for the early boot crash reported on ppc64le KVM guests. Commit b3b974008388 ("tracing: Do not initialize tracefs work if tracing is disabled") stopped the NULL pointer dereference in __find_event_file() that followed the failed allocation. This patch fixes the allocation failure itself. Cc: stable@vger.kernel.org Fixes: 2a872fa4e9c8 ("ring-buffer: Check if memory is available before allocation") Link: https://patch.msgid.link/20261118183235.63310-1-amachhiw@linux.ibm.com Reported-by: Michal Suchánek <msuchanek@suse.de> Closes: https://lore.kernel.org/all/arYskzbiaNzBR9MD@kunlun.suse.cz/ Reviewed-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Do not allow user events to add a system nameSteven Rostedt
User events currently do not support the addition of a system name, but the parsing does not check to see if one is specified. A kprobe can add its own system name with the following command: ~# echo 'p:mysystem/kprobe_event schedule a=%ax' >> dynamic_events ~# ls events/mysystem enable filter kprobe_event But if one tries to do the same with user events: ~# echo 'u:user_events/test u32 a' >> dynamic_events ~# ls events/user_events ls: reading directory 'events/user_events/': Invalid argument enable filter It corrupts the file system as the event added had a '/' in the name. Until user events support specifying system names, just return -EINVAL to prevent the corrupted file system from happening: ~# echo 'u:user_events/test u32 a' >> dynamic_events -bash: echo: write error: Invalid argument Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261118122520.4a689710@gandalf.local.home Acked-by: Beau Belgrave <beaub@linux.microsoft.com> Fixes: 7f5a08c79df35 ("user_events: Add minimal support for trace_event into ftrace") Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Take trace_access_lock() in tracing_buffers_ioctl()Vincent Donnefort
tracing_buffers_ioctl() calls ring_buffer_map_get_reader() without trace_access_lock, breaking concurrent readers. Take trace_access_lock() around ring_buffer_map_get_reader(), matching the other consuming readers. Cc: stable@vger.kernel.org Fixes: cf9f0f7c4c5b ("tracing: Allow user-space mapping of the ring-buffer") Reported-by: Kyuwon Cho <kyuwoncho18@gmail.com> Closes: https://lore.kernel.org/all/179485165154.2547186.6129837870360499372@gmail.com/ Link: https://patch.msgid.link/20261117082932.3441173-1-vdonnefort@google.com Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Add tests for globbing number-based stringsBrian Norris
In "tracing: Properly match strings that start with numbers", we fixed bugs related to string fields that start with a number and also use globs instead of full matches. Add some additional startup test cases for this. For easy reproducible testing, I abused the kunit.py script to boot a minimal kernel with FTRACE_STARTUP_TEST enabled: ./tools/testing/kunit/kunit.py run --arch=x86_64 \ --kconfig_add=CONFIG_FTRACE=y \ --kconfig_add=CONFIG_FUNCTION_TRACER=y \ --kconfig_add=CONFIG_DYNAMIC_FTRACE=y \ --kconfig_add=CONFIG_FTRACE_STARTUP_TEST=y \ --kconfig_add=CONFIG_EVENT_TRACE_STARTUP_TEST=n \ --raw_output=all deadbeef Relevant line: Testing ftrace filter: OK Without "tracing: Properly match strings that start with numbers", the test fails with: Testing ftrace filter: Failed to match filter 'str ~ "0001:*"', expected 1 Link: https://patch.msgid.link/20261116182710.2.Ic117871c2b1e94c5a2176903a5c3316a10584e61@changeid Signed-off-by: Brian Norris <briannorris@chromium.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Properly match strings that start with numbersBrian Norris
As an optimization, set_ftrace_filter supports writing indices (numbers) instead of function names. This support was added to the generic glob (fake regex) function, which breaks the ability to filter string patterns that start with a number. For example, PCI device names tend to look like '0001:01:00.0', and a reasonable filter might be: echo 'name ~ "0001:*"' > /sys/kernel/tracing/events/rpm/rpm_resume/filter Move the MATCH_INDEX code out to the only place it actually was intended to work -- ftrace match_records(), with a 'func' and no 'mod'. As a side effect, this also fixes :mod:<module> function filtering for modules whose names start with a digit. Link: https://patch.msgid.link/20261116182710.1.Ic0625a2bd2e6f8960c0f75e5d15f14f3c84d1d38@changeid Fixes: f79b3f338564 ("ftrace: Allow enabling of filters via index of available_filter_functions") Signed-off-by: Brian Norris <briannorris@chromium.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing/hwlat: Do the latency calculations in nanosecondsWenwu Hou
tr->max_latency is expected to hold nanoseconds: tracing_max_lat_read() converts it with nsecs_to_usecs() to print the usecs documented in hwlat_detector.rst, and the other latency tracers store nanoseconds there too. Do all the latency calculations in nanoseconds instead, and only convert the durations to microseconds when recording the hwlat event. This also makes the backward-clock error paths reachable. Previously, time_to_us() passed the delta through unsigned div_u64(), so a negative delta became a positive value after division. These error paths jumped to out without clearing trace_hwlat_callback_enabled. Fix this as well. Link: https://patch.msgid.link/20261116032156.3138060-1-hwenwur@gmail.com Fixes: e7c15cd8a1133 ("tracing: Added hardware latency tracer") Fixes: 7b2c86250122d ("tracing: Add NMI tracing in hwlat detector") Suggested-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Wenwu Hou <hwenwur@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysring-buffer: Increment pages_read on remote ring buffer page swapVincent Donnefort
__rb_get_reader_page_from_remote() swaps in a new reader page without incrementing cpu_buffer->pages_read. While this isn't an issue now as trace remotes do not use buffer_percent, add this missing increment for consistency. Link: https://patch.msgid.link/20261113152729.837429-5-vdonnefort@google.com Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysring-buffer: Order remote page commit with data and timestampVincent Donnefort
__rb_get_reader_page_from_remote() uses page::commit to check if more data is available for consumption. However, it needs to make sure that data and page::time_stamp are not stale. Enforce page::commit order with page::data and page::time_stamp, and defer updating read_stamp on page swap until rb_page_size() confirms committed data is present. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261113152729.837429-4-vdonnefort@google.com Fixes: 2e67fabd8b77 ("ring-buffer: Introduce ring-buffer remotes") Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer") Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysring-buffer: Check remote reader page commit before meta entriesVincent Donnefort
__rb_get_reader_page_from_remote() bails out when rb_num_of_entries() is zero before verifying if there is more data committed on the current reader_page (rb_page_size()), while simple_ring_buffer updates page::commit before meta::entries. As a consequence, a race between the writer and reader could lead to __rb_get_reader_page_from_remote() returning NULL, while more data is available for reading on the ring buffer. CPU0 (writer) CPU1 (reader) ------------- ------------- local_set(&page->commit, write); __rb_get_reader_page_from_remote() !rb_read_remote_meta_page() return NULL; simple_rb_meta_inc(meta->entries, 1); This is an issue for rb_advance_reader() which always expects rb_get_reader_page() to return a page. Fix this issue by swapping the checks in __rb_get_reader_page_from_remote(): first it verifies if there is more to read in the current reader page, then it verifies if there's anything at all in the ring buffer. Also, if the reader observes the meta::entries update before page::commit while the writer moves tail_page, it could swap reader_page out and drop unread events. Order page::commit before meta::entries on the writer and rb_read_remote_meta_page() before rb_page_size() on the reader size. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261113152729.837429-3-vdonnefort@google.com Fixes: 2e67fabd8b77 ("ring-buffer: Introduce ring-buffer remotes") Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer") Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysring-buffer: Skip remote reader page swap when on tailVincent Donnefort
When the reader page is also the tail, swap should not be permitted or it would insert the tail behind the head, breaking the integrity of the ring buffer. While __rb_get_reader_page() does correctly prevent this situation, the simple_ring_buffer implementation misses it. Once the reader catches up with the tail, make simple_ring_buffer_swap_reader_page() return 0. The remote reader now can expect an unchanged reader. When it is the case, there's nothing more to read. Also, when the simple_ring_buffer writer moves the tail to a new page, it resets the new tail counters and more specifically page::commit. As moving the tail unblocks page swap, order the page reset before the tail_page update. This ensures the reader can't swap the reader page with the new tail and observe a stale commit value. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261113152729.837429-2-vdonnefort@google.com Fixes: 2e67fabd8b77 ("ring-buffer: Introduce ring-buffer remotes") Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer") Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysfgraph: Do not mark index 0 in every shadow stack frameBreno Leitao
We are seeing this warning on an arm64 host: WARNING: kernel/trace/fprobe.c:676 at fprobe_return+0x260/0x2c8, CPU#16: FuncSched/3281330 Call trace: fprobe_return+0x260/0x2c8 (P) ftrace_return_to_handler+0x2bc/0x5a8 return_to_handler+0x20/0x48 futex_wait+0xa4/0x218 do_futex+0xb4/0x1d0 __arm64_sys_futex+0x15c/0x278 The theory is that function_graph_enter_regs() sets BIT(0) in the bitmap of every frame, a leftover of an old tail-call check, while the return path calls the retfunc of every set bit. A reproducer on linux-next supports the theory. On a fresh boot, with no other fgraph user yet: cd /sys/kernel/tracing echo 'f:fpexit vfs_read%return' >> dynamic_events echo 1 > events/fprobes/fpexit/enable # fprobe_graph_ops: index 0 echo vfs_write > set_ftrace_filter echo function_graph > current_tracer # function_graph: index 1 echo x > /dev/null # WARN on vfs_write return Removing the bit was agreed in the review of the series that added it [0], but the line stayed. Drop it now. [0] https://lore.kernel.org/all/20240527093436.7060d358a64cc2ea3213b07b@kernel.org/ Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261112-fgraph-bit0-v1-1-695ad14f4b1e@debian.org Fixes: 7aa1eaef9f42 ("function_graph: Allow multiple users to attach to function graph") Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Validate user addresses in faultable buffer copiesKyle Zeng
trace_user_fault_read() uses __copy_from_user() when no custom copy function is supplied. That primitive assumes the source address has already been validated, but the helper only checks the destination buffer size. A caller that passes an unchecked kernel address can therefore cause mapped kernel memory to be copied into the tracing buffer. The original syscall-array tracing implementation exposed this path to syscall arguments before the syscall validated them. Use copy_from_user() for the default copy as documented. Non-user addresses then fail the copy and follow the existing NULL-return path. Successful user copies, buffer bounds, and preemption and migration retry rules are unchanged. Cc: stable@vger.kernel.org Fixes: 64cf7d058a005 ("tracing: Have trace_marker use per-cpu data to read user space") Link: https://patch.msgid.link/20261110054411.75788-1-kylebot@openai.com Signed-off-by: Kyle Zeng <kylebot@openai.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Wait for marker writers when copy_trace_marker is clearedPengfei Li
Clearing copy_trace_marker removes the instance from marker_copies without waiting for trace_marker writers still walking the list. If the option is set again right away, a writer on that entry can revisit instances and write the same marker twice. Assisted-by: LLM Link: https://patch.msgid.link/20261107110722.1241413-1-lipengfei28@xiaomi.com Fixes: 7b382efd5e8a ("tracing: Allow the top level trace_marker to write into another instances") Signed-off-by: Pengfei Li <lipengfei28@xiaomi.com> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing/user_events: Don't free an event that a dynamic event still referencesDavid Carlier
An eprobe takes a reference on the call of the event it attaches to, and kprobe, uprobe, fprobe and synth events all refuse to go away while trace_event_dyn_busy() says such a reference exists. user_events never checks it, so a user event can be freed under an eprobe: echo 'u:test u32 a' >> dynamic_events echo 'e:ep user_events/test a=$a' >> dynamic_events echo '-:user_events/test u32 a' >> dynamic_events echo '-:eprobes/ep' >> dynamic_events The last write drops the reference on the freed call. If the last fd of a non-persistent event closes while such a reference is held, the delayed destroy now fails. Mark the event persistent then, so it can still be deleted once the reference is gone instead of being leaked. Return -EBUSY from destroy_user_event() in that case. Fixes: 7f5a08c79df3 ("user_events: Add minimal support for trace_event into ftrace") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261031212453.16116-1-devnexen@gmail.com Signed-off-by: David Carlier <devnexen@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing/osnoise: Don't start a kthread in timerlat user-space modeChaosheng Qu
In timerlat user-space mode (NO_OSNOISE_WORKLOAD) the workload is a user task reading timerlat_fd, so there is no per-CPU kernel thread to run. start_kthread() only checks for that in the osnoise branch: if (timerlat_enabled()) { snprintf(comm, 24, "timerlat/%d", cpu); main = timerlat_main; } else { /* if no workload, just return */ if (!test_bit(OSN_WORKLOAD, &osnoise_options)) { ... return 0; } ... } start_per_cpu_kthreads() guards against this mode itself, but osnoise_hotplug_workfn() calls start_kthread() directly. Bringing a CPU online in user-space mode therefore starts a timerlat/N thread and sets its bit in kthread_cpumask while OSN_WORKLOAD is clear. stop_kthread() uses that bit to decide what the recorded task is: if (cpumask_test_and_clear_cpu(cpu, &kthread_cpumask) && !WARN_ON(!test_bit(OSN_WORKLOAD, &osnoise_options))) { kthread_stop(kthread); } else if (!WARN_ON(test_bit(OSN_WORKLOAD, &osnoise_options))) { kill_pid(kthread->thread_pid, SIGKILL, 1); put_task_struct(kthread); } The bit is set but OSN_WORKLOAD is not, so the first WARN_ON() fires and the && short-circuits into the user-task branch. A running kernel thread is SIGKILLed and its task_struct is put without ever being stopped, so it keeps executing until it is freed underneath itself. Any write to osnoise/options reaches this: osnoise_options_write() stops the per-CPU threads before applying the new value, so stop_kthread() still sees OSN_WORKLOAD clear. Re-writing the value that is already set triggers it just as well as changing it. echo NO_OSNOISE_WORKLOAD > osnoise/options echo timerlat > current_tracer echo 0 > /sys/devices/system/cpu/cpu1/online echo 1 > /sys/devices/system/cpu/cpu1/online echo NO_OSNOISE_WORKLOAD > osnoise/options The offline/online pair is required, otherwise no kthread is recorded and no bit is set. Running this on 7.3-rc7 with KASAN gives a WARNING in stop_kthread() followed by a slab-use-after-free in update_se(); leaving out the hotplug step produces neither. Keep the check in start_kthread(), where the related hotplug bug was fixed in 0bb0a5c12ecf, instead of adding another copy to the callback. Cc: stable@vger.kernel.org Fixes: e88ed227f639 ("tracing/timerlat: Add user-space interface") Link: https://patch.msgid.link/20261014081034.12702-1-chaosheng.qu.linux@gmail.com Signed-off-by: Chaosheng Qu <chaosheng.qu.linux@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysfgraph: Read the task->ret_stack with a smp_load_acquire()Steven Rostedt
The setting of task->ret_stack was switched from a smp_wmb() and the update to the variable with a smp_store_release(). Match the reading of the task->ret_stack with a smp_load_acquire() to replace the read and smp_rmb(). Also update graph_init_task() to use smp_store_release(). Link: https://lore.kernel.org/all/20261021174406.2891598-2-vineet.gupta@linux.dev/ Link: https://patch.msgid.link/20261117200108.35179ae8@gandalf.local.home Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysfgraph: Use scoped_guard() for the task list walkVineet Gupta
alloc_retstack_tasklist() open-codes rcu_read_lock() and unwinds it through an unlock label. Use scoped_guard(rcu) instead and let the compiler emit the unlock on every exit path. The -EAGAIN case now jumps straight to the free label rather than to unlock; leaving the guard's scope releases the RCU read lock on the way, so the unlock label has no remaining users and is removed. No functional change: objdump of fgraph.o shows identical call targets and counts, including the three __rcu_read_unlock() sites the compiler emits for the exits from the read-side section. A PROVE_RCU + DEBUG_ATOMIC_SLEEP build with the -EAGAIN path forced several thousand times is clean. Link: https://patch.msgid.link/20261021174406.2891598-3-vineet.gupta@linux.dev Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev> Tested-by: Vineet Gupta <vineet.gupta@linux.dev> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daysfgraph: Allocate shadow stacks inline with GFP_NOWAITVineet Gupta
When ftrace graphing is turned on, all tasks in the system missing return stack page are assigned one. This is done in a simplistic multi-sweep loop of FTRACE_RETSTACK_ALLOC_SIZE (currently 32) tasks at a time as follows: start_graph_tracing() do { alloc_retstack_tasklist } while (-EAGAIN); alloc_retstack_tasklist() alloc x32 # GFP_KERNEL, may sleep rcu_read_lock() # preempt off for_each_process_thread walk N_total, no cond_resched t->ret_stack = new_page rcu_read_unlock() # preempt enable but no explicit yield Each successive iteration of loop invokes for_each_process_thread() which doesn't support cursor based resume and always restarts from the init_task. Thus each successive loop needs to skip the tasks assigned ret_stack in prior sweeps and thus take longer and longer to find the candidate 32 tasks. And while the loop end calls rcu unlock, and re-enables preemption briefly, there is no explicit yield. The total number of iterations turn out to be N_total * N_null / (2 * FTRACE_RETSTACK_ALLOC_SIZE) where N_total is the number of threads on the system and N_null the number of those whose ret_stack is still NULL. After boot with no fgraph user that is every thread. This is not a tracing-only path. Since commit 4346ba160409 ("fprobe: Rewrite fprobe on function-graph tracer") fprobe is built on fgraph, so an ordinary kprobe_multi BPF attach that flips ftrace_graph_active from 0 to 1 pays the whole cost inside one bpf() syscall. Commit 2c67dc457bc6 ("tracing: fprobe: optimization for entry only case") narrows that to return and session probes but does not remove it. A host running hundreds of thousands of threads, with the current batch size of 32, turns the ftrace_graph_active 0 -> 1 transition into a multi-second, and eventually multi-minute, operation which showed up as RCU stall and softlockup_panic on heavily loaded Meta Fleet machines with preemption disabled. rcu: INFO: rcu_sched self-detected stall on CPU rcu: 0-....: (20718 ticks this GP) (t=21000 jiffies g=913 q=8 ncpus=8) CPU: 0 UID: 0 PID: 160141 Comm: bpftrace ___slab_alloc+0x549/0xa20 kmem_cache_alloc_noprof+0x16c/0x340 register_ftrace_graph+0x3d7/0x6c0 register_fprobe_ips+0x2d5/0x310 bpf_kprobe_multi_link_attach+0x218/0x7e0 __sys_bpf+0x267a/0x27a0 Fix this by allocating inline with GFP_NOWAIT instead of pre-allocating a fixed batch. GFP_NOWAIT does not sleep, so it is legal inside the RCU read-side critical section. A single sweep now serves every task, so the walk becomes O(N) rather than O(N_total * N_null), and the retry loop is no longer the normal path. The pre-allocated array remains as the fallback when GFP_NOWAIT fails. The runs below never needed it, so it was exercised with failslab injection: at a 100% failure rate every task falls back and -EAGAIN retries ~1560 times for 50000 threads, with no stall or splat. smp_store_release() is a drop-in replacement for the smp_wmb() and plain store it replaces. Measured on a 60-core Sapphire Rapids machine running a PREEMPT_LAZY kernel (CONFIG_PREEMPT_DYNAMIC=y, mode lazy), timing the write that drives the ftrace_graph_active 0 -> 1 transition. Threads are spawned while fgraph is inactive so every one of them has ret_stack == NULL, and the loop was instrumented to count sweeps: threads before after sweeps time sweeps time 100000 3126 15.3 s 1 0.019 s 200000 6253 59.1 s 1 0.047 s 400000 12503 227.8 s 1 0.092 s The sweep count is 1 throughout. Time now scales linearly with the thread count at roughly 230 ns per task, which is the allocation and initialisation of one shadow stack. Fixes: f201ae2356c7 ("tracing/function-return-tracer: store return stack into task_struct and allocate it dynamically") Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev> Tested-by: Vineet Gupta <vineet.gupta@linux.dev> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261021174406.2891598-2-vineet.gupta@linux.dev Acked-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Free tracer resources on instance creation failureBaek Kyu, Kim
Creating a tracefs instance can allocate private tracer nodes, copied flags and option arrays before trace_array_create_dir() returns. If a later allocation fails, trace_array_create_systems() frees the trace_array without releasing those private allocations. The failed instance is never registered, so normal removal cannot reclaim them. Free the tracer nodes and option arrays when trace_array_create_dir() fails, then continue through the existing trace_array cleanup. Share the option array cleanup with normal instance removal. Earlier failures still use out_free_tr because the tracer list is not yet initialized there. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261029173127.387835-1-pocj8ur4in@gmail.com Fixes: 428add559b69 ("tracing: Have tracer option be instance specific") Signed-off-by: Baek Kyu, Kim <pocj8ur4in@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing/filters: Fix false success return in process_system_preds()Masami Hiramatsu (Google)
In process_system_preds(), "fail" was initialized to true to indicate whether any event in the subsystem successfully applied the filter. However, "fail = false;" was placed at the end of the event loop outside the error check, unconditionally clearing "fail" on every iteration even when process_preds() returned an error. As a result, if every event in the subsystem fails to match the filter (e.g., an invalid field), process_system_preds() returns 0 (success) instead of -EINVAL. Consequently, create_system_filter() considers the operation successful and silently resets the subsystem filter display to the default global filter message instead of reporting the parse error. Fix this by clearing "fail" only when at least one event filter succeeds. Consolidate the cleanup logic in fail and fail_mem by using ret initialized to -ENOMEM, setting ret to -EINVAL in fail, and falling through to fail_mem, freeing any replaced filters via delay_free_filter() if !list_empty(&filter_list->list). Cc: stable@vger.kernel.org Fixes: 80765597bc58 ("tracing: Rewrite filter logic to be simpler and faster") Link: https://patch.msgid.link/179324101176.752804.17624386967710135045.stgit@devnote2 Suggested-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing/filters: Check for missing operand after operator in parse_pred()Masami Hiramatsu (Google)
In parse_pred(), after matching the operator and skipping whitespace, the filter string may terminate (str[i] == '\0') if the operand is missing (e.g. "ip ==" or "common_pid =="). For function events, the loop 'for (i++; str[i]; i++)' unconditionally increments 'i' past the NUL terminator, causing an out-of-bounds read. For other event types, allocating a predicate only to fail later during value parsing is wasteful. Check if 'str[i]' is NUL immediately after skipping whitespace after the operator, and report FILT_ERR_INVALID_FILTER. Cc: stable@vger.kernel.org Fixes: 80765597bc58 ("tracing: Rewrite filter logic to be simpler and faster") Link: https://patch.msgid.link/179323789181.740114.16161070743864669086.stgit@devnote2 Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparisonMasami Hiramatsu (Google)
In filter_pred_##size##_cpumask(), if the event's scalar CPU value is out of range (cpu >= nr_cpu_ids), it unconditionally returns 0. However, if the predicate operation is OP_NE (e.g., field != CPUS{0,1}), an out-of-range CPU cannot match any valid CPU in the user-provided cpumask and the condition is satisfied. Returning 0 produces a false negative. Return "pred->op == OP_NE" instead of 0 when cpu >= nr_cpu_ids. Cc: stable@vger.kernel.org Fixes: 3cbec9d7b93d ("tracing/filters: Enable filtering a scalar field by a cpumask") Link: https://patch.msgid.link/179323787340.740114.14434420599496956193.stgit@devnote2 Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size stringsMasami Hiramatsu (Google)
regex_match_end() calculates string length as "len - 1", assuming @len is the string length including trailing '\0'. For dynamic strings (filter_pred_strloc) and pointer strings (filter_pchar), this assumption holds and allows O(1) constant-time suffix matching. However, for fixed-size string fields (FILTER_STATIC_STRING) and "comm" (FILTER_COMM), the callers pass the buffer capacity rather than the actual string length (field->size for filter_pred_string, and TASK_COMM_LEN for filter_pred_comm). Because these buffers hold null-terminated strings (e.g. prev_comm in sched_switch holding "bash" in a 16-byte buffer), regex_match_end() tests against the tail of the buffer capacity (typically trailing '\0' padding at offset 13) rather than the actual string end. Consequently, suffix matching like comm ~ "*sh" or prev_comm ~ "*sh" fails for all strings shorter than the buffer capacity. Furthermore, for trace events like ftrace/print (trace_marker), the "buf" field is defined with size 0, denoting an unbounded NUL-terminated string. regex_match_end() and regex_match_end_str() return 0 when len is 0, causing suffix matching to fail on ftrace/print events as well. To fix this without penalizing dynamic and pointer strings with an unnecessary scan on every event: - Introduce regex_match_end_str() using strnlen(str, len) for fixed-size buffers (FILTER_COMM and FILTER_STATIC_STRING with field->size > 0). - Introduce regex_match_end_dynstr() using strlen(str) for unbounded strings (FILTER_STATIC_STRING with field->size == 0). Assign these match callbacks in parse_pred() when MATCH_END_ONLY is requested. Cc: stable@vger.kernel.org Fixes: a3291c14ecf0 ("tracing/filters: Fix MATCH_END_ONLY filter matching") Fixes: 10f20e9f9da9 ("tracing: Have zero size length in filter logic be full string") Link: https://patch.msgid.link/179323785497.740114.7643531772387726730.stgit@devnote2 Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Avoid undefined shifts for zero histogram map sizeJaewon Jung
Reject size=0 before calling roundup_pow_of_two(). include/linux/log2.h documents roundup_pow_of_two() as: - the result is undefined when n == 0 With CONFIG_UBSAN_SHIFT=y, a size=0 histogram trigger reports: UBSAN: shift-out-of-bounds in include/linux/log2.h shift exponent 64 is too large for 64-bit type 'long unsigned int' Tested on x86_64 QEMU: size=0 is rejected without UBSAN warnings, and the histogram modifier and parser tests pass. Fixes: 7ef224d1d0e3 ("tracing: Add 'hist' event trigger command") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261028074610.2212374-1-jaewon8868@gmail.com Signed-off-by: Jaewon Jung <jaewon8868@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Drop the synthetic event ref when clearing hist triggersDavid Carlier
clear_event_triggers() frees a hist trigger on a synthetic event without dropping the se->ref taken by event_hist_trigger_parse(). Removing an instance with such a trigger leaves the synthetic event busy forever. Cc: stable@vger.kernel.org Fixes: 4b147936fa50 ("tracing: Add support for 'synthetic' events") Link: https://patch.msgid.link/20261022205405.1228742-1-devnexen@gmail.com Signed-off-by: David Carlier <devnexen@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Define common event fields before enabling boot eventsDavid Carlier
event_trace_enable() parses trace_event= filters before event_trace_init_fields() has defined the common and generic fields, so a filter on common_pid or comm fails and the event stays off until event_trace_enable_again(). Link: https://patch.msgid.link/20261022204218.1222647-1-devnexen@gmail.com Fixes: 084100a1b579 ("tracing: Parse filter from boot event string") Signed-off-by: David Carlier <devnexen@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing/filters: Treat zero-length dynamic strings as emptyKyle Zeng
The regex callbacks use a length of zero for NUL-terminated strings of unknown size, such as the trailing buffer in a trace_marker record. However, filter_pred_strloc() and filter_pred_strrelloc() pass the length from a data locator directly to those callbacks. A zero-length locator has no data and need not point at a NUL byte. In particular, syscall entry events can contain an empty captured array or a failed user-string copy. Matching such a field with an equality, prefix, or substring filter can read beyond the record. The per-CPU perf trace buffer is reused, so an unprivileged counting syscall event can disclose bytes left by a previous kernel tracepoint even when raw sampling is denied and exclude_kernel prevents counting that tracepoint. Handle both locator formats through a common helper. For a zero-length field, pass an empty string and its actual size to the regex callback. This gives all matching modes the empty-string semantics without reading the locator's target. Keep nonzero fields and the legacy trace_marker unknown-length convention unchanged. Fixes: 10f20e9f9da9 ("tracing: Have zero size length in filter logic be full string") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261006225642.58778-1-kylebot@openai.com Assisted-by: Codex:gpt-6-astra Signed-off-by: Kyle Zeng <kylebot@openai.com> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Restrict perf filters that read kernel stringsKyle Zeng
A task-bound, counting-only syscall tracepoint can be opened without permission to read raw kernel tracepoint data. Setting exclude_kernel does not prevent its filter from running: perf_syscall_enter() submits the saved user-mode registers. Pointer-string filters use FILTER_PRED_FN_PCHAR by default, which reads through strncpy_from_kernel_nofault(). For sys_enter_openat, for example, the filename field comes directly from a syscall argument. An unprivileged caller can pass a kernel address, install a filter such as 'filename ~ "Linux version*"', and use the event count to test the contents of kernel memory, even with perf_event_paranoid=2. Check the compiled filter before installing it and require the same kernel and raw-tracepoint permissions as access to raw kernel tracepoint data for FILTER_PRED_FN_PCHAR. Inspect every predicate so that other events, operators, and boolean expressions cannot bypass the check. Return the permission error through the existing cleanup path before publishing the filter. Keep user-pointer (.ustring) and record-local predicates available under the existing policy. This leaves tracefs filtering and authorized kernel string filtering unchanged. Link: https://patch.msgid.link/20261006224005.49636-1-kylebot@openai.com Fixes: 5967bd5c4239 ("tracing: Let filter_assign_type() detect FILTER_PTR_STRING") Assisted-by: Codex:gpt-6-astra Signed-off-by: Kyle Zeng <kylebot@openai.com> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 daystracing: Keep copying markers when one instance is stoppedJaewon Jung
When several instances enable copy_trace_marker, stopping one instance can prevent the remaining buffers from receiving markers. Continue copying text and raw markers even if one copy fails. Return the largest successful write length, or -ENODEV if no write succeeds. Link: https://patch.msgid.link/20261104232046.32519-1-jaewon8868@gmail.com Fixes: 7b382efd5e8a ("tracing: Allow the top level trace_marker to write into another instances") Signed-off-by: Jaewon Jung <jaewon8868@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>