From: Alexey Dobriyan <adobriyan@gmail.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Stefani Seibold <stefani@seibold.net>,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
a.p.zijlstra@chello.nl, mingo@elte.hu
Subject: Re: + procfs-provide-stack-information-for-threads-v08.patch added to -mm tree
Date: Wed, 17 Jun 2009 01:30:04 +0400 [thread overview]
Message-ID: <20090616213004.GA6687@x200.localdomain> (raw)
In-Reply-To: <m1ski03r4f.fsf@fess.ebiederm.org>
On Tue, Jun 16, 2009 at 12:39:28PM -0700, Eric W. Biederman wrote:
> Stefani Seibold <stefani@seibold.net> writes:
>
> > Am Dienstag, den 16.06.2009, 02:33 +0400 schrieb Alexey Dobriyan:
> >> On Mon, Jun 15, 2009 at 03:02:05PM -0700, akpm@linux-foundation.org wrote:
> >> > procfs-provide-stack-information-for-threads-v08.patch
> >> > --- a/fs/proc/array.c~procfs-provide-stack-information-for-threads-v08
> >>
> >> > +++ a/fs/proc/array.c
> >> > @@ -321,6 +321,54 @@ static inline void task_context_switch_c
> >> > p->nivcsw);
> >> > }
> >> >
> >> > +static inline unsigned long get_stack_usage_in_bytes(struct vm_area_struct *vma,
> >> > + struct task_struct *p)
> >> > +{
> >> > + unsigned long i;
> >> > + struct page *page;
> >> > + unsigned long stkpage;
> >> > +
> >> > + stkpage = KSTK_ESP(p) & PAGE_MASK;
> >> > +
> >> > +#ifdef CONFIG_STACK_GROWSUP
> >> > + for (i = vma->vm_end; i-PAGE_SIZE > stkpage; i -= PAGE_SIZE) {
> >> > +
> >> > + page = follow_page(vma, i-PAGE_SIZE, 0);
> >>
> >> How can this work?
> >>
> >> If stack page got swapped out, you'll get smaller than actual result.
> >>
> >
> > If you tell me how to do it in the right way, i can fix it!
>
> You are attempting to answer two questions here.
> 1) Where do the thread stacks reside.
Kernel doesn't know. Application stack is somewhere below/above
some SP register.
> 2) What is the maximum stack space that has been used.
>
> Just listing the thread stacks seems like a small O(1) change.
>
> Computing how much stack space has been used looks trickier.
> Perhaps you could map them with MAP_GROWSDOWN? Of course that
> has the problem that you don't stop growing your stack until
> it bumps into something else. Not ideal for a thread stack.
prev parent reply other threads:[~2009-06-16 21:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200906152202.n5FM25VD021536@imap1.linux-foundation.org>
2009-06-15 22:33 ` Alexey Dobriyan
2009-06-16 6:17 ` Stefani Seibold
2009-06-16 19:39 ` Eric W. Biederman
2009-06-16 21:30 ` Alexey Dobriyan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090616213004.GA6687@x200.localdomain \
--to=adobriyan@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=stefani@seibold.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®