From a5e65657007ebfe94139c067e7c0dec2fd4a3cb3 Mon Sep 17 00:00:00 2001 From: Vasiliy Kulikov Date: Mon, 27 Jun 2011 16:18:11 -0700 Subject: [PATCH] --- yaml --- r: 254108 b: refs/heads/master c: 26c4caea9d697043cc5a458b96411b86d7f6babd h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/kernel/taskstats.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index f09281b0a936..1b7f4cbcf2ba 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 08142579b6ca35883c1ed066a2681de6f6917062 +refs/heads/master: 26c4caea9d697043cc5a458b96411b86d7f6babd diff --git a/trunk/kernel/taskstats.c b/trunk/kernel/taskstats.c index 9ffea360a778..fc0f22005417 100644 --- a/trunk/kernel/taskstats.c +++ b/trunk/kernel/taskstats.c @@ -285,16 +285,18 @@ static void fill_tgid_exit(struct task_struct *tsk) static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd) { struct listener_list *listeners; - struct listener *s, *tmp; + struct listener *s, *tmp, *s2; unsigned int cpu; if (!cpumask_subset(mask, cpu_possible_mask)) return -EINVAL; + s = NULL; if (isadd == REGISTER) { for_each_cpu(cpu, mask) { - s = kmalloc_node(sizeof(struct listener), GFP_KERNEL, - cpu_to_node(cpu)); + if (!s) + s = kmalloc_node(sizeof(struct listener), + GFP_KERNEL, cpu_to_node(cpu)); if (!s) goto cleanup; s->pid = pid; @@ -303,9 +305,16 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd) listeners = &per_cpu(listener_array, cpu); down_write(&listeners->sem); + list_for_each_entry_safe(s2, tmp, &listeners->list, list) { + if (s2->pid == pid) + goto next_cpu; + } list_add(&s->list, &listeners->list); + s = NULL; +next_cpu: up_write(&listeners->sem); } + kfree(s); return 0; }