public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@debian.org>
To: Dave Pifke <dave@pifke.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: CLONE_THREAD with old (glibc 2.2.5) linuxthreads
Date: Sat, 22 Feb 2003 01:10:57 -0500	[thread overview]
Message-ID: <20030222061057.GA16475@nevyn.them.org> (raw)
In-Reply-To: <Pine.LNX.4.50.0302211649300.19257-100000@burn.victim.com>

On Fri, Feb 21, 2003 at 05:05:40PM -0800, Dave Pifke wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> 
> I'm attempting to add ps-like code to an application, and am running into
> a problem calculating the memory usage of multithreaded processes.  The
> memory usage numbers in /proc/PID/statm don't give any indication as to
> whether or not the process shares its VM with another, thus a
> multithreaded application appears to be using (actual usage * number of
> threads).
> 
> It looks like this could be easilly solved by looking at Tgid in
> /proc/PID/status and calculating memory usage per-thread-group instead of
> per-process.  The problem, however, is that glibc 2.2.5 does not set
> CLONE_THREAD and so Tgid == Pid in every case.
> 
> Would it break anything if I patch my glibc to set this flag?  Is
> task_struct->tgid just informational in 2.4, or does it modify the
> behavior of the task somehow?

Don't even try it.  CLONE_THREAD changs the semantics for signal
delivery.

> Or, is there perhaps another way to see if CLONE_VM was set when the
> process was cloned?  (Thus avoiding the need to change anything in glibc.)

There's no good way.  Once you have the process tree you can make
pretty good guesses though; the hierarchy of LinuxThreads is quite
distinctive (first -> manager -> all children).  It might be nice to
export the clone flags in proc.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

      reply	other threads:[~2003-02-22  6:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-22  1:05 CLONE_THREAD with old (glibc 2.2.5) linuxthreads Dave Pifke
2003-02-22  6:10 ` Daniel Jacobowitz [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=20030222061057.GA16475@nevyn.them.org \
    --to=dan@debian.org \
    --cc=dave@pifke.org \
    --cc=linux-kernel@vger.kernel.org \
    /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