Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 287906
b: refs/heads/master
c: d80e731
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Feb 24, 2012
1 parent 69eed9b commit 7871c28
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 855a85f704026d5fe7de94fb1b765fe03404507f
refs/heads/master: d80e731ecab420ddcb79ee9d0ac427acbc187b4b
4 changes: 4 additions & 0 deletions trunk/fs/eventpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,10 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
struct epitem *epi = ep_item_from_wait(wait);
struct eventpoll *ep = epi->ep;

/* the caller holds eppoll_entry->whead->lock */
if ((unsigned long)key & POLLFREE)
list_del_init(&wait->task_list);

spin_lock_irqsave(&ep->lock, flags);

/*
Expand Down
11 changes: 11 additions & 0 deletions trunk/fs/signalfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
#include <linux/signalfd.h>
#include <linux/syscalls.h>

void signalfd_cleanup(struct sighand_struct *sighand)
{
wait_queue_head_t *wqh = &sighand->signalfd_wqh;

if (likely(!waitqueue_active(wqh)))
return;

/* wait_queue_t->func(POLLFREE) should do remove_wait_queue() */
wake_up_poll(wqh, POLLHUP | POLLFREE);
}

struct signalfd_ctx {
sigset_t sigmask;
};
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/asm-generic/poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#define POLLRDHUP 0x2000
#endif

#define POLLFREE 0x4000 /* currently only for epoll */

struct pollfd {
int fd;
short events;
Expand Down
5 changes: 4 additions & 1 deletion trunk/include/linux/signalfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ static inline void signalfd_notify(struct task_struct *tsk, int sig)
wake_up(&tsk->sighand->signalfd_wqh);
}

extern void signalfd_cleanup(struct sighand_struct *sighand);

#else /* CONFIG_SIGNALFD */

static inline void signalfd_notify(struct task_struct *tsk, int sig) { }

static inline void signalfd_cleanup(struct sighand_struct *sighand) { }

#endif /* CONFIG_SIGNALFD */

#endif /* __KERNEL__ */

#endif /* _LINUX_SIGNALFD_H */

5 changes: 4 additions & 1 deletion trunk/kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include <linux/user-return-notifier.h>
#include <linux/oom.h>
#include <linux/khugepaged.h>
#include <linux/signalfd.h>

#include <asm/pgtable.h>
#include <asm/pgalloc.h>
Expand Down Expand Up @@ -935,8 +936,10 @@ static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk)

void __cleanup_sighand(struct sighand_struct *sighand)
{
if (atomic_dec_and_test(&sighand->count))
if (atomic_dec_and_test(&sighand->count)) {
signalfd_cleanup(sighand);
kmem_cache_free(sighand_cachep, sighand);
}
}


Expand Down

0 comments on commit 7871c28

Please sign in to comment.