Re: [PATCH 2/8] uprobes: revamp uprobe refcounting and lifetime management

Oleg Nesterov
2024-08-05T13:44:34Z

On 07/31, Andrii Nakryiko wrote:
>
> @@ -732,11 +776,13 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset,
> uprobe->ref_ctr_offset = ref_ctr_offset;
> init_rwsem(&uprobe->register_rwsem);
> init_rwsem(&uprobe->consumer_rwsem);
> + RB_CLEAR_NODE(&uprobe->rb_node);

I guess RB_CLEAR_NODE() is not necessary?

> @@ -1286,15 +1296,19 @@ static void build_probe_list(struct inode *inode,
> u = rb_entry(t, struct uprobe, rb_node);
> if (u->inode != inode || u->offset < min)
> break;
> + u = try_get_uprobe(u);
> + if (!u) /* uprobe already went away, safe to ignore */
> + continue;
> list_add(&u->pending_list, head);

cosmetic nit, feel to ignore, but to me

if (try_get_uprobe(u))
list_add(&u->pending_list, head);

looks more readable.

Other than the lack of kfree() in put_uprobe() and WARN() in _unregister()
the patch looks good to me.

Oleg.