Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Mar 2015 18:11:57 -0400
From:      Yue Chen <ycyc321@gmail.com>
To:        Mateusz Guzik <mjguzik@gmail.com>, Yue Chen <ycyc321@gmail.com>,  "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: How to traverse kernel threads?
Message-ID:  <CAKtBrB5KNqt6UJ1R_BQpPfTvQZdUzGvZZtT7Uz5qd4VrrfgEdw@mail.gmail.com>
In-Reply-To: <20150321220246.GE14650@dft-labs.eu>
References:  <CAKtBrB4h13ZFJ=V0fvkDeTG-L6=e5Uz9%2BHfYc8vY523Y3X6N0A@mail.gmail.com> <20150321220246.GE14650@dft-labs.eu>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for the quick reply.

What I am trying to achieve is to get the stack starting and ending address
of a kernel module.
I think it could be got from

struct thread *td
td->td_kstack
td->td_kstack + td->td_kstack_pages * PAGE_SIZE

So I need to get the ``td'' first.
Maybe there is another way to get it other than traversing?

On Sat, Mar 21, 2015 at 6:02 PM, Mateusz Guzik <mjguzik@gmail.com> wrote:

> On Sat, Mar 21, 2015 at 05:54:24PM -0400, Yue Chen wrote:
> > Dear all,
> >
> > Is there an easy way to traverse all the kernel threads (including
> > modules') in a FreeBSD kernel module?
> > The resulting structure would be `` struct thread * ''.
> >
>
> Well if you read kthread_add you can see you just need to traverse
> threads linked into proc0.
>
> Chances are you also want to traverse kernel process (see kproc_create).
>
> The real question though is what are you trying to achieve.
>
> --
> Mateusz Guzik <mjguzik gmail.com>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAKtBrB5KNqt6UJ1R_BQpPfTvQZdUzGvZZtT7Uz5qd4VrrfgEdw>