進程描述符task_struct


    1、進程狀態 

[cpp] view plain copy
 
  1. volatile long state;  
  2. int exit_state;  

    state成員的可能取值如下: 

[cpp] view plain copy
 
  1. #define TASK_RUNNING        0  
  2. #define TASK_INTERRUPTIBLE  1  
  3. #define TASK_UNINTERRUPTIBLE    2  
  4. #define __TASK_STOPPED      4  
  5. #define __TASK_TRACED       8  
  6. /* in tsk->exit_state */  
  7. #define EXIT_ZOMBIE     16  
  8. #define EXIT_DEAD       32  
  9. /* in tsk->state again */  
  10. #define TASK_DEAD       64  
  11. #define TASK_WAKEKILL       128  
  12. #define TASK_WAKING     256  

    系統中的每個進程都必然處於以上所列進程狀態中的一種。

    TASK_RUNNING表示進程要么正在執行,要么正要准備執行。

    TASK_INTERRUPTIBLE表示進程被阻塞(睡眠),直到某個條件變為真。條件一旦達成,進程的狀態就被設置為TASK_RUNNING。

    TASK_UNINTERRUPTIBLE的意義與TASK_INTERRUPTIBLE類似,除了不能通過接受一個信號來喚醒以外。

    __TASK_STOPPED表示進程被停止執行。

    __TASK_TRACED表示進程被debugger等進程監視。

    EXIT_ZOMBIE表示進程的執行被終止,但是其父進程還沒有使用wait()等系統調用來獲知它的終止信息。

    EXIT_DEAD表示進程的最終狀態。

    EXIT_ZOMBIE和EXIT_DEAD也可以存放在exit_state成員中。 

    2、進程標識符(PID) 

[cpp] view plain copy
 
  1. pid_t pid;  
  2. pid_t tgid;  

    在CONFIG_BASE_SMALL配置為0的情況下,PID的取值范圍是0到32767,即系統中的進程數最大為32768個。 

[cpp] view plain copy
 
  1. /* linux-2.6.38.8/include/linux/threads.h */  
  2. #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000)  

    在Linux系統中,一個線程組中的所有線程使用和該線程組的領頭線程(該組中的第一個輕量級進程)相同的PID,並被存放在tgid成員中。只有線程組的領頭線程的pid成員才會被設置為與tgid相同的值。注意,getpid()系統調用返回的是當前進程的tgid值而不是pid值。

    3、進程內核棧 

[cpp] view plain copy
 
  1. void *stack;  

    進程通過alloc_thread_info函數分配它的內核棧,通過free_thread_info函數釋放所分配的內核棧。 

[cpp] view plain copy
 
  1. /* linux-2.6.38.8/kernel/fork.c */   
  2. static inline struct thread_info *alloc_thread_info(struct task_struct *tsk)  
  3. {  
  4. #ifdef CONFIG_DEBUG_STACK_USAGE  
  5.     gfp_t mask = GFP_KERNEL | __GFP_ZERO;  
  6. #else  
  7.     gfp_t mask = GFP_KERNEL;  
  8. #endif  
  9.     return (struct thread_info *)__get_free_pages(mask, THREAD_SIZE_ORDER);  
  10. }  
  11. static inline void free_thread_info(struct thread_info *ti)  
  12. {  
  13.     free_pages((unsigned long)ti, THREAD_SIZE_ORDER);  
  14. }  

    其中,THREAD_SIZE_ORDER宏在linux-2.6.38.8/arch/arm/include/asm/thread_info.h文件中被定義為1,也就是說alloc_thread_info函數通過調用__get_free_pages函數分配2個頁的內存(它的首地址是8192 字節對齊的)。

    Linux內核通過thread_union聯合體來表示進程的內核棧,其中THREAD_SIZE宏的大小為8192。 

  1. union thread_union {  
  2.     struct thread_info thread_info;  
  3.     unsigned long stack[THREAD_SIZE/sizeof(long)];  
  4. };  

    當進程從用戶態切換到內核態時,進程的內核棧總是空的,所以ARM的sp寄存器指向這個棧的頂端。因此,內核能夠輕易地通過sp寄存器獲得當前正在CPU上運行的進程。 

[cpp] view plain copy
 
  1. /* linux-2.6.38.8/arch/arm/include/asm/current.h */  
  2. static inline struct task_struct *get_current(void)  
  3. {  
  4.     return current_thread_info()->task;  
  5. }  
  6.   
  7. #define current (get_current())  
  8.   
  9. /* linux-2.6.38.8/arch/arm/include/asm/thread_info.h */   
  10. static inline struct thread_info *current_thread_info(void)  
  11. {  
  12.     register unsigned long sp asm ("sp");  
  13.     return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));  
  14. }  

    4、標記 

[cpp] view plain copy
 
  1. unsigned int flags; /* per process flags, defined below */  

    flags成員的可能取值如下: 

[cpp] view plain copy
 
  1. #define PF_KSOFTIRQD    0x00000001  /* I am ksoftirqd */  
  2. #define PF_STARTING 0x00000002  /* being created */  
  3. #define PF_EXITING  0x00000004  /* getting shut down */  
  4. #define PF_EXITPIDONE   0x00000008  /* pi exit done on shut down */  
  5. #define PF_VCPU     0x00000010  /* I'm a virtual CPU */  
  6. #define PF_WQ_WORKER    0x00000020  /* I'm a workqueue worker */  
  7. #define PF_FORKNOEXEC   0x00000040  /* forked but didn't exec */  
  8. #define PF_MCE_PROCESS  0x00000080      /* process policy on mce errors */  
  9. #define PF_SUPERPRIV    0x00000100  /* used super-user privileges */  
  10. #define PF_DUMPCORE 0x00000200  /* dumped core */  
  11. #define PF_SIGNALED 0x00000400  /* killed by a signal */  
  12. #define PF_MEMALLOC 0x00000800  /* Allocating memory */  
  13. #define PF_USED_MATH    0x00002000  /* if unset the fpu must be initialized before use */  
  14. #define PF_FREEZING 0x00004000  /* freeze in progress. do not account to load */  
  15. #define PF_NOFREEZE 0x00008000  /* this thread should not be frozen */  
  16. #define PF_FROZEN   0x00010000  /* frozen for system suspend */  
  17. #define PF_FSTRANS  0x00020000  /* inside a filesystem transaction */  
  18. #define PF_KSWAPD   0x00040000  /* I am kswapd */  
  19. #define PF_OOM_ORIGIN   0x00080000  /* Allocating much memory to others */  
  20. #define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */  
  21. #define PF_KTHREAD  0x00200000  /* I am a kernel thread */  
  22. #define PF_RANDOMIZE    0x00400000  /* randomize virtual address space */  
  23. #define PF_SWAPWRITE    0x00800000  /* Allowed to write to swap */  
  24. #define PF_SPREAD_PAGE  0x01000000  /* Spread page cache over cpuset */  
  25. #define PF_SPREAD_SLAB  0x02000000  /* Spread some slab caches over cpuset */  
  26. #define PF_THREAD_BOUND 0x04000000  /* Thread bound to specific cpu */  
  27. #define PF_MCE_EARLY    0x08000000      /* Early kill for mce process policy */  
  28. #define PF_MEMPOLICY    0x10000000  /* Non-default NUMA mempolicy */  
  29. #define PF_MUTEX_TESTER 0x20000000  /* Thread belongs to the rt mutex tester */  
  30. #define PF_FREEZER_SKIP 0x40000000  /* Freezer should not count it as freezable */  
  31. #define PF_FREEZER_NOSIG 0x80000000 /* Freezer won't send signals to it */  

    5、表示進程親屬關系的成員 

[cpp] view plain copy
 
  1. struct task_struct *real_parent; /* real parent process */  
  2. struct task_struct *parent; /* recipient of SIGCHLD, wait4() reports */  
  3. struct list_head children;  /* list of my children */  
  4. struct list_head sibling;   /* linkage in my parent's children list */  
  5. struct task_struct *group_leader;   /* threadgroup leader */  

    在Linux系統中,所有進程之間都有着直接或間接地聯系,每個進程都有其父進程,也可能有零個或多個子進程。擁有同一父進程的所有進程具有兄弟關系。

    real_parent指向其父進程,如果創建它的父進程不再存在,則指向PID為1的init進程。

    parent指向其父進程,當它終止時,必須向它的父進程發送信號。它的值通常與real_parent相同。

    children表示鏈表的頭部,鏈表中的所有元素都是它的子進程。

    sibling用於把當前進程插入到兄弟鏈表中。

    group_leader指向其所在進程組的領頭進程。

    6、ptrace系統調用 

[cpp] view plain copy
 
  1. unsigned int ptrace;  
  2. struct list_head ptraced;  
  3. struct list_head ptrace_entry;  
  4. unsigned long ptrace_message;  
  5. siginfo_t *last_siginfo; /* For ptrace use.  */  
  6. ifdef CONFIG_HAVE_HW_BREAKPOINT  
  7. atomic_t ptrace_bp_refcnt;  
  8. endif  

    成員ptrace被設置為0時表示不需要被跟蹤,它的可能取值如下: 

