public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Stefani Seibold <stefani@seibold.net>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	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: Tue, 16 Jun 2009 12:39:28 -0700	[thread overview]
Message-ID: <m1ski03r4f.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <1245133026.17989.2.camel@wall-e> (Stefani Seibold's message of "Tue\, 16 Jun 2009 08\:17\:06 +0200")

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

Eric


  reply	other threads:[~2009-06-16 19:39 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 ` + procfs-provide-stack-information-for-threads-v08.patch added to -mm tree Alexey Dobriyan
2009-06-16  6:17   ` Stefani Seibold
2009-06-16 19:39     ` Eric W. Biederman [this message]
2009-06-16 21:30       ` Alexey Dobriyan

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=m1ski03r4f.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --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