BPF List
 help / color / mirror / Atom feed
* Re: [PATCH 0/2] lib/sort: Clean up sort_nonatomic() and sort_r_nonatomic()
       [not found] <20260730181216.2709088-1-visitorckw@gmail.com>
@ 2026-07-30 19:32 ` Kuan-Wei Chiu
  0 siblings, 0 replies; only message in thread
From: Kuan-Wei Chiu @ 2026-07-30 19:32 UTC (permalink / raw)
  To: will, joro, akpm
  Cc: robin.murphy, nicolinc, cychu, hhchung, amitamishra, marscheng,
	linux-arm-kernel, iommu, linux-kernel, jserv, eleanor15x, kpsingh,
	mattbobrowski, song, jolsa, ast, daniel, andrii, eddyz87, memxor,
	martin.lau, yonghong.song, emil, rostedt, mhiramat,
	mathieu.desnoyers, bpf, linux-trace-kernel

+Cc maintainers/reviewers of kernel/trace/bpf_trace.c

On Thu, Jul 30, 2026 at 06:12:14PM +0000, Kuan-Wei Chiu wrote:
> Remove the sort_nonatomic() and sort_r_nonatomic() APIs from the kernel
> library.
> 
> Currently, the arm-smmu-v3 driver is the sole in-tree user of 
> sort_nonatomic(). Because the array size being sorted is small in

I just realized that I missed another in-tree user: sort_r_nonatomic()
is actually being used in kernel/trace/bpf_trace.c.

Looking at the bpf code, the array size there is bounded by
MAX_TRACING_MULTI_CNT, which is set to (1u << 20). I guess sorting an
array of this size in a single go could potentially cause scheduling
latency spikes on certain configurations if we don't yield the cpu.

Because of this, it seems my proposal to completely remove
sort_r_nonatomic() and sort_nonatomic() from the core library was
premature.

Please let me know if you think otherwise, or if there is any
alternative approach for check_dup_ids() that would allow us to safely
drop sort_r_nonatomic(). Otherwise, please disregard this series.

Regards,
Kuan-Wei

> practice, there is no real risk of triggering a soft lockup. Therefore,
> the periodic cond_resched() calls provided by the _nonatomic variant
> are unnecessary.
> 
> With the only in-tree user updated, the _nonatomic APIs are no longer
> needed anywhere in the kernel. Removing them effectively drops the
> wrapper function and eliminates the may_schedule branch from the
> innermost loop of the core sorting logic, slightly simplifying the code.
> 
> Kuan-Wei Chiu (2):
>   iommu/arm-smmu-v3: Replace sort_nonatomic() with sort()
>   Revert "lib/sort.c: add _nonatomic() variants with cond_resched()"
> 
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c |   6 +-
>  include/linux/sort.h                        |  11 --
>  lib/sort.c                                  | 110 ++++++--------------
>  3 files changed, 34 insertions(+), 93 deletions(-)
> 
> -- 
> 2.55.0.508.g3f0d502094-goog
> 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-30 19:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260730181216.2709088-1-visitorckw@gmail.com>
2026-07-30 19:32 ` [PATCH 0/2] lib/sort: Clean up sort_nonatomic() and sort_r_nonatomic() Kuan-Wei Chiu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox