linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Giarrusso <p.giarrusso@gmail.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Jeff Dike <jdike@addtoit.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] uml: pthreads instead of manual clone()?
Date: Mon, 17 May 2010 16:41:25 +0200	[thread overview]
Message-ID: <AANLkTilQfz-PfNf6ZTqguMKBsADghbK4pEBGVzpjSurm@mail.gmail.com> (raw)
In-Reply-To: <4BCB464A.702@web.de>

On Sun, Apr 18, 2010 at 19:50, Jan Kiszka <jan.kiszka@web.de> wrote:
> Hi Jeff,
>
> is there (still) any reason to use explicit clone() instead of pthreads
> to spawn UML kernel threads?
>
> While playing with a patch to finally move os_nsecs to proper
> CLOCK_MONOTONIC, I noticed some subtle side-effect: We need to link
> against librt for clock_gettime, but that indirectly drags in
> libpthread. Now gdb gets unhappy when you try to debug the UML kernel.
> It assumes that pthreads are used, but fails to find their IDs and
> terminates the session. So the obvious approach appears to be converting
> kernel threads to pthreads - if there aren't any know pitfalls.

I think you should better manually copy the clock_gettime syscall stub
or function (hoping it's simple enough). Basically, we don't want
glibc to do anything by his own free will, like doing TLS setup
(pthread could do that), allocating memory from the heap on its own
(we only allow it very early, and we try to make it still safe - see
the malloc replacement stuff we do through linker and
__real_malloc/_whatever_I_dont_recall_malloc). We got a bug once we
called getpid() just to get a ptrace notification, but glibc cached
the getpid() result: we have our own getpid() syscall stub (at some
point I was writing actual UML code, and I wrote some TLS code myself
- not sure whether it's the current implementation or it was
rewritten).

Then, maybe, it can be made to work, even if I really wonder about the
TLS setup stuff - we need to allow the guest userspace programs to do
basically any [gs]et_thread_area() calls. But it's really untrivial
IMHO.
-- 
Paolo Giarrusso

      reply	other threads:[~2010-05-17 14:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-18 17:50 uml: pthreads instead of manual clone()? Jan Kiszka
2010-05-17 14:41 ` Paolo Giarrusso [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=AANLkTilQfz-PfNf6ZTqguMKBsADghbK4pEBGVzpjSurm@mail.gmail.com \
    --to=p.giarrusso@gmail.com \
    --cc=jan.kiszka@web.de \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=user-mode-linux-devel@lists.sourceforge.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;
as well as URLs for NNTP newsgroup(s).