Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 40413
b: refs/heads/master
c: b8534d7
h: refs/heads/master
i:
  40411: 1ad6067
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Oct 28, 2006
1 parent ac80129 commit b8c7f9a
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: 17b02695b254aa2ef0e53df9c8e6548f86e66a9d
refs/heads/master: b8534d7bd89df0cd41cd47bcd6733a05ea9a691a
1 change: 0 additions & 1 deletion trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ struct signal_struct {
struct pacct_struct pacct; /* per-process accounting information */
#endif
#ifdef CONFIG_TASKSTATS
spinlock_t stats_lock;
struct taskstats *stats;
#endif
};
Expand Down
15 changes: 6 additions & 9 deletions trunk/include/linux/taskstats_kern.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,26 @@ static inline void taskstats_exit_free(struct taskstats *tidstats)

static inline void taskstats_tgid_init(struct signal_struct *sig)
{
spin_lock_init(&sig->stats_lock);
sig->stats = NULL;
}

static inline void taskstats_tgid_alloc(struct signal_struct *sig)
static inline void taskstats_tgid_alloc(struct task_struct *tsk)
{
struct signal_struct *sig = tsk->signal;
struct taskstats *stats;
unsigned long flags;

if (sig->stats != NULL)
return;

/* No problem if kmem_cache_zalloc() fails */
stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
if (!stats)
return;

spin_lock_irqsave(&sig->stats_lock, flags);
spin_lock_irq(&tsk->sighand->siglock);
if (!sig->stats) {
sig->stats = stats;
stats = NULL;
}
spin_unlock_irqrestore(&sig->stats_lock, flags);
spin_unlock_irq(&tsk->sighand->siglock);

if (stats)
kmem_cache_free(taskstats_cache, stats);
Expand All @@ -59,7 +57,6 @@ static inline void taskstats_tgid_free(struct signal_struct *sig)
extern void taskstats_exit_alloc(struct taskstats **, unsigned int *);
extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int, unsigned int);
extern void taskstats_init_early(void);
extern void taskstats_tgid_alloc(struct signal_struct *);
#else
static inline void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu)
{}
Expand All @@ -71,7 +68,7 @@ static inline void taskstats_exit_send(struct task_struct *tsk,
{}
static inline void taskstats_tgid_init(struct signal_struct *sig)
{}
static inline void taskstats_tgid_alloc(struct signal_struct *sig)
static inline void taskstats_tgid_alloc(struct task_struct *tsk)
{}
static inline void taskstats_tgid_free(struct signal_struct *sig)
{}
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
if (clone_flags & CLONE_THREAD) {
atomic_inc(&current->signal->count);
atomic_inc(&current->signal->live);
taskstats_tgid_alloc(current->signal);
taskstats_tgid_alloc(current);
return 0;
}
sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
Expand Down
16 changes: 6 additions & 10 deletions trunk/kernel/taskstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ static int fill_tgid(pid_t tgid, struct task_struct *tgidtsk,
tsk = first;
read_lock(&tasklist_lock);
/* Start with stats from dead tasks */
if (first->signal) {
spin_lock_irqsave(&first->signal->stats_lock, flags);
if (first->sighand) {
spin_lock_irqsave(&first->sighand->siglock, flags);
if (first->signal->stats)
memcpy(stats, first->signal->stats, sizeof(*stats));
spin_unlock_irqrestore(&first->signal->stats_lock, flags);
spin_unlock_irqrestore(&first->sighand->siglock, flags);
}

do {
Expand Down Expand Up @@ -276,7 +276,7 @@ static void fill_tgid_exit(struct task_struct *tsk)
{
unsigned long flags;

spin_lock_irqsave(&tsk->signal->stats_lock, flags);
spin_lock_irqsave(&tsk->sighand->siglock, flags);
if (!tsk->signal->stats)
goto ret;

Expand All @@ -288,7 +288,7 @@ static void fill_tgid_exit(struct task_struct *tsk)
*/
delayacct_add_tsk(tsk->signal->stats, tsk);
ret:
spin_unlock_irqrestore(&tsk->signal->stats_lock, flags);
spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
return;
}

Expand Down Expand Up @@ -464,22 +464,18 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
size_t size;
int is_thread_group;
struct nlattr *na;
unsigned long flags;

if (!family_registered || !tidstats)
return;

spin_lock_irqsave(&tsk->signal->stats_lock, flags);
is_thread_group = tsk->signal->stats ? 1 : 0;
spin_unlock_irqrestore(&tsk->signal->stats_lock, flags);

rc = 0;
/*
* Size includes space for nested attributes
*/
size = nla_total_size(sizeof(u32)) +
nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);

is_thread_group = (tsk->signal->stats != NULL);
if (is_thread_group)
size = 2 * size; /* PID + STATS + TGID + STATS */

Expand Down

0 comments on commit b8c7f9a

Please sign in to comment.