Re: Accessing process information from inside a LKM?

From: Jimmie Mayfield (jimmie_at_excelsior.sackheads.org)
Date: 12/03/04

  • Next message: Kristoffer Br?nemyr: "OpenGL for HP-UX from tgs"
    Date: Fri, 03 Dec 2004 15:16:50 GMT
    
    

    On Fri, 3 Dec 2004 09:58:55 +1100, Shaun Clowes
    <delius@no.spam.for.me.progsoc.org> wrote:
    >
    > As far as I'm aware, you will need to traverse the structures manually, I'm
    > not aware of a kernel interface to lock the list and iterate across it.
    > However, when accessing the entries themselves you should always try to use
    > the interfaces defined in /usr/include/sys/proc_iface.h. The proc struct has
    > definitely changed a number of times in annoying ways during the 11 series.

    Hi. Thanks for the fast response. I was indeed afraid that the private part
    of the proc struct changes frequently. Something I (and my customer) will
    have to live with since they're fairly insistant on doing this from within
    the LKM rather than from userspace.

    You mentioned locking the list...I'm glad you brought this up because I
    forgot to ask about it in my original post. Looking at the q4-generated
    proc structure, I see "lock_t *p_lock" which presumably serializes access
    to the individual proc entries but I didn't see anything in
    /usr/include/sys/spinlock.h that suggests that the system process list
    itself is protected by a lock. This bothers me.

    One other question: ignoring the potential locking issue above, I'm curious
    about actually walking the process list. I understand that HP-UX 11i uses
    a linked list of proc structures rather than a static array? In the proc
    structure, I see reference to 6 pointers:
       p_cache_next and p_cache_prev
       p_pptr, p_cptr, p_osptr and p_ysptr, p_dptr

    I assume the last 4 are parent, youngest child, and oldest/youngest sibling.
    I'm not sure what p_cache_* are used for (possibly analogous to cached
    threads?). I'm also not sure what p_dptr refers to (orphaned descendants?).
    Does one navigate the process list using the five child/sibling pointers or by
    some other pointer that I've missed (or even possibly by using the p_cache_*
    pointers)?

    Thanks again for your help.

    >
    > Cheers,
    > Shaun
    >

    Jimmie

    -- 
    Jimmie Mayfield  
    http://www.sackheads.org/mayfield    email: mayfield+usenet@sackheads.org
    My mail provider does not welcome UCE -- http://www.sackheads.org/uce
    

  • Next message: Kristoffer Br?nemyr: "OpenGL for HP-UX from tgs"

    Relevant Pages

    • Re: [PATCH 08 of 11] anon-vma-rwsem
      ... have the padding due to the alignment of the 64-bit pointers in the ... On 32-bit, the alignment of list-head is obviously just 32 bits, so right ... now the structure is "perfectly packed" and doesn't have any empty space. ... spinlock_t lock; ...
      (Linux-Kernel)
    • Re: file locking.
      ... On Thu, 16 Aug 2007, John Baldwin wrote: ... I just introduced an extra flag so I could remove the race from dropping the lock inbetween operations and get an accurate count of how big the array needs to be. ... What's more troubling is the continued erosion of support for libkvm as it ... Well shaving off two pointers gets us into cacheline size for struct file which has some perf improvement. ...
      (freebsd-arch)
    • Re: Smart Pointers and Microsoft Foundation Classes
      ... LockProxy operator++{ ... lock l; ... problems that come with raw pointers, such as the need to delete them at ... Ownership is always important. ...
      (microsoft.public.vc.mfc)
    • Re: panic: kern/52718
      ... Bryan Liesner wrote: ... The problem is that the proc struct is not locked ... Either lock the proc before and unlock it after this, ...
      (freebsd-current)
    • Re: panic: kern/52718
      ... The problem is that the proc struct is not locked ... > in the lock and unlock. ... > to do is act on information already present. ...
      (freebsd-current)