Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24555
b: refs/heads/master
c: aa1757f
h: refs/heads/master
i:
  24553: 34c7a1a
  24551: a36f816
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Mar 29, 2006
1 parent 8d563f4 commit f0639ec
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 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: 1f09f9749cdde4e69f95d62d96d2e03f50b3353c
refs/heads/master: aa1757f90bea3f598b6e5d04d922a6a60200f1da
3 changes: 1 addition & 2 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ static int de_thread(struct task_struct *tsk)
/*
* Move our state over to newsighand and switch it in.
*/
spin_lock_init(&newsighand->siglock);
atomic_set(&newsighand->count, 1);
memcpy(newsighand->action, oldsighand->action,
sizeof(newsighand->action));
Expand All @@ -785,7 +784,7 @@ static int de_thread(struct task_struct *tsk)
write_unlock_irq(&tasklist_lock);

if (atomic_dec_and_test(&oldsighand->count))
sighand_free(oldsighand);
kmem_cache_free(sighand_cachep, oldsighand);
}

BUG_ON(!thread_group_leader(current));
Expand Down
8 changes: 0 additions & 8 deletions trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,8 @@ struct sighand_struct {
atomic_t count;
struct k_sigaction action[_NSIG];
spinlock_t siglock;
struct rcu_head rcu;
};

extern void sighand_free_cb(struct rcu_head *rhp);

static inline void sighand_free(struct sighand_struct *sp)
{
call_rcu(&sp->rcu, sighand_free_cb);
}

/*
* NOTE! "signal_struct" does not have it's own
* locking, because a shared signal_struct always
Expand Down
21 changes: 11 additions & 10 deletions trunk/kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,14 +786,6 @@ int unshare_files(void)

EXPORT_SYMBOL(unshare_files);

void sighand_free_cb(struct rcu_head *rhp)
{
struct sighand_struct *sp;

sp = container_of(rhp, struct sighand_struct, rcu);
kmem_cache_free(sighand_cachep, sp);
}

static inline int copy_sighand(unsigned long clone_flags, struct task_struct * tsk)
{
struct sighand_struct *sig;
Expand All @@ -806,7 +798,6 @@ static inline int copy_sighand(unsigned long clone_flags, struct task_struct * t
rcu_assign_pointer(tsk->sighand, sig);
if (!sig)
return -ENOMEM;
spin_lock_init(&sig->siglock);
atomic_set(&sig->count, 1);
memcpy(sig->action, current->sighand->action, sizeof(sig->action));
return 0;
Expand Down Expand Up @@ -1356,11 +1347,21 @@ long do_fork(unsigned long clone_flags,
#define ARCH_MIN_MMSTRUCT_ALIGN 0
#endif

static void sighand_ctor(void *data, kmem_cache_t *cachep, unsigned long flags)
{
struct sighand_struct *sighand = data;

if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR)
spin_lock_init(&sighand->siglock);
}

void __init proc_caches_init(void)
{
sighand_cachep = kmem_cache_create("sighand_cache",
sizeof(struct sighand_struct), 0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_DESTROY_BY_RCU,
sighand_ctor, NULL);
signal_cachep = kmem_cache_create("signal_cache",
sizeof(struct signal_struct), 0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void __exit_sighand(struct task_struct *tsk)
/* Ok, we're done with the signal handlers */
tsk->sighand = NULL;
if (atomic_dec_and_test(&sighand->count))
sighand_free(sighand);
kmem_cache_free(sighand_cachep, sighand);
}

void exit_sighand(struct task_struct *tsk)
Expand Down

0 comments on commit f0639ec

Please sign in to comment.