[cpp] view plain copy
 
  1. /* linux-2.6.38.8/include/linux/ptrace.h */  
  2. #define PT_PTRACED  0x00000001  
  3. #define PT_DTRACE   0x00000002  /* delayed trace (used on m68k, i386) */  
  4. #define PT_TRACESYSGOOD 0x00000004  
  5. #define PT_PTRACE_CAP   0x00000008  /* ptracer can follow suid-exec */  
  6. #define PT_TRACE_FORK   0x00000010  
  7. #define PT_TRACE_VFORK  0x00000020  
  8. #define PT_TRACE_CLONE  0x00000040  
  9. #define PT_TRACE_EXEC   0x00000080  
  10. #define PT_TRACE_VFORK_DONE 0x00000100  
  11. #define PT_TRACE_EXIT   0x00000200  

    7、Performance Event 

[cpp] view plain copy
 
  1. #ifdef CONFIG_PERF_EVENTS  
  2.     struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];  
  3.     struct mutex perf_event_mutex;  
  4.     struct list_head perf_event_list;  
  5. #endif  

    Performance Event是一款隨 Linux 內核代碼一同發布和維護的性能診斷工具。這些成員用於幫助PerformanceEvent分析進程的性能問題。

       8、進程調度 

[cpp] view plain copy
 
  1. int prio, static_prio, normal_prio;  
  2. unsigned int rt_priority;  
  3. const struct sched_class *sched_class;  
  4. struct sched_entity se;  
  5. struct sched_rt_entity rt;  
  6. unsigned int policy;  
  7. cpumask_t cpus_allowed;  

    實時優先級范圍是0到MAX_RT_PRIO-1(即99),而普通進程的靜態優先級范圍是從MAX_RT_PRIO到MAX_PRIO-1(即100到139)。值越大靜態優先級越低。 

  1. /* linux-2.6.38.8/include/linux/sched.h */  
  2. #define MAX_USER_RT_PRIO    100  
  3. #define MAX_RT_PRIO     MAX_USER_RT_PRIO  
  4.   
  5. #define MAX_PRIO        (MAX_RT_PRIO + 40)  
  6. #define DEFAULT_PRIO        (MAX_RT_PRIO + 20)  

    static_prio用於保存靜態優先級,可以通過nice系統調用來進行修改。

    rt_priority用於保存實時優先級。

    normal_prio的值取決於靜態優先級和調度策略。

    prio用於保存動態優先級。

    policy表示進程的調度策略,目前主要有以下五種: 

  1. #define SCHED_NORMAL        0  
  2. #define SCHED_FIFO      1  
  3. #define SCHED_RR        2  
  4. #define SCHED_BATCH     3  
  5. /* SCHED_ISO: reserved but not implemented yet */  
  6. #define SCHED_IDLE      5  

    SCHED_NORMAL用於普通進程,通過CFS調度器實現。SCHED_BATCH用於非交互的處理器消耗型進程。SCHED_IDLE是在系統負載很低時使用。

    SCHED_FIFO(先入先出調度算法)和SCHED_RR(輪流調度算法)都是實時調度策略。

    sched_class結構體表示調度類,目前內核中有實現以下四種: 

  1. /* linux-2.6.38.8/kernel/sched_fair.c */   
  2. static const struct sched_class fair_sched_class;  
  3. /* linux-2.6.38.8/kernel/sched_rt.c */  
  4. static const struct sched_class rt_sched_class;  
  5. /* linux-2.6.38.8/kernel/sched_idletask.c */  
  6. static const struct sched_class idle_sched_class;  
  7. /* linux-2.6.38.8/kernel/sched_stoptask.c */  
  8. static const struct sched_class stop_sched_class;  

    se和rt都是調用實體,一個用於普通進程,一個用於實時進程,每個進程都有其中之一的實體。

    cpus_allowed用於控制進程可以在哪里處理器上運行。

9、進程地址空間 

[cpp] view plain copy
 
  1.     struct mm_struct *mm, *active_mm;  
  2. #ifdef CONFIG_COMPAT_BRK  
  3.     unsigned brk_randomized:1;  
  4. #endif  
  5. #if defined(SPLIT_RSS_COUNTING)  
  6.     struct task_rss_stat    rss_stat;  
  7. #endif  

    mm指向進程所擁有的內存描述符,而active_mm指向進程運行時所使用的內存描述符。對於普通進程而言,這兩個指針變量的值相同。但是,內核線程不擁有任何內存描述符,所以它們的mm成員總是為NULL。當內核線程得以運行時,它的active_mm成員被初始化為前一個運行進程的 active_mm值。

      rss_stat用來記錄緩沖信息。 

    10、判斷標志 

[cpp] view plain copy
 
  1. int exit_code, exit_signal;  
  2. int pdeath_signal;  /*  The signal sent when the parent dies  */  
  3. /* ??? */  
  4. unsigned int personality;  
  5. unsigned did_exec:1;  
  6. unsigned in_execve:1;   /* Tell the LSMs that the process is doing an 
  7.              * execve */  
  8. unsigned in_iowait:1;  
  9.   
  10.   
  11. /* Revert to default priority/policy when forking */  
  12. unsigned sched_reset_on_fork:1;  

    exit_code用於設置進程的終止代號,這個值要么是_exit()或exit_group()系統調用參數(正常終止),要么是由內核提供的一個錯誤代號(異常終止)。

    exit_signal被置為-1時表示是某個線程組中的一員。只有當線程組的最后一個成員終止時,才會產生一個信號,以通知線程組的領頭進程的父進程。

    pdeath_signal用於判斷父進程終止時發送信號。

    personality用於處理不同的ABI,它的可能取值如下: 

[cpp] view plain copy
 
  1. enum {  
  2.     PER_LINUX =     0x0000,  
  3.     PER_LINUX_32BIT =   0x0000 | ADDR_LIMIT_32BIT,  
  4.     PER_LINUX_FDPIC =   0x0000 | FDPIC_FUNCPTRS,  
  5.     PER_SVR4 =      0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,  
  6.     PER_SVR3 =      0x0002 | STICKY_TIMEOUTS | SHORT_INODE,  
  7.     PER_SCOSVR3 =       0x0003 | STICKY_TIMEOUTS |  
  8.                      WHOLE_SECONDS | SHORT_INODE,  
  9.     PER_OSR5 =      0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,  
  10.     PER_WYSEV386 =      0x0004 | STICKY_TIMEOUTS | SHORT_INODE,  
  11.     PER_ISCR4 =     0x0005 | STICKY_TIMEOUTS,  
  12.     PER_BSD =       0x0006,  
  13.     PER_SUNOS =     0x0006 | STICKY_TIMEOUTS,  
  14.     PER_XENIX =     0x0007 | STICKY_TIMEOUTS | SHORT_INODE,  
  15.     PER_LINUX32 =       0x0008,  
  16.     PER_LINUX32_3GB =   0x0008 | ADDR_LIMIT_3GB,  
  17.     PER_IRIX32 =        0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */  
  18.     PER_IRIXN32 =       0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */  
  19.     PER_IRIX64 =        0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */  
  20.     PER_RISCOS =        0x000c,  
  21.     PER_SOLARIS =       0x000d | STICKY_TIMEOUTS,  
  22.     PER_UW7 =       0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,  
  23.     PER_OSF4 =      0x000f,          /* OSF/1 v4 */  
  24.     PER_HPUX =      0x0010,  
  25.     PER_MASK =      0x00ff,  
  26. };  

    did_exec用於記錄進程代碼是否被execve()函數所執行。

    in_iowait用於判斷是否進行iowait計數。

    sched_reset_on_fork用於判斷是否恢復默認的優先級或調度策略。

    11、時間 

[cpp] view plain copy
 
  1.     cputime_t utime, stime, utimescaled, stimescaled;  
  2.     cputime_t gtime;  
  3. #ifndef CONFIG_VIRT_CPU_ACCOUNTING  
  4.     cputime_t prev_utime, prev_stime;  
  5. #endif  
  6.     unsigned long nvcsw, nivcsw; /* context switch counts */  
  7.     struct timespec start_time;         /* monotonic time */  
  8.     struct timespec real_start_time;    /* boot based time */  
  9.     struct task_cputime cputime_expires;  
  10.     struct list_head cpu_timers[3];  
  11. #ifdef CONFIG_DETECT_HUNG_TASK  
  12. /* hung task detection */  
  13.     unsigned long last_switch_count;  
  14. #endif  

    utime/stime用於記錄進程在用戶態/內核態下所經過的節拍數(定時器)

    utimescaled/stimescaled也是用於記錄進程在用戶態/內核態的運行時間,但它們以處理器的頻率為刻度。

    gtime是以節拍計數的虛擬機運行時間(guest time)。

    nvcsw/nivcsw是自願(voluntary)/非自願(involuntary)上下文切換計數。last_switch_count是nvcsw和nivcsw的總和。

    start_time和real_start_time都是進程創建時間,real_start_time還包含了進程睡眠時間,常用於/proc/pid/stat,

    cputime_expires用來統計進程或進程組被跟蹤的處理器時間,其中的三個成員對應着cpu_timers[3]的三個鏈表。

    12、信號處理 

