From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 21 23:26:28 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6A22216A for ; Sat, 21 Mar 2015 23:26:28 +0000 (UTC) Received: from mail-we0-x22c.google.com (mail-we0-x22c.google.com [IPv6:2a00:1450:400c:c03::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EB79BA19 for ; Sat, 21 Mar 2015 23:26:27 +0000 (UTC) Received: by weop45 with SMTP id p45so109136101weo.0 for ; Sat, 21 Mar 2015 16:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=GDpYO1GrtywxNpvNYRjdH67G6hRP3UmnXVavsKXBGPs=; b=b3ucEfuKW95i3E9wdPcl0mLBJl7YDYXFtIAnKDKH+KjRtwZT8CDxIOBN1zOY2gxRsK ijn+Usafp82KTBrMyqH/t5NZT/AUP6bSo8KZtz/hM9A8m57EMOeFer7QzVbH0ks2GFpe 1iE1nqQC2tvyhJ9U8MYW2ibBREwUFBiprCIPsSSu12AGw8jsRIMAgukmfaJbS4MhC7uf s01n28TCzmatOBwwGQKU0TKbXyD0S9gf0VKLjLfbhVRgbeVCPr4qY3n9/+NAy6vOVJKu lSkh8gen1WIUxDM/2sw9BUV1sautqb/sbvGwIw9JiFi9f7qkNiyeDCileFVzihqqln4Y HkRA== X-Received: by 10.195.13.168 with SMTP id ez8mr169985343wjd.30.1426980386372; Sat, 21 Mar 2015 16:26:26 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id a6sm4251701wiy.17.2015.03.21.16.26.24 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Mar 2015 16:26:25 -0700 (PDT) Date: Sun, 22 Mar 2015 00:26:22 +0100 From: Mateusz Guzik To: Yue Chen Subject: Re: How to traverse kernel threads? Message-ID: <20150321232622.GF14650@dft-labs.eu> Mail-Followup-To: Mateusz Guzik , Yue Chen , "freebsd-hackers@freebsd.org" References: <20150321220246.GE14650@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Mar 2015 23:26:28 -0000 On Sat, Mar 21, 2015 at 06:11:57PM -0400, Yue Chen wrote: > 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? > Kernel modules don't have stacks, presumably you mean kernel threads created by code in modules. But how would you go about recognising that given thread was created by given module? I don't see starting func stored anywhere, so you would need some crap hacks to unwind the stack by hand and even that is not reliable (not to mention terrible). But once more the real question is what are you trying to do. I don't see any use for stack info of random threads. -- Mateusz Guzik