Re: 2.6.39-rc4+: Kernel leaking memory during FS scanning, regression?

From: Sedat Dilek
Date: Fri Apr 29 2011 - 03:55:59 EST


On Fri, Apr 29, 2011 at 12:02 AM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> On Thu, 28 Apr 2011, john stultz wrote:
>> On Thu, 2011-04-28 at 23:04 +0200, Thomas Gleixner wrote:
>> > /me suspects hrtimer changes to be the real culprit.
>>
>> I'm not seeing anything on right off, but it does smell like
>> e06383db9ec591696a06654257474b85bac1f8cb would be where such an issue
>> would crop up.
>>
>> Bruno, could you try checking out e06383db9ec, confirming it still
>> occurs (and then maybe seeing if it goes away at e06383db9ec^1)?
>>
>> I'll keep digging in the meantime.
>
> I found the bug already. The problem is that sched_init() calls
> init_rt_bandwidth() which calls hrtimer_init() _BEFORE_
> hrtimers_init() is called.
>
> That was unnoticed so far as the CLOCK id to hrtimer base conversion
> was hardcoded. Now we use a table which is set up at hrtimers_init(),
> so the bandwith hrtimer ends up on CLOCK_REALTIME because the table is
> in the bss.
>
> The patch below fixes this, by providing the table statically rather
> than runtime initialized. Though that whole ordering wants to be
> revisited.
>
> Thanks,
>
> Â Â Â Âtglx
>
> --- linux-2.6.orig/kernel/hrtimer.c
> +++ linux-2.6/kernel/hrtimer.c
> @@ -81,7 +81,11 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base,
> Â Â Â Â}
> Â};
>
> -static int hrtimer_clock_to_base_table[MAX_CLOCKS];
> +static int hrtimer_clock_to_base_table[MAX_CLOCKS] = {
> + Â Â Â [CLOCK_REALTIME] = HRTIMER_BASE_REALTIME,
> + Â Â Â [CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC,
> + Â Â Â [CLOCK_BOOTTIME] = HRTIMER_BASE_BOOTTIME,
> +};
>
> Âstatic inline int hrtimer_clockid_to_base(clockid_t clock_id)
> Â{
> @@ -1722,10 +1726,6 @@ static struct notifier_block __cpuinitda
>
> Âvoid __init hrtimers_init(void)
> Â{
> - Â Â Â hrtimer_clock_to_base_table[CLOCK_REALTIME] = HRTIMER_BASE_REALTIME;
> - Â Â Â hrtimer_clock_to_base_table[CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC;
> - Â Â Â hrtimer_clock_to_base_table[CLOCK_BOOTTIME] = HRTIMER_BASE_BOOTTIME;
> -
> Â Â Â Âhrtimer_cpu_notify(&hrtimers_nb, (unsigned long)CPU_UP_PREPARE,
> Â Â Â Â Â Â Â Â Â Â Â Â Â(void *)(long)smp_processor_id());
> Â Â Â Âregister_cpu_notifier(&hrtimers_nb);
>

Will you send this as a separate patch?

Please also feel free to add:

Tested-by: Sedat Dilek <sedat.dilek@xxxxxxxxx>

If you like also a Reported-by... as the issue is not new, I have
first reported it here [1].

- Sedat -

[1] http://lkml.org/lkml/2011/3/25/97
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/