[cpp] view plain copy
 
  1. /* signal handlers */  
  2.     struct signal_struct *signal;  
  3.     struct sighand_struct *sighand;  
  4.   
  5.     sigset_t blocked, real_blocked;  
  6.     sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */  
  7.     struct sigpending pending;  
  8.   
  9.     unsigned long sas_ss_sp;  
  10.     size_t sas_ss_size;  
  11.     int (*notifier)(void *priv);  
  12.     void *notifier_data;  
  13.     sigset_t *notifier_mask;  

    signal指向進程的信號描述符。

    sighand指向進程的信號處理程序描述符。

    blocked表示被阻塞信號的掩碼,real_blocked表示臨時掩碼。

    pending存放私有掛起信號的數據結構

    sas_ss_sp是信號處理程序備用堆棧的地址,sas_ss_size表示堆棧的大小。

    設備驅動程序常用notifier指向的函數來阻塞進程的某些信號(notifier_mask是這些信號的位掩碼),notifier_data指的是notifier所指向的函數可能使用的數據。

    13、其他

    (1)、用於保護資源分配或釋放的自旋鎖 

[cpp] view plain copy
 
  1. /* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed, 
  2.  * mempolicy */  
  3.     spinlock_t alloc_lock;  

    (2)、進程描述符使用計數,被置為2時,表示進程描述符正在被使用而且其相應的進程處於活動狀態。 

[cpp] view plain copy
 
  1. atomic_t usage;  

    (3)、用於表示獲取大內核鎖的次數,如果進程未獲得過鎖,則置為-1。 

[cpp] view plain copy
 
  1. int lock_depth;     /* BKL lock depth */  

    (4)、在SMP上幫助實現無加鎖的進程切換(unlocked context switches) 

[cpp] view plain copy
 
  1. #ifdef CONFIG_SMP  
  2. #ifdef __ARCH_WANT_UNLOCKED_CTXSW  
  3.     int oncpu;  
  4. #endif  
  5. #endif  

    (5)、preempt_notifier結構體鏈表 

[cpp] view plain copy
 
  1. #ifdef CONFIG_PREEMPT_NOTIFIERS  
  2.     /* list of struct preempt_notifier: */  
  3.     struct hlist_head preempt_notifiers;  
  4. #endif  

    (6)、FPU使用計數 

[cpp] view plain copy
 
  1. unsigned char fpu_counter;  

    (7)、blktrace是一個針對Linux內核中塊設備I/O層的跟蹤工具。 

[cpp] view plain copy
 
  1. #ifdef CONFIG_BLK_DEV_IO_TRACE  
  2.     unsigned int btrace_seq;  
  3. #endif  

    (8)、RCU同步原語 

[cpp] view plain copy
 
  1. #ifdef CONFIG_PREEMPT_RCU  
  2.     int rcu_read_lock_nesting;  
  3.     char rcu_read_unlock_special;  
  4.     struct list_head rcu_node_entry;  
  5. #endif /* #ifdef CONFIG_PREEMPT_RCU */  
  6. #ifdef CONFIG_TREE_PREEMPT_RCU  
  7.     struct rcu_node *rcu_blocked_node;  
  8. #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */  
  9. #ifdef CONFIG_RCU_BOOST  
  10.     struct rt_mutex *rcu_boost_mutex;  
  11. #endif /* #ifdef CONFIG_RCU_BOOST */  

    (9)、用於調度器統計進程的運行信息 

[cpp] view plain copy
 
  1. #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)  
  2.     struct sched_info sched_info;  
  3. #endif  

    (10)、用於構建進程鏈表 

[cpp] view plain copy
 
  1. struct list_head tasks;  

    (11)、to limit pushing to one attempt 

[cpp] view plain copy
 
  1. #ifdef CONFIG_SMP  
  2.     struct plist_node pushable_tasks;  
  3. #endif  

        (12)、防止內核堆棧溢出 

[cpp] view plain copy
 
  1. #ifdef CONFIG_CC_STACKPROTECTOR  
  2.     /* Canary value for the -fstack-protector gcc feature */  
  3.     unsigned long stack_canary;  
  4. #endif  

    在GCC編譯內核時,需要加上-fstack-protector選項。

    (13)、PID散列表和鏈表 

[cpp] view plain copy
 
  1. /* PID/PID hash table linkage. */  
  2. struct pid_link pids[PIDTYPE_MAX];  
  3. struct list_head thread_group; //線程組中所有進程的鏈表  

    (14)、do_fork函數 

[cpp] view plain copy
 
  1. struct completion *vfork_done;      /* for vfork() */  
  2. int __user *set_child_tid;      /* CLONE_CHILD_SETTID */  
  3. int __user *clear_child_tid;        /* CLONE_CHILD_CLEARTID */  

    在執行do_fork()時,如果給定特別標志,則vfork_done會指向一個特殊地址。

    如果copy_process函數的clone_flags參數的值被置為CLONE_CHILD_SETTID或 CLONE_CHILD_CLEARTID,則會把child_tidptr參數的值分別復制到set_child_tid和 clear_child_tid成員。這些標志說明必須改變子進程用戶態地址空間的child_tidptr所指向的變量的值。

    (15)、缺頁統計 

[cpp] view plain copy
 
  1. /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */  
  2.     unsigned long min_flt, maj_flt;  

    (16)、進程權能 

[cpp] view plain copy
 
  1. const struct cred __rcu *real_cred; /* objective and real subjective task 
  2.                  * credentials (COW) */  
  3. const struct cred __rcu *cred;  /* effective (overridable) subjective task 
  4.                  * credentials (COW) */  
  5. struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */  

    (17)、相應的程序名 

[cpp] view plain copy
 
  1. char comm[TASK_COMM_LEN];  

    (18)、文件 

[cpp] view plain copy
 
  1. /* file system info */  
  2.     int link_count, total_link_count;  
  3. /* filesystem information */  
  4.     struct fs_struct *fs;  
  5. /* open file information */  
  6.     struct files_struct *files;  

    fs用來表示進程與文件系統的聯系,包括當前目錄和根目錄。

    files表示進程當前打開的文件。

    (19)、進程通信(SYSVIPC) 

[cpp] view plain copy
 
  1. #ifdef CONFIG_SYSVIPC  
  2. /* ipc stuff */  
  3.     struct sysv_sem sysvsem;  
  4. #endif  

    (20)、處理器特有數據 

[cpp] view plain copy
 
  1. /* CPU-specific state of this task */  
  2.     struct thread_struct thread;  

    (21)、命名空間 

