System processes recognition.

From: Pawel Jakub Dawidek (pjd_at_FreeBSD.org)
Date: 03/15/05

  • Next message: Stephan Uphoff: "Re: Freeing vnodes."
    Date: Tue, 15 Mar 2005 13:51:36 +0100
    To: freebsd-arch@freebsd.org
    
    
    

    Hi.

    I found, that there is no way to know if the given process is a system
    (kernel) process or not:

    - P_SYSTEM flag is used also for userland processes (init),
    - P_KTHREAD flag is not used for swapper,
    - ps(1) thinks, that it found system process when there are no arguments
      (argv == NULL || argv[0] == NULL), but this is not true:
            char *argv[1] = { NULL };

            execve("/path/to/somewhere", argv, NULL);
      /path/to/somewhere process will be recognized by ps(1) as a system process.

    The easiest way to fix it, is to add P_KTHREAD flag to the swapper, I think:

    --- init_main.c 17 Feb 2005 10:00:09 -0000 1.255
    +++ init_main.c 15 Mar 2005 12:48:04 -0000
    @@ -365,7 +365,7 @@ proc0_init(void *dummy __unused)
             session0.s_leader = p;
     
             p->p_sysent = &null_sysvec;
    - p->p_flag = P_SYSTEM;
    + p->p_flag = P_SYSTEM | P_KTHREAD;
             p->p_sflag = PS_INMEM;
             p->p_state = PRS_NORMAL;
             knlist_init(&p->p_klist, &p->p_mtx);

    Opinions?

    -- 
    Pawel Jakub Dawidek                       http://www.wheel.pl
    pjd@FreeBSD.org                           http://www.FreeBSD.org
    FreeBSD committer                         Am I Evil? Yes, I Am!
    
    



  • Next message: Stephan Uphoff: "Re: Freeing vnodes."

    Relevant Pages

    • Re: Suspend2 merge preparation: Rationale behind the freezer changes.
      ... but we're not just talking about user threads. ... differentiate kernel threads and user threads (presumably using another ... >>number of processes in critical paths to reach zero. ... setting the PF_FRIDGE_WAIT flag and incrementing the ...
      (Linux-Kernel)
    • [PATCH 0/8] dynamic debug
      ... Each kernel sub-system seems to have its own way of dealing with debugging ... INTERFACE - userspace ... cpufreq_shared 0 flag 0 ...
      (Linux-Kernel)
    • Re: [PATCH 0/8] dynamic debug
      ... Each kernel sub-system seems to have its own way of dealing with debugging ... cpufreq_shared 0 flag 0 ... I've tried to make the kernel interface as simple as possible. ...
      (Linux-Kernel)
    • Re: [PATCH 1/3] change clone_flags type to u64
      ... You could just have added it to feature groups over time. ... go through those quickly too as more and more of the kernel ... mq is just waiting for a clone flag. ...
      (Linux-Kernel)
    • Re: [patch 0/4] MAP_NOZERO v2 - VM_NOZERO/MAP_NOZERO early summer madness
      ... Also, a simple kernel build, in my Dual Opteron with 8GB of RAM, shows ... So I implemented a rather quick hack that introduces a new mmapflag ... if your web browser and your ssh session are running under the same ...
      (Linux-Kernel)