Re: [PATCH 3/4][resend] Show kernel stack usage in /proc/meminfo and OOM log output

From: KOSAKI Motohiro
Date: Mon Jul 13 2009 - 19:36:27 EST


> On Mon, 13 Jul 2009 15:02:25 +0900 (JST)
> KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> wrote:
>
> > ChangeLog
> > Since v1
> > - Rewrote the descriptin (Thanks Christoph!)
> >
> > =====================
> > Subject: [PATCH] Show kernel stack usage in /proc/meminfo and OOM log output
> >
> > The amount of memory allocated to kernel stacks can become significant and
> > cause OOM conditions. However, we do not display the amount of memory
> > consumed by stacks.
> >
> > Add code to display the amount of memory used for stacks in /proc/meminfo.
> >
> > ...
> >
> > +static void account_kernel_stack(struct thread_info *ti, int account)
> > +{
> > + struct zone *zone = page_zone(virt_to_page(ti));
> > +
> > + mod_zone_page_state(zone, NR_KERNEL_STACK, account);
> > +}
> > +
> > void free_task(struct task_struct *tsk)
> > {
> > prop_local_destroy_single(&tsk->dirties);
> > + account_kernel_stack(tsk->stack, -1);
>
> But surely there are other less expensive ways of calculating this.
> The number we want is small-known-constant * number-of-tasks.
>
> number-of-tasks probably isn't tracked, but can be calculated along the
> lines of nr_running(), nr_uninterruptible() and nr_iowait().

But, nr_running() don't know zone information. we really need
per-zone tracking IMHO.


> number-of-tasks is also equal to number-of-task_structs and
> number-of_thread_infos which can be obtained from slab (if the arch
> implemented these via slab - uglier).

You know, Almost architecture doesn't use slab for kernel-stack.




--
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/