[cpp] view plain copy
 
  1. /* namespaces */  
  2.     struct nsproxy *nsproxy;  

    (22)、進程審計 

  1.     struct audit_context *audit_context;  
  2. #ifdef CONFIG_AUDITSYSCALL  
  3.     uid_t loginuid;  
  4.     unsigned int sessionid;  
  5. #endif  

    (23)、secure computing 

  1. seccomp_t seccomp;  

    (24)、用於copy_process函數使用CLONE_PARENT 標記時 

  1. /* Thread group tracking */  
  2.     u32 parent_exec_id;  
  3.     u32 self_exec_id;  

    (25)、中斷 

  1. #ifdef CONFIG_GENERIC_HARDIRQS  
  2.     /* IRQ handler threads */  
  3.     struct irqaction *irqaction;  
  4. #endif  
  5. #ifdef CONFIG_TRACE_IRQFLAGS  
  6.     unsigned int irq_events;  
  7.     unsigned long hardirq_enable_ip;  
  8.     unsigned long hardirq_disable_ip;  
  9.     unsigned int hardirq_enable_event;  
  10.     unsigned int hardirq_disable_event;  
  11.     int hardirqs_enabled;  
  12.     int hardirq_context;  
  13.     unsigned long softirq_disable_ip;  
  14.     unsigned long softirq_enable_ip;  
  15.     unsigned int softirq_disable_event;  
  16.     unsigned int softirq_enable_event;  
  17.     int softirqs_enabled;  
  18.     int softirq_context;  
  19. #endif  

    (26)、task_rq_lock函數所使用的鎖 

  1. /* Protection of the PI data structures: */  
  2. raw_spinlock_t pi_lock;  

    (27)、基於PI協議的等待互斥鎖,其中PI指的是priority inheritance(優先級繼承) 

  1. #ifdef CONFIG_RT_MUTEXES  
  2.     /* PI waiters blocked on a rt_mutex held by this task */  
  3.     struct plist_head pi_waiters;  
  4.     /* Deadlock detection and priority inheritance handling */  
  5.     struct rt_mutex_waiter *pi_blocked_on;  
  6. #endif  

    (28)、死鎖檢測 

  1. #ifdef CONFIG_DEBUG_MUTEXES  
  2.     /* mutex deadlock detection */  
  3.     struct mutex_waiter *blocked_on;  
  4. #endif  

    (29)、lockdep,參見內核說明文檔linux-2.6.38.8/Documentation/lockdep-design.txt 

  1. #ifdef CONFIG_LOCKDEP  
  2. # define MAX_LOCK_DEPTH 48UL  
  3.     u64 curr_chain_key;  
  4.     int lockdep_depth;  
  5.     unsigned int lockdep_recursion;  
  6.     struct held_lock held_locks[MAX_LOCK_DEPTH];  
  7.     gfp_t lockdep_reclaim_gfp;  
  8. #endif  

    (30)、JFS文件系統 

  1. /* journalling filesystem info */  
  2.     void *journal_info;  

    (31)、塊設備鏈表 

  1. /* stacked block device info */  
  2.     struct bio_list *bio_list;  

    (32)、內存回收 

  1. struct reclaim_state *reclaim_state;  

    (33)、存放塊設備I/O數據流量信息

  1. struct backing_dev_info *backing_dev_info;  

    (34)、I/O調度器所使用的信息 

  1. struct io_context *io_context;  

    (35)、記錄進程的I/O計數 

  1. struct task_io_accounting ioac;  
  2. if defined(CONFIG_TASK_XACCT)  
  3. u64 acct_rss_mem1;  /* accumulated rss usage */  
  4. u64 acct_vm_mem1;   /* accumulated virtual memory usage */  
  5. cputime_t acct_timexpd; /* stime + utime since last update */  
  6. endif  

    在Ubuntu 11.04上,執行cat獲得進程1的I/O計數如下: 

  1. $ sudo cat /proc/1/io  
  1. rchar: 164258906  
  2. wchar: 455212837  
  3. syscr: 388847  
  4. syscw: 92563  
  5. read_bytes: 439251968  
  6. write_bytes: 14143488  
  7. cancelled_write_bytes: 2134016  

    輸出的數據項剛好是task_io_accounting結構體的所有成員。

    (36)、CPUSET功能 

  1. #ifdef CONFIG_CPUSETS  
  2.     nodemask_t mems_allowed;    /* Protected by alloc_lock */  
  3.     int mems_allowed_change_disable;  
  4.     int cpuset_mem_spread_rotor;  
  5.     int cpuset_slab_spread_rotor;  
  6. #endif  

    (37)、Control Groups 

  1. #ifdef CONFIG_CGROUPS  
  2.     /* Control Group info protected by css_set_lock */  
  3.     struct css_set __rcu *cgroups;  
  4.     /* cg_list protected by css_set_lock and tsk->alloc_lock */  
  5.     struct list_head cg_list;  
  6. #endif  
  7. #ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */  
  8.     struct memcg_batch_info {  
  9.         int do_batch;   /* incremented when batch uncharge started */  
  10.         struct mem_cgroup *memcg; /* target memcg of uncharge */  
  11.         unsigned long bytes;        /* uncharged usage */  
  12.         unsigned long memsw_bytes; /* uncharged mem+swap usage */  
  13.     } memcg_batch;  
  14. #endif  

    (38)、futex同步機制 

  1. #ifdef CONFIG_FUTEX  
  2.     struct robust_list_head __user *robust_list;  
  3. #ifdef CONFIG_COMPAT  
  4.     struct compat_robust_list_head __user *compat_robust_list;  
  5. #endif  
  6.     struct list_head pi_state_list;  
  7.     struct futex_pi_state *pi_state_cache;  
  8. #endif  

    (39)、非一致內存訪問(NUMA  Non-Uniform Memory Access) 

  1. #ifdef CONFIG_NUMA  
  2.     struct mempolicy *mempolicy;    /* Protected by alloc_lock */  
  3.     short il_next;  
  4. #endif  

    (40)、文件系統互斥資源 

  1. atomic_t fs_excl;   /* holding fs exclusive resources */  

    (41)、RCU鏈表 

  1. struct rcu_head rcu;  

    (42)、管道 

  1. struct pipe_inode_info *splice_pipe;  

    (43)、延遲計數 

  1. #ifdef  CONFIG_TASK_DELAY_ACCT  
  2.     struct task_delay_info *delays;  
  3. #endif  

    (44)、fault injection

