Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

signal/drbd: Use send_sig not force_sig

The drbd module exclusively sends signals to kernel threads it creates with
kthread_create. These kernel threads do not block or ignore signals (only
flush signals after they have been delivered), nor can drbd threads
possibly be pid namespace init processes so the extra work that force_sig
performs that send_sig does not is unnecessary.

Further force_sig is for delivering synchronous signals (aka exceptions).
The locking in force_sig is not prepared to deal with running processes, as
tsk->sighand may change during exec for a running process.

In short it is not only unnecessary for drbd to use force_sig it is
semantically wrong.

With drbd using send_sig it becomes easier to maintain force_sig as only
synchronous signals need to be considered.

Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: drbd-dev@lists.linbit.com
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+3 -3
+1 -1
drivers/block/drbd/drbd_int.h
··· 1972 1972 { 1973 1973 struct task_struct *task = connection->ack_receiver.task; 1974 1974 if (task && get_t_state(&connection->ack_receiver) == RUNNING) 1975 - force_sig(SIGXCPU, task); 1975 + send_sig(SIGXCPU, task, 1); 1976 1976 } 1977 1977 1978 1978 static inline void request_ping(struct drbd_connection *connection)
+1 -1
drivers/block/drbd/drbd_main.c
··· 477 477 smp_mb(); 478 478 init_completion(&thi->stop); 479 479 if (thi->task != current) 480 - force_sig(DRBD_SIGKILL, thi->task); 480 + send_sig(DRBD_SIGKILL, thi->task, 1); 481 481 } 482 482 483 483 spin_unlock_irqrestore(&thi->t_lock, flags);
+1 -1
drivers/block/drbd/drbd_nl.c
··· 611 611 struct task_struct *opa; 612 612 613 613 kref_get(&connection->kref); 614 - /* We may just have force_sig()'ed this thread 614 + /* We may have just sent a signal to this thread 615 615 * to get it out of some blocking network function. 616 616 * Clear signals; otherwise kthread_run(), which internally uses 617 617 * wait_on_completion_killable(), will mistake our pending signal