Re: [PATCH v2 1/2] bpf: Replace sort_r_nonatomic() with sort_r() in check_dup_ids()

From: Jiri Olsa

Date: Fri Sep 11 2026 - 04:37:12 EST


On Thu, Sep 10, 2026 at 04:52:20PM +0000, Kuan-Wei Chiu wrote:
> bpf_kprobe_multi_link_attach() in the same file has been using sort_r()
> under the exact same limit (1U << 20) for 4 years without issues.

true

> Switch check_dup_ids() from sort_r_nonatomic() to sort_r() to match it.

I looked it up and I used that based on sashiko comment,
it seems like switching to sort_r sould be fine

Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>

>
> This removes the last in-tree user of sort_r_nonatomic(), allowing the
> unused _nonatomic() sort variants to be dropped from the core library.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx>
> ---
> Build test only

I ran bpf ci on this, it passed

jirka


>
> kernel/trace/bpf_trace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 29260951aa87..1d7e73ddbafb 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -3826,7 +3826,7 @@ static int check_dup_ids(u32 *ids, u64 *cookies, u32 cnt)
> * and check it for duplicates. The ids and cookies arrays
> * are left sorted.
> */
> - sort_r_nonatomic(ids, cnt, sizeof(ids[0]), ids_cmp_r, ids_swap_r, data);
> + sort_r(ids, cnt, sizeof(ids[0]), ids_cmp_r, ids_swap_r, data);
>
> for (int i = 1; i < cnt; i++) {
> if (ids[i] == ids[i - 1]) {
> --
> 2.55.0.1003.g10538fe699-goog
>