[cpp] view plain copy

 

  1. #ifdef CONFIG_FAULT_INJECTION  
  2.     int make_it_fail;  
  3. #endif  

    (45)、FLoating proportions 

  1. struct prop_local_single dirties;  

    (46)、Infrastructure for displayinglatency 

  1. #ifdef CONFIG_LATENCYTOP  
  2.     int latency_record_count;  
  3.     struct latency_record latency_record[LT_SAVECOUNT];  
  4. #endif  

    (47)、time slack values,常用於poll和select函數 

  1. unsigned long timer_slack_ns;  
  2. unsigned long default_timer_slack_ns;  

    (48)、socket控制消息(control message) 

  1. struct list_head    *scm_work_list;  

    (49)、ftrace跟蹤器 

  1. #ifdef CONFIG_FUNCTION_GRAPH_TRACER  
  2.     /* Index of current stored address in ret_stack */  
  3.     int curr_ret_stack;  
  4.     /* Stack of return addresses for return function tracing */  
  5.     struct ftrace_ret_stack *ret_stack;  
  6.     /* time stamp for last schedule */  
  7.     unsigned long long ftrace_timestamp;  
  8.     /* 
  9.      * Number of functions that haven't been traced 
  10.      * because of depth overrun. 
  11.      */  
  12.     atomic_t trace_overrun;  
  13.     /* Pause for the tracing */  
  14.     atomic_t tracing_graph_pause;  
  15. #endif  
  16. #ifdef CONFIG_TRACING  
  17.     /* state flags for use by tracers */  
  18.     unsigned long trace;  
  19.     /* bitmask of trace recursion */  
  20.     unsigned long trace_recursion;  
  21. #endif /* CONFIG_TRACING */  

    9、進程地址空間 

    [cpp] view plain copy
     
    1.     struct mm_struct *mm, *active_mm;  
    2. #ifdef CONFIG_COMPAT_BRK  
    3.     unsigned brk_randomized:1;  
    4. #endif  
    5. #if defined(SPLIT_RSS_COUNTING)  
    6.     struct task_rss_stat    rss_stat;  
    7. #endif  

        mm指向進程所擁有的內存描述符,而active_mm指向進程運行時所使用的內存描述符。對於普通進程而言,這兩個指針變量的值相同。但是,內核線程不擁有任何內存描述符,所以它們的mm成員總是為NULL。當內核線程得以運行時,它的active_mm成員被初始化為前一個運行進程的 active_mm值。

           rss_stat用來記錄緩沖信息。 

        10、判斷標志 

    [cpp] view plain copy
     
    1. int exit_code, exit_signal;  
    2. int pdeath_signal;  /*  The signal sent when the parent dies  */  
    3. /* ??? */  
    4. unsigned int personality;  
    5. unsigned did_exec:1;  
    6. unsigned in_execve:1;   /* Tell the LSMs that the process is doing an 
    7.              * execve */  
    8. unsigned in_iowait:1;  
    9.   
    10.   
    11. /* Revert to default priority/policy when forking */  
    12. unsigned sched_reset_on_fork:1;  

        exit_code用於設置進程的終止代號,這個值要么是_exit()或exit_group()系統調用參數(正常終止),要么是由內核提供的一個錯誤代號(異常終止)。

        exit_signal被置為-1時表示是某個線程組中的一員。只有當線程組的最后一個成員終止時,才會產生一個信號,以通知線程組的領頭進程的父進程。

        pdeath_signal用於判斷父進程終止時發送信號。

        personality用於處理不同的ABI,它的可能取值如下: 

    [cpp] view plain copy
     
    1. enum {  
    2.     PER_LINUX =     0x0000,  
    3.     PER_LINUX_32BIT =   0x0000 | ADDR_LIMIT_32BIT,  
    4.     PER_LINUX_FDPIC =   0x0000 | FDPIC_FUNCPTRS,  
    5.     PER_SVR4 =      0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,  
    6.     PER_SVR3 =      0x0002 | STICKY_TIMEOUTS | SHORT_INODE,  
    7.     PER_SCOSVR3 =       0x0003 | STICKY_TIMEOUTS |  
    8.                      WHOLE_SECONDS | SHORT_INODE,  
    9.     PER_OSR5 =      0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,  
    10.     PER_WYSEV386 =      0x0004 | STICKY_TIMEOUTS | SHORT_INODE,  
    11.     PER_ISCR4 =     0x0005 | STICKY_TIMEOUTS,  
    12.     PER_BSD =       0x0006,  
    13.     PER_SUNOS =     0x0006 | STICKY_TIMEOUTS,  
    14.     PER_XENIX =     0x0007 | STICKY_TIMEOUTS | SHORT_INODE,  
    15.     PER_LINUX32 =       0x0008,  
    16.     PER_LINUX32_3GB =   0x0008 | ADDR_LIMIT_3GB,  
    17.     PER_IRIX32 =        0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */  
    18.     PER_IRIXN32 =       0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */  
    19.     PER_IRIX64 =        0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */  
    20.     PER_RISCOS =        0x000c,  
    21.     PER_SOLARIS =       0x000d | STICKY_TIMEOUTS,  
    22.     PER_UW7 =       0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,  
    23.     PER_OSF4 =      0x000f,          /* OSF/1 v4 */  
    24.     PER_HPUX =      0x0010,  
    25.     PER_MASK =      0x00ff,  
    26. };  

        did_exec用於記錄進程代碼是否被execve()函數所執行。

        in_execve用於通知LSM是否被do_execve()函數所調用。

  22.     in_iowait用於判斷是否進行iowait計數。

        sched_reset_on_fork用於判斷是否恢復默認的優先級或調度策略。

        11、時間 

    [cpp] view plain copy
     
    1.     cputime_t utime, stime, utimescaled, stimescaled;  
    2.     cputime_t gtime;  
    3. #ifndef CONFIG_VIRT_CPU_ACCOUNTING  
    4.     cputime_t prev_utime, prev_stime;  
    5. #endif  
    6.     unsigned long nvcsw, nivcsw; /* context switch counts */  
    7.     struct timespec start_time;         /* monotonic time */  
    8.     struct timespec real_start_time;    /* boot based time */  
    9.     struct task_cputime cputime_expires;  
    10.     struct list_head cpu_timers[3];  
    11. #ifdef CONFIG_DETECT_HUNG_TASK  
    12. /* hung task detection */  
    13.     unsigned long last_switch_count;  
    14. #endif  

        utime/stime用於記錄進程在用戶態/內核態下所經過的節拍數(定時器)。

  23.     utimescaled/stimescaled也是用於記錄進程在用戶態/內核態的運行時間,但它們以處理器的頻率為刻度。

        gtime是以節拍計數的虛擬機運行時間(guest time)。

        nvcsw/nivcsw是自願(voluntary)/非自願(involuntary)上下文切換計數。last_switch_count是nvcsw和nivcsw的總和。

        start_time和real_start_time都是進程創建時間,real_start_time還包含了進程睡眠時間,常用於/proc/pid/stat,補丁說明請參考http://lkml.indiana.edu/hypermail/linux/kernel/0705.0/2094.html

        cputime_expires用來統計進程或進程組被跟蹤的處理器時間,其中的三個成員對應着cpu_timers[3]的三個鏈表。

        12、信號處理 

    [cpp] view plain copy
     
    1. /* signal handlers */  
    2.     struct signal_struct *signal;  
    3.     struct sighand_struct *sighand;  
    4.   
    5.     sigset_t blocked, real_blocked;  
    6.     sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */  
    7.     struct sigpending pending;  
    8.   
    9.     unsigned long sas_ss_sp;  
    10.     size_t sas_ss_size;  
    11.     int (*notifier)(void *priv);  
    12.     void *notifier_data;  
    13.     sigset_t *notifier_mask;  

        signal指向進程的信號描述符。

        sighand指向進程的信號處理程序描述符。

        blocked表示被阻塞信號的掩碼,real_blocked表示臨時掩碼。

        pending存放私有掛起信號的數據結構

        sas_ss_sp是信號處理程序備用堆棧的地址,sas_ss_size表示堆棧的大小。

        設備驅動程序常用notifier指向的函數來阻塞進程的某些信號(notifier_mask是這些信號的位掩碼),notifier_data指的是notifier所指向的函數可能使用的數據。

        13、其他

        (1)、用於保護資源分配或釋放的自旋鎖 

    [cpp] view plain copy
     
    1. /* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed, 
    2.  * mempolicy */  
    3.     spinlock_t alloc_lock;  

        (2)、進程描述符使用計數,被置為2時,表示進程描述符正在被使用而且其相應的進程處於活動狀態。 

    [cpp] view plain copy
     
    1. atomic_t usage;  

        (3)、用於表示獲取大內核鎖的次數,如果進程未獲得過鎖,則置為-1。 

    [cpp] view plain copy
     
    1. int lock_depth;     /* BKL lock depth */  

        (4)、在SMP上幫助實現無加鎖的進程切換(unlocked context switches) 

    [cpp] view plain copy
     
    1. #ifdef CONFIG_SMP  
    2. #ifdef __ARCH_WANT_UNLOCKED_CTXSW  
    3.     int oncpu;  
    4. #endif  
    5. #endif  

        (5)、preempt_notifier結構體鏈表 

    [cpp] view plain copy
     
    1. #ifdef CONFIG_PREEMPT_NOTIFIERS  
    2.     /* list of struct preempt_notifier: */  
    3.     struct hlist_head preempt_notifiers;  
    4. #endif  

        (6)、FPU使用計數 

    [cpp] view plain copy
     
    1. unsigned char fpu_counter;  

        (7)、blktrace是一個針對Linux內核中塊設備I/O層的跟蹤工具。 

    [cpp] view plain copy
     
    1. #ifdef CONFIG_BLK_DEV_IO_TRACE  
    2.     unsigned int btrace_seq;  
    3. #endif  

        (8)、RCU同步原語 

    [cpp] view plain copy
     
    1. #ifdef CONFIG_PREEMPT_RCU  
    2.     int rcu_read_lock_nesting;  
    3.     char rcu_read_unlock_special;  
    4.     struct list_head rcu_node_entry;  
    5. #endif /* #ifdef CONFIG_PREEMPT_RCU */  
    6. #ifdef CONFIG_TREE_PREEMPT_RCU  
    7.     struct rcu_node *rcu_blocked_node;  
    8. #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */  
    9. #ifdef CONFIG_RCU_BOOST  
    10.     struct rt_mutex *rcu_boost_mutex;  
    11. #endif /* #ifdef CONFIG_RCU_BOOST */  

        (9)、用於調度器統計進程的運行信息 

    [cpp] view plain copy
     
    1. #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)  
    2.     struct sched_info sched_info;  
    3. #endif  

        (10)、用於構建進程鏈表 

    [cpp] view plain copy
     
    1. struct list_head tasks;  

        (11)、to limit pushing to one attempt 

    [cpp] view plain copy
     
    1. #ifdef CONFIG_SMP  
    2.     struct plist_node pushable_tasks;  
    3. #endif  

        補丁說明請參考:http://lkml.indiana.edu/hypermail/linux/kernel/0808.3/0503.html

        (12)、防止內核堆棧溢出 

    [cpp] view plain copy
     
    1. #ifdef CONFIG_CC_STACKPROTECTOR  
    2.     /* Canary value for the -fstack-protector gcc feature */  
    3.     unsigned long stack_canary;  
    4. #endif  

        在GCC編譯內核時,需要加上-fstack-protector選項。

        (13)、PID散列表和鏈表 

    [cpp] view plain copy
     
    1. /* PID/PID hash table linkage. */  
    2. struct pid_link pids[PIDTYPE_MAX];  
    3. struct list_head thread_group; //線程組中所有進程的鏈表  

        (14)、do_fork函數 

    [cpp] view plain copy
     
    1. struct completion *vfork_done;      /* for vfork() */  
    2. int __user *set_child_tid;      /* CLONE_CHILD_SETTID */  
    3. int __user *clear_child_tid;        /* CLONE_CHILD_CLEARTID */  

        在執行do_fork()時,如果給定特別標志,則vfork_done會指向一個特殊地址。

        如果copy_process函數的clone_flags參數的值被置為CLONE_CHILD_SETTID或 CLONE_CHILD_CLEARTID,則會把child_tidptr參數的值分別復制到set_child_tid和 clear_child_tid成員。這些標志說明必須改變子進程用戶態地址空間的child_tidptr所指向的變量的值。

        (15)、缺頁統計 

    [cpp] view plain copy
     
    1. /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */  
    2.     unsigned long min_flt, maj_flt;  

        (16)、進程權能 

    [cpp] view plain copy
     
    1. const struct cred __rcu *real_cred; /* objective and real subjective task 
    2.                  * credentials (COW) */  
    3. const struct cred __rcu *cred;  /* effective (overridable) subjective task 
    4.                  * credentials (COW) */  
    5. struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */  

        (17)、相應的程序名 

    [cpp] view plain copy
     
    1. char comm[TASK_COMM_LEN];  

        (18)、文件 

    [cpp] view plain copy
     
    1. /* file system info */  
    2.     int link_count, total_link_count;  
    3. /* filesystem information */  
    4.     struct fs_struct *fs;  
    5. /* open file information */  
    6.     struct files_struct *files;  

        fs用來表示進程與文件系統的聯系,包括當前目錄和根目錄。

        files表示進程當前打開的文件。

        (19)、進程通信(SYSVIPC) 

    [cpp] view plain copy
     
    1. #ifdef CONFIG_SYSVIPC  
    2. /* ipc stuff */  
    3.     struct sysv_sem sysvsem;  
    4. #endif  

        (20)、處理器特有數據 

    [cpp] view plain copy
     
    1. /* CPU-specific state of this task */  
    2.     struct thread_struct thread;  

        (21)、命名空間 

    [cpp] view plain copy
     
    1. /* namespaces */  
    2.     struct nsproxy *nsproxy;  

        (22)、進程審計 

    [cpp] view plain copy
     
    1.     struct audit_context *audit_context;  
    2. #ifdef CONFIG_AUDITSYSCALL  
    3.     uid_t loginuid;  
    4.     unsigned int sessionid;  
    5. #endif  

        (23)、secure computing 

    1. seccomp_t seccomp;  

        (24)、用於copy_process函數使用CLONE_PARENT 標記時 

    1. /* Thread group tracking */  
    2.     u32 parent_exec_id;  
    3.     u32 self_exec_id;  

        (25)、中斷 

    1. #ifdef CONFIG_GENERIC_HARDIRQS  
    2.     /* IRQ handler threads */  
    3.     struct irqaction *irqaction;  
    4. #endif  
    5. #ifdef CONFIG_TRACE_IRQFLAGS  
    6.     unsigned int irq_events;  
    7.     unsigned long hardirq_enable_ip;  
    8.     unsigned long hardirq_disable_ip;  
    9.     unsigned int hardirq_enable_event;  
    10.     unsigned int hardirq_disable_event;  
    11.     int hardirqs_enabled;  
    12.     int hardirq_context;  
    13.     unsigned long softirq_disable_ip;  
    14.     unsigned long softirq_enable_ip;  
    15.     unsigned int softirq_disable_event;  
    16.     unsigned int softirq_enable_event;  
    17.     int softirqs_enabled;  
    18.     int softirq_context;  
    19. #endif  

        (26)、task_rq_lock函數所使用的鎖 

    1. /* Protection of the PI data structures: */  
    2. raw_spinlock_t pi_lock;  

        (27)、基於PI協議的等待互斥鎖,其中PI指的是priority inheritance(優先級繼承) 

    1. #ifdef CONFIG_RT_MUTEXES  
    2.     /* PI waiters blocked on a rt_mutex held by this task */  
    3.     struct plist_head pi_waiters;  
    4.     /* Deadlock detection and priority inheritance handling */  
    5.     struct rt_mutex_waiter *pi_blocked_on;  
    6. #endif  

        (28)、死鎖檢測 

    1. #ifdef CONFIG_DEBUG_MUTEXES  
    2.     /* mutex deadlock detection */  
    3.     struct mutex_waiter *blocked_on;  
    4. #endif  

        (29)、lockdep,參見內核說明文檔linux-2.6.38.8/Documentation/lockdep-design.txt 

    1. #ifdef CONFIG_LOCKDEP  
    2. # define MAX_LOCK_DEPTH 48UL  
    3.     u64 curr_chain_key;  
    4.     int lockdep_depth;  
    5.     unsigned int lockdep_recursion;  
    6.     struct held_lock held_locks[MAX_LOCK_DEPTH];  
    7.     gfp_t lockdep_reclaim_gfp;  
    8. #endif  

        (30)、JFS文件系統 

    1. /* journalling filesystem info */  
    2.     void *journal_info;  

        (31)、塊設備鏈表 

    1. /* stacked block device info */  
    2.     struct bio_list *bio_list;  

        (32)、內存回收 

    1. struct reclaim_state *reclaim_state;  

        (33)、存放塊設備I/O數據流量信息

    1. struct backing_dev_info *backing_dev_info;  
        (34)、I/O調度器所使用的信息 
    1. struct io_context *io_context;  

        (35)、記錄進程的I/O計數 

    1. struct task_io_accounting ioac;  
    2. if defined(CONFIG_TASK_XACCT)  
    3. u64 acct_rss_mem1;  /* accumulated rss usage */  
    4. u64 acct_vm_mem1;   /* accumulated virtual memory usage */  
    5. cputime_t acct_timexpd; /* stime + utime since last update */  
    6. endif  

        在Ubuntu 11.04上,執行cat獲得進程1的I/O計數如下: 

    1. $ sudo cat /proc/1/io  
    1. rchar: 164258906  
    2. wchar: 455212837  
    3. syscr: 388847  
    4. syscw: 92563  
    5. read_bytes: 439251968  
    6. write_bytes: 14143488  
    7. cancelled_write_bytes: 2134016  

        輸出的數據項剛好是task_io_accounting結構體的所有成員。

        (36)、CPUSET功能 

    1. #ifdef CONFIG_CPUSETS  
    2.     nodemask_t mems_allowed;    /* Protected by alloc_lock */  
    3.     int mems_allowed_change_disable;  
    4.     int cpuset_mem_spread_rotor;  
    5.     int cpuset_slab_spread_rotor;  
    6. #endif  

        (37)、Control Groups 

    1. #ifdef CONFIG_CGROUPS  
    2.     /* Control Group info protected by css_set_lock */  
    3.     struct css_set __rcu *cgroups;  
    4.     /* cg_list protected by css_set_lock and tsk->alloc_lock */  
    5.     struct list_head cg_list;  
    6. #endif  
    7. #ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */  
    8.     struct memcg_batch_info {  
    9.         int do_batch;   /* incremented when batch uncharge started */  
    10.         struct mem_cgroup *memcg; /* target memcg of uncharge */  
    11.         unsigned long bytes;        /* uncharged usage */  
    12.         unsigned long memsw_bytes; /* uncharged mem+swap usage */  
    13.     } memcg_batch;  
    14. #endif  

        (38)、futex同步機制 

    1. #ifdef CONFIG_FUTEX  
    2.     struct robust_list_head __user *robust_list;  
    3. #ifdef CONFIG_COMPAT  
    4.     struct compat_robust_list_head __user *compat_robust_list;  
    5. #endif  
    6.     struct list_head pi_state_list;  
    7.     struct futex_pi_state *pi_state_cache;  
    8. #endif  

        (39)、非一致內存訪問(NUMA  Non-Uniform Memory Access) 

    1. #ifdef CONFIG_NUMA  
    2.     struct mempolicy *mempolicy;    /* Protected by alloc_lock */  
    3.     short il_next;  
    4. #endif  

        (40)、文件系統互斥資源 

    1. atomic_t fs_excl;   /* holding fs exclusive resources */  

        (41)、RCU鏈表 

    1. struct rcu_head rcu;  

        (42)、管道 

    1. struct pipe_inode_info *splice_pipe;  

        (43)、延遲計數 

    1. #ifdef  CONFIG_TASK_DELAY_ACCT  
    2.     struct task_delay_info *delays;  
    3. #endif  

        (44)、fault injection,參考內核說明文件linux-2.6.38.8/Documentation/fault-injection/fault-injection.txt 

    1. #ifdef CONFIG_FAULT_INJECTION  
    2.     int make_it_fail;  
    3. #endif  

        (45)、FLoating proportions 

    1. struct prop_local_single dirties;  

        (46)、Infrastructure for displayinglatency 

    1. #ifdef CONFIG_LATENCYTOP  
    2.     int latency_record_count;  
    3.     struct latency_record latency_record[LT_SAVECOUNT];  
    4. #endif  

        (47)、time slack values,常用於poll和select函數 

    1. unsigned long timer_slack_ns;  
    2. unsigned long default_timer_slack_ns;  

        (48)、socket控制消息(control message) 

    1. struct list_head    *scm_work_list;  

        (49)、ftrace跟蹤器 

    1. #ifdef CONFIG_FUNCTION_GRAPH_TRACER  
    2.     /* Index of current stored address in ret_stack */  
    3.     int curr_ret_stack;  
    4.     /* Stack of return addresses for return function tracing */  
    5.     struct ftrace_ret_stack *ret_stack;  
    6.     /* time stamp for last schedule */  
    7.     unsigned long long ftrace_timestamp;  
    8.     /* 
    9.      * Number of functions that haven't been traced 
    10.      * because of depth overrun. 
    11.      */  
    12.     atomic_t trace_overrun;  
    13.     /* Pause for the tracing */  
    14.     atomic_t tracing_graph_pause;  
    15. #endif  
    16. #ifdef CONFIG_TRACING  
    17.     /* state flags for use by tracers */  
    18.     unsigned long trace;  
    19.     /* bitmask of trace recursion */  
    20.     unsigned long trace_recursion;  
    21. #endif /* CONFIG_TRACING */  

  9、進程地址空間 

