Re: [PATCH] uprobes: Improve the usage of xol slots for better scalability

From: Andi Kleen
Date: Wed Sep 18 2024 - 08:25:55 EST


Liao Chang <liaochang1@xxxxxxxxxx> writes:
> +
> +/*
> + * xol_recycle_insn_slot - recycle a slot from the garbage collection list.
> + */
> +static int xol_recycle_insn_slot(struct xol_area *area)
> +{
> + struct uprobe_task *utask;
> + int slot = UINSNS_PER_PAGE;
> +
> + rcu_read_lock();
> + list_for_each_entry_rcu(utask, &area->gc_list, gc) {
> + /*
> + * The utask associated slot is in-use or recycling when
> + * utask associated slot_ref is not one.
> + */
> + if (test_and_put_task_slot(utask)) {
> + slot = utask->insn_slot;
> + utask->insn_slot = UINSNS_PER_PAGE;
> + clear_bit(slot, area->bitmap);
> + atomic_dec(&area->slot_count);
> + get_task_slot(utask);

Doesn't this need some annotation to make ThreadSanitizer happy?
Would be good to have some commentary why doing so
many write operations with merely a rcu_read_lock as protection is safe.
It might be safer to put some write type operations under a real lock.
Also it is unclear how the RCU grace period for utasks is enforced.


-Andi