Re: [PATCH] sched: try to fix mm leak when freeing sched groups

From: Hillf Danton
Date: Thu Apr 21 2011 - 09:47:02 EST


On Thu, Apr 21, 2011 at 9:44 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Thu, 2011-04-21 at 21:37 +0800, Hillf Danton wrote:
>> When freeing sched groups, there is a sg (== sched_group_nodes[i]) not
>> got freed.
>> The relevant code is reshuffled to be clearer, and correct.
>
> The code doesn't even appear to exist, what kernel are you patching?
>
Hi Peter

It is linux-2.6.39-rc1.tar.bz2 downloaded at kernel.org, and
>> --- a/kernel/sched.c Â2011-03-30 03:09:48.000000000 +0800
is the time stamp, right?

thanks
Hillf

>> Signed-off-by: Hillf Danton <dhillf@xxxxxxxxx>
>> ---
>>
>> --- a/kernel/sched.c Â2011-03-30 03:09:48.000000000 +0800
>> +++ b/kernel/sched.c Â2011-04-21 21:09:00.000000000 +0800
>> @@ -7106,7 +7106,7 @@ static void free_sched_groups(const stru
>> Â Â Â Â Â Â Â Â Â Â Â continue;
>>
>> Â Â Â Â Â Â Â for (i = 0; i < nr_node_ids; i++) {
>> - Â Â Â Â Â Â Â Â Â Â struct sched_group *oldsg, *sg = sched_group_nodes[i];
>> + Â Â Â Â Â Â Â Â Â Â struct sched_group *sg = sched_group_nodes[i];
>>
>> Â Â Â Â Â Â Â Â Â Â Â cpumask_and(nodemask, cpumask_of_node(i), cpu_map);
>> Â Â Â Â Â Â Â Â Â Â Â if (cpumask_empty(nodemask))
>> @@ -7114,13 +7114,11 @@ static void free_sched_groups(const stru
>>
>> Â Â Â Â Â Â Â Â Â Â Â if (sg == NULL)
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue;
>> - Â Â Â Â Â Â Â Â Â Â sg = sg->next;
>> -next_sg:
>> - Â Â Â Â Â Â Â Â Â Â oldsg = sg;
>> - Â Â Â Â Â Â Â Â Â Â sg = sg->next;
>> - Â Â Â Â Â Â Â Â Â Â kfree(oldsg);
>> - Â Â Â Â Â Â Â Â Â Â if (oldsg != sched_group_nodes[i])
>> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto next_sg;
>> + Â Â Â Â Â Â Â Â Â Â do {
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct sched_group *next = sg->next;
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â kfree(sg);
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â sg = next;
>> + Â Â Â Â Â Â Â Â Â Â } while (sg != sched_group_nodes[i]);
>> Â Â Â Â Â Â Â }
>> Â Â Â Â Â Â Â kfree(sched_group_nodes);
>> Â Â Â Â Â Â Â sched_group_nodes_bycpu[cpu] = NULL;
>
>
>
>
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—