[cpp] view plain copy
 
  1.     struct mm_struct *mm, *active_mm;  
  2. #ifdef CONFIG_COMPAT_BRK  
  3.     unsigned brk_randomized:1;  
  4. #endif  
  5. #if defined(SPLIT_RSS_COUNTING)  
  6.     struct task_rss_stat    rss_stat;  
  7. #endif  

    mm指向進程所擁有的內存描述符,而active_mm指向進程運行時所使用的內存描述符。對於普通進程而言,這兩個指針變量的值相同。但是,內核線程不擁有任何內存描述符,所以它們的mm成員總是為NULL。當內核線程得以運行時,它的active_mm成員被初始化為前一個運行進程的 active_mm值。

    brk_randomized的用法在http://lkml.indiana.edu/hypermail/linux/kernel/1104.1/00196.html上有介紹,用來確定對隨機堆內存的探測。

    rss_stat用來記錄緩沖信息。 

    10、判斷標志 

[cpp] view plain copy
 
  1. int exit_code, exit_signal;  
  2. int pdeath_signal;  /*  The signal sent when the parent dies  */  
  3. /* ??? */  
  4. unsigned int personality;  
  5. unsigned did_exec:1;  
  6. unsigned in_execve:1;   /* Tell the LSMs that the process is doing an 
  7.              * execve */  
  8. unsigned in_iowait:1;  
  9.   
  10.   
  11. /* Revert to default priority/policy when forking */  
  12. unsigned sched_reset_on_fork:1;  

    exit_code用於設置進程的終止代號,這個值要么是_exit()或exit_group()系統調用參數(正常終止),要么是由內核提供的一個錯誤代號(異常終止)。

    exit_signal被置為-1時表示是某個線程組中的一員。只有當線程組的最后一個成員終止時,才會產生一個信號,以通知線程組的領頭進程的父進程。

    pdeath_signal用於判斷父進程終止時發送信號。

    personality用於處理不同的ABI,它的可能取值如下: 

