Re: [PATCH net-next v1 1/3] connector/cn_proc: Add hash table for threads

From: Peter Zijlstra
Date: Mon Oct 14 2024 - 04:30:11 EST


On Sun, Oct 13, 2024 at 10:06:15AM -0700, Anjali Kulkarni wrote:

> + if (unlikely(task->flags & PF_EXIT_NOTIFY)) {
> + task_lock(task);
> + task->flags &= ~PF_EXIT_NOTIFY;
> + task_unlock(task);
> +

> @@ -413,6 +440,15 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
> if (msg->len == sizeof(*pinput)) {
> pinput = (struct proc_input *)msg->data;
> mc_op = pinput->mcast_op;
> + if (mc_op == PROC_CN_MCAST_NOTIFY) {
> + pr_debug("%s: Received PROC_CN_MCAST_NOTIFY, pid %d\n",
> + __func__, current->pid);
> + task_lock(current);
> + current->flags |= PF_EXIT_NOTIFY;
> + task_unlock(current);
> + err = cn_add_elem(pinput->uexit_code, current->pid);
> + return;
> + }

You seem to think that task_lock protects task->flags ? Why?