History

signalfd simplification

This simplifies signalfd code, by avoiding it to remain attached to the sighand during its lifetime. In this way, the signalfd remain attached to the sighand only during poll(2) (and select and epoll) and read(2). This also allows to remove all the custom "tsk == current" checks in kernel/signal.c, since dequeue_signal() will only be called by "current". I think this is also what Ben was suggesting time ago. The external effect of this, is that a thread can extract only its own private signals and the group ones. I think this is an acceptable behaviour, in that those are the signals the thread would be able to fetch w/out signalfd.

Davide Libenzi committed 19 years ago

Commit b8fceee1 parent 9db619e8 files · +39 −217Browse files

Showing the changes to include/linux (3 of 8 files). Show all

Unified · Split

3 files
  1. include/linux/init_task.h +1 −1
  2. include/linux/sched.h +1 −1
  3. include/linux/signalfd.h +4 −36
include/linux/init_task.h+1−1
@@ -86,7 +86,7 @@ extern struct nsproxy init_nsproxy; · 85 unmodified lines
8686 .count = ATOMIC_INIT(1), \
8787 .action = { { { .sa_handler = NULL, } }, }, \
8888 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
89− .signalfd_list = LIST_HEAD_INIT(sighand.signalfd_list), \
89+ .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
9090 }
9191
9292 extern struct group_info init_groups;
include/linux/sched.h+1−1
@@ -438,7 +438,7 @@ struct sighand_struct { · 437 unmodified lines
438438 atomic_t count;
439439 struct k_sigaction action[_NSIG];
440440 spinlock_t siglock;
441− struct list_head signalfd_list;
441+ wait_queue_head_t signalfd_wqh;
442442 };
443443
444444 struct pacct_struct {
include/linux/signalfd.h+4−36
@@ -45,49 +45,17 @@ struct signalfd_siginfo { · 44 unmodified lines
4545 #ifdef CONFIG_SIGNALFD
4646
4747 /*
48− * Deliver the signal to listening signalfd. This must be called
49− * with the sighand lock held. Same are the following that end up
50− * calling signalfd_deliver().
51− */
52−void signalfd_deliver(struct task_struct *tsk, int sig);
53−
54−/*
55− * No need to fall inside signalfd_deliver() if no signal listeners
56− * are available.
48+ * Deliver the signal to listening signalfd.
5749 */
5850 static inline void signalfd_notify(struct task_struct *tsk, int sig)
5951 {
60− if (unlikely(!list_empty(&tsk->sighand->signalfd_list)))
61− signalfd_deliver(tsk, sig);
62−}
63−
64−/*
65− * The signal -1 is used to notify the signalfd that the sighand
66− * is on its way to be detached.
67− */
68−static inline void signalfd_detach_locked(struct task_struct *tsk)
69−{
70− if (unlikely(!list_empty(&tsk->sighand->signalfd_list)))
71− signalfd_deliver(tsk, -1);
72−}
73−
74−static inline void signalfd_detach(struct task_struct *tsk)
75−{
76− struct sighand_struct *sighand = tsk->sighand;
77−
78− if (unlikely(!list_empty(&sighand->signalfd_list))) {
79− spin_lock_irq(&sighand->siglock);
80− signalfd_deliver(tsk, -1);
81− spin_unlock_irq(&sighand->siglock);
82− }
52+ if (unlikely(waitqueue_active(&tsk->sighand->signalfd_wqh)))
53+ wake_up(&tsk->sighand->signalfd_wqh);
8354 }
8455
8556 #else /* CONFIG_SIGNALFD */
8657
87−#define signalfd_deliver(t, s) do { } while (0)
88−#define signalfd_notify(t, s) do { } while (0)
89−#define signalfd_detach_locked(t) do { } while (0)
90−#define signalfd_detach(t) do { } while (0)
58+static inline void signalfd_notify(struct task_struct *tsk, int sig) { }
9159
9260 #endif /* CONFIG_SIGNALFD */
9361

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t