[cpp] view plain copy
 
  1. enum {  
  2.     PER_LINUX =     0x0000,  
  3.     PER_LINUX_32BIT =   0x0000 | ADDR_LIMIT_32BIT,  
  4.     PER_LINUX_FDPIC =   0x0000 | FDPIC_FUNCPTRS,  
  5.     PER_SVR4 =      0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,  
  6.     PER_SVR3 =      0x0002 | STICKY_TIMEOUTS | SHORT_INODE,  
  7.     PER_SCOSVR3 =       0x0003 | STICKY_TIMEOUTS |  
  8.                      WHOLE_SECONDS | SHORT_INODE,  
  9.     PER_OSR5 =      0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS,  
  10.     PER_WYSEV386 =      0x0004 | STICKY_TIMEOUTS | SHORT_INODE,  
  11.     PER_ISCR4 =     0x0005 | STICKY_TIMEOUTS,  
  12.     PER_BSD =       0x0006,  
  13.     PER_SUNOS =     0x0006 | STICKY_TIMEOUTS,  
  14.     PER_XENIX =     0x0007 | STICKY_TIMEOUTS | SHORT_INODE,  
  15.     PER_LINUX32 =       0x0008,  
  16.     PER_LINUX32_3GB =   0x0008 | ADDR_LIMIT_3GB,  
  17.     PER_IRIX32 =        0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */  
  18.     PER_IRIXN32 =       0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */  
  19.     PER_IRIX64 =        0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */  
  20.     PER_RISCOS =        0x000c,  
  21.     PER_SOLARIS =       0x000d | STICKY_TIMEOUTS,  
  22.     PER_UW7 =       0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO,  
  23.     PER_OSF4 =      0x000f,          /* OSF/1 v4 */  
  24.     PER_HPUX =      0x0010,  
  25.     PER_MASK =      0x00ff,  
  26. };  

    did_exec用於記錄進程代碼是否被execve()函數所執行。

    in_execve用於通知LSM是否被do_execve()函數所調用。詳見補丁說明:http://lkml.indiana.edu/hypermail/linux/kernel/0901.1/00014.html

    in_iowait用於判斷是否進行iowait計數。

    sched_reset_on_fork用於判斷是否恢復默認的優先級或調度策略。

    11、時間 

[cpp] view plain copy
 
  1.     cputime_t utime, stime, utimescaled, stimescaled;  
  2.     cputime_t gtime;  
  3. #ifndef CONFIG_VIRT_CPU_ACCOUNTING  
  4.     cputime_t prev_utime, prev_stime;  
  5. #endif  
  6.     unsigned long nvcsw, nivcsw; /* context switch counts */  
  7.     struct timespec start_time;         /* monotonic time */  
  8.     struct timespec real_start_time;    /* boot based time */  
  9.     struct task_cputime cputime_expires;  
  10.     struct list_head cpu_timers[3];  
  11. #ifdef CONFIG_DETECT_HUNG_TASK  
  12. /* hung task detection */  
  13.     unsigned long last_switch_count;  
  14. #endif  

    utime/stime用於記錄進程在用戶態/內核態下所經過的節拍數(定時器)。prev_utime/prev_stime是先前的運行時間,請參考補丁說明http://lkml.indiana.edu/hypermail/linux/kernel/1003.3/02431.html

    utimescaled/stimescaled也是用於記錄進程在用戶態/內核態的運行時間,但它們以處理器的頻率為刻度。

    gtime是以節拍計數的虛擬機運行時間(guest time)。

    nvcsw/nivcsw是自願(voluntary)/非自願(involuntary)上下文切換計數。last_switch_count是nvcsw和nivcsw的總和。

    start_time和real_start_time都是進程創建時間,real_start_time還包含了進程睡眠時間,常用於/proc/pid/stat,補丁說明請參考http://lkml.indiana.edu/hypermail/linux/kernel/0705.0/2094.html

    cputime_expires用來統計進程或進程組被跟蹤的處理器時間,其中的三個成員對應着cpu_timers[3]的三個鏈表。

    12、信號處理 

[cpp] view plain copy
 
  1. /* signal handlers */  
  2.     struct signal_struct *signal;  
  3.     struct sighand_struct *sighand;  
  4.   
  5.     sigset_t blocked, real_blocked;  
  6.     sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */  
  7.     struct sigpending pending;  
  8.   
  9.     unsigned long sas_ss_sp;  
  10.     size_t sas_ss_size;  
  11.     int (*notifier)(void *priv);  
  12.     void *notifier_data;  
  13.     sigset_t *notifier_mask;  

    signal指向進程的信號描述符。

    sighand指向進程的信號處理程序描述符。

    blocked表示被阻塞信號的掩碼,real_blocked表示臨時掩碼。

    pending存放私有掛起信號的數據結構

    sas_ss_sp是信號處理程序備用堆棧的地址,sas_ss_size表示堆棧的大小。

    設備驅動程序常用notifier指向的函數來阻塞進程的某些信號(notifier_mask是這些信號的位掩碼),notifier_data指的是notifier所指向的函數可能使用的數據。

    13、其他

    (1)、用於保護資源分配或釋放的自旋鎖 

[cpp] view plain copy
 
  1. /* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed, 
  2.  * mempolicy */  
  3.     spinlock_t alloc_lock;  

    (2)、進程描述符使用計數,被置為2時,表示進程描述符正在被使用而且其相應的進程處於活動狀態。 

[cpp] view plain copy
 
  1. atomic_t usage;  

    (3)、用於表示獲取大內核鎖的次數,如果進程未獲得過鎖,則置為-1。 

[cpp] view plain copy
 
  1. int lock_depth;     /* BKL lock depth */  

    (4)、在SMP上幫助實現無加鎖的進程切換(unlocked context switches) 

[cpp] view plain copy
 
  1. #ifdef CONFIG_SMP  
  2. #ifdef __ARCH_WANT_UNLOCKED_CTXSW  
  3.     int oncpu;  
  4. #endif  
  5. #endif  

    (5)、preempt_notifier結構體鏈表 

[cpp] view plain copy
 
  1. #ifdef CONFIG_PREEMPT_NOTIFIERS  
  2.     /* list of struct preempt_notifier: */  
  3.     struct hlist_head preempt_notifiers;  
  4. #endif  

    (6)、FPU使用計數 

[cpp] view plain copy
 
  1. unsigned char fpu_counter;  

    (7)、blktrace是一個針對Linux內核中塊設備I/O層的跟蹤工具。 

[cpp] view plain copy
 
  1. #ifdef CONFIG_BLK_DEV_IO_TRACE  
  2.     unsigned int btrace_seq;  
  3. #endif  

    (8)、RCU同步原語 

[cpp] view plain copy
 
  1. #ifdef CONFIG_PREEMPT_RCU  
  2.     int rcu_read_lock_nesting;  
  3.     char rcu_read_unlock_special;  
  4.     struct list_head rcu_node_entry;  
  5. #endif /* #ifdef CONFIG_PREEMPT_RCU */  
  6. #ifdef CONFIG_TREE_PREEMPT_RCU  
  7.     struct rcu_node *rcu_blocked_node;  
  8. #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */  
  9. #ifdef CONFIG_RCU_BOOST  
  10.     struct rt_mutex *rcu_boost_mutex;  
  11. #endif /* #ifdef CONFIG_RCU_BOOST */  

    (9)、用於調度器統計進程的運行信息 

[cpp] view plain copy
 
  1. #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)  
  2.     struct sched_info sched_info;  
  3. #endif  

    (10)、用於構建進程鏈表 

[cpp] view plain copy
 
  1. struct list_head tasks;  

    (11)、to limit pushing to one attempt 

[cpp] view plain copy
 
  1. #ifdef CONFIG_SMP  
  2.     struct plist_node pushable_tasks;  
  3. #endif  

    補丁說明請參考:http://lkml.indiana.edu/hypermail/linux/kernel/0808.3/0503.html

    (12)、防止內核堆棧溢出 

[cpp] view plain copy
 
  1. #ifdef CONFIG_CC_STACKPROTECTOR  
  2.     /* Canary value for the -fstack-protector gcc feature */  
  3.     unsigned long stack_canary;  
  4. #endif  

    在GCC編譯內核時,需要加上-fstack-protector選項。

    (13)、PID散列表和鏈表 

[cpp] view plain copy
 
  1. /* PID/PID hash table linkage. */  
  2. struct pid_link pids[PIDTYPE_MAX];  
  3. struct list_head thread_group; //線程組中所有進程的鏈表  

    (14)、do_fork函數 

[cpp] view plain copy
 
  1. struct completion *vfork_done;      /* for vfork() */  
  2. int __user *set_child_tid;      /* CLONE_CHILD_SETTID */  
  3. int __user *clear_child_tid;        /* CLONE_CHILD_CLEARTID */  

    在執行do_fork()時,如果給定特別標志,則vfork_done會指向一個特殊地址。

    如果copy_process函數的clone_flags參數的值被置為CLONE_CHILD_SETTID或 CLONE_CHILD_CLEARTID,則會把child_tidptr參數的值分別復制到set_child_tid和 clear_child_tid成員。這些標志說明必須改變子進程用戶態地址空間的child_tidptr所指向的變量的值。

    (15)、缺頁統計 

[cpp] view plain copy
 
  1. /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */  
  2.     unsigned long min_flt, maj_flt;  

    (16)、進程權能 

[cpp] view plain copy
 
  1. const struct cred __rcu *real_cred; /* objective and real subjective task 
  2.                  * credentials (COW) */  
  3. const struct cred __rcu *cred;  /* effective (overridable) subjective task 
  4.                  * credentials (COW) */  
  5. struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */  

    (17)、相應的程序名 

[cpp] view plain copy
 
  1. char comm[TASK_COMM_LEN];  

    (18)、文件 

[cpp] view plain copy
 
  1. /* file system info */  
  2.     int link_count, total_link_count;  
  3. /* filesystem information */  
  4.     struct fs_struct *fs;  
  5. /* open file information */  
  6.     struct files_struct *files;  

    fs用來表示進程與文件系統的聯系,包括當前目錄和根目錄。

    files表示進程當前打開的文件。

    (19)、進程通信(SYSVIPC) 

[cpp] view plain copy
 
  1. #ifdef CONFIG_SYSVIPC  
  2. /* ipc stuff */  
  3.     struct sysv_sem sysvsem;  
  4. #endif  

    (20)、處理器特有數據 

[cpp] view plain copy
 
  1. /* CPU-specific state of this task */  
  2.     struct thread_struct thread;  

    (21)、命名空間 

[cpp] view plain copy
 
  1. /* namespaces */  
  2.     struct nsproxy *nsproxy;  

    (22)、進程審計 

[cpp] view plain copy
 
  1.     struct audit_context *audit_context;  
  2. #ifdef CONFIG_AUDITSYSCALL  
  3.     uid_t loginuid;  
  4.     unsigned int sessionid;  
  5. #endif  

    (23)、secure computing 

  1. seccomp_t seccomp;  

    (24)、用於copy_process函數使用CLONE_PARENT 標記時 

  1. /* Thread group tracking */  
  2.     u32 parent_exec_id;  
  3.     u32 self_exec_id;  

    (25)、中斷 

  1. #ifdef CONFIG_GENERIC_HARDIRQS  
  2.     /* IRQ handler threads */  
  3.     struct irqaction *irqaction;  
  4. #endif  
  5. #ifdef CONFIG_TRACE_IRQFLAGS  
  6.     unsigned int irq_events;  
  7.     unsigned long hardirq_enable_ip;  
  8.     unsigned long hardirq_disable_ip;  
  9.     unsigned int hardirq_enable_event;  
  10.     unsigned int hardirq_disable_event;  
  11.     int hardirqs_enabled;  
  12.     int hardirq_context;  
  13.     unsigned long softirq_disable_ip;  
  14.     unsigned long softirq_enable_ip;  
  15.     unsigned int softirq_disable_event;  
  16.     unsigned int softirq_enable_event;  
  17.     int softirqs_enabled;  
  18.     int softirq_context;  
  19. #endif  

    (26)、task_rq_lock函數所使用的鎖 

  1. /* Protection of the PI data structures: */  
  2. raw_spinlock_t pi_lock;  

    (27)、基於PI協議的等待互斥鎖,其中PI指的是priority inheritance(優先級繼承) 

  1. #ifdef CONFIG_RT_MUTEXES  
  2.     /* PI waiters blocked on a rt_mutex held by this task */  
  3.     struct plist_head pi_waiters;  
  4.     /* Deadlock detection and priority inheritance handling */  
  5.     struct rt_mutex_waiter *pi_blocked_on;  
  6. #endif  

    (28)、死鎖檢測 

  1. #ifdef CONFIG_DEBUG_MUTEXES  
  2.     /* mutex deadlock detection */  
  3.     struct mutex_waiter *blocked_on;  
  4. #endif  

    (29)、lockdep,參見內核說明文檔linux-2.6.38.8/Documentation/lockdep-design.txt 

  1. #ifdef CONFIG_LOCKDEP  
  2. # define MAX_LOCK_DEPTH 48UL  
  3.     u64 curr_chain_key;  
  4.     int lockdep_depth;  
  5.     unsigned int lockdep_recursion;  
  6.     struct held_lock held_locks[MAX_LOCK_DEPTH];  
  7.     gfp_t lockdep_reclaim_gfp;  
  8. #endif  

    (30)、JFS文件系統 

  1. /* journalling filesystem info */  
  2.     void *journal_info;  

    (31)、塊設備鏈表 

  1. /* stacked block device info */  
  2.     struct bio_list *bio_list;  

    (32)、內存回收 

  1. struct reclaim_state *reclaim_state;  

    (33)、存放塊設備I/O數據流量信息

  1. struct backing_dev_info *backing_dev_info;  

    (34)、I/O調度器所使用的信息 

  1. struct io_context *io_context;  

    (35)、記錄進程的I/O計數 

  1. struct task_io_accounting ioac;  
  2. if defined(CONFIG_TASK_XACCT)  
  3. u64 acct_rss_mem1;  /* accumulated rss usage */  
  4. u64 acct_vm_mem1;   /* accumulated virtual memory usage */  
  5. cputime_t acct_timexpd; /* stime + utime since last update */  
  6. endif  

    在Ubuntu 11.04上,執行cat獲得進程1的I/O計數如下: 

  1. $ sudo cat /proc/1/io  
  1. rchar: 164258906  
  2. wchar: 455212837  
  3. syscr: 388847  
  4. syscw: 92563  
  5. read_bytes: 439251968  
  6. write_bytes: 14143488  
  7. cancelled_write_bytes: 2134016  

    輸出的數據項剛好是task_io_accounting結構體的所有成員。

    (36)、CPUSET功能 

  1. #ifdef CONFIG_CPUSETS  
  2.     nodemask_t mems_allowed;    /* Protected by alloc_lock */  
  3.     int mems_allowed_change_disable;  
  4.     int cpuset_mem_spread_rotor;  
  5.     int cpuset_slab_spread_rotor;  
  6. #endif  

    (37)、Control Groups 

  1. #ifdef CONFIG_CGROUPS  
  2.     /* Control Group info protected by css_set_lock */  
  3.     struct css_set __rcu *cgroups;  
  4.     /* cg_list protected by css_set_lock and tsk->alloc_lock */  
  5.     struct list_head cg_list;  
  6. #endif  
  7. #ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */  
  8.     struct memcg_batch_info {  
  9.         int do_batch;   /* incremented when batch uncharge started */  
  10.         struct mem_cgroup *memcg; /* target memcg of uncharge */  
  11.         unsigned long bytes;        /* uncharged usage */  
  12.         unsigned long memsw_bytes; /* uncharged mem+swap usage */  
  13.     } memcg_batch;  
  14. #endif  

    (38)、futex同步機制 

  1. #ifdef CONFIG_FUTEX  
  2.     struct robust_list_head __user *robust_list;  
  3. #ifdef CONFIG_COMPAT  
  4.     struct compat_robust_list_head __user *compat_robust_list;  
  5. #endif  
  6.     struct list_head pi_state_list;  
  7.     struct futex_pi_state *pi_state_cache;  
  8. #endif  

    (39)、非一致內存訪問(NUMA  Non-Uniform Memory Access) 

  1. #ifdef CONFIG_NUMA  
  2.     struct mempolicy *mempolicy;    /* Protected by alloc_lock */  
  3.     short il_next;  
  4. #endif  

    (40)、文件系統互斥資源 

  1. atomic_t fs_excl;   /* holding fs exclusive resources */  

    (41)、RCU鏈表 

  1. struct rcu_head rcu;  

    (42)、管道 

  1. struct pipe_inode_info *splice_pipe;  

    (43)、延遲計數 

  1. #ifdef  CONFIG_TASK_DELAY_ACCT  
  2.     struct task_delay_info *delays;  
  3. #endif  

    (44)、fault injection,參考內核說明文件linux-2.6.38.8/Documentation/fault-injection/fault-injection.txt 

  1. #ifdef CONFIG_FAULT_INJECTION  
  2.     int make_it_fail;  
  3. #endif  

    (45)、FLoating proportions 

  1. struct prop_local_single dirties;  

    (46)、Infrastructure for displayinglatency 

  1. #ifdef CONFIG_LATENCYTOP  
  2.     int latency_record_count;  
  3.     struct latency_record latency_record[LT_SAVECOUNT];  
  4. #endif  

    (47)、time slack values,常用於poll和select函數 

  1. unsigned long timer_slack_ns;  
  2. unsigned long default_timer_slack_ns;  

    (48)、socket控制消息(control message) 

  1. struct list_head    *scm_work_list;  

    (49)、ftrace跟蹤器 

  1. #ifdef CONFIG_FUNCTION_GRAPH_TRACER  
  2.     /* Index of current stored address in ret_stack */  
  3.     int curr_ret_stack;  
  4.     /* Stack of return addresses for return function tracing */  
  5.     struct ftrace_ret_stack *ret_stack;  
  6.     /* time stamp for last schedule */  
  7.     unsigned long long ftrace_timestamp;  
  8.     /* 
  9.      * Number of functions that haven't been traced 
  10.      * because of depth overrun. 
  11.      */  
  12.     atomic_t trace_overrun;  
  13.     /* Pause for the tracing */  
  14.     atomic_t tracing_graph_pause;  
  15. #endif  
  16. #ifdef CONFIG_TRACING  
  17.     /* state flags for use by tracers */  
  18.     unsigned long trace;  
  19.     /* bitmask of trace recursion */  
  20.     unsigned long trace_recursion;  
  21. #endif /* CONFIG_TRACING */  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM