Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2182086
  • 博文数量: 141
  • 博客积分: 3552
  • 博客等级: 中校
  • 技术积分: 4148
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-15 14:39
个人简介

熟悉Linux下程序设计及各种应用程序 熟悉C Language 熟悉Glusterfs、FFmpeg、CDN 系统设计,计算机图形系统设计、分布式程序设计 目前主要研究方向:流媒体

文章分类

全部博文(141)

分类: LINUX

2009-12-20 23:26:16

[root@localhost ~]# cat /proc/sched_debug
Sched Debug Version: v0.09, 2.6.33-rc1 #1
now at 18954381.354499 msecs
  .jiffies : 18654381
  .sysctl_sched_latency : 10.000000
  .sysctl_sched_min_granularity : 2.000000
  .sysctl_sched_wakeup_granularity : 2.000000
  .sysctl_sched_child_runs_first : 0.000000
  .sysctl_sched_features : 7917179
  .sysctl_sched_tunable_scaling : 1 (logaritmic)

cpu#0, 2260.658 MHz
  .nr_running : 1
  .load : 1024
  .nr_switches : 30642518
  .nr_load_updates : 17494240
  .nr_uninterruptible : 32
  .next_balance : 18.654624
  .curr->pid : 30069
  .clock : 18954381.122310
  .cpu_load[0] : 1024
  .cpu_load[1] : 980
  .cpu_load[2] : 831
  .cpu_load[3] : 618
  .cpu_load[4] : 419
  .yld_count : 10407
  .sched_switch : 0
  .sched_count : 31645668
  .sched_goidle : 10461420
  .avg_idle : 1000000
  .ttwu_count : 17520447
  .ttwu_local : 12576491
  .bkl_count : 353989

cfs_rq[0]:/
  .exec_clock : 5324597.435447
  .MIN_vruntime : 0.000001
  .min_vruntime : 4449136.507675
  .max_vruntime : 0.000001
  .spread : 0.000000
  .spread0 : 0.000000
  .nr_running : 1
  .load : 1024
  .nr_spread_over : 130
  .shares : 0

rt_rq[0]:
  .rt_nr_running : 0
  .rt_throttled : 0
  .rt_time : 0.000000
  .rt_runtime : 950.000000

runnable tasks:
            task PID tree-key switches prio exec-runtime sum-exec sum-sleep
----------------------------------------------------------------------------------------------------------
R cat 30069 4449136.588425 4 120 4449136.588425 3.309490 0.000000 /

cpu#1, 2260.658 MHz
  .nr_running : 0
  .load : 0
  .nr_switches : 31281602
  .nr_load_updates : 17541385
  .nr_uninterruptible : 4294967264
  .next_balance : 18.654631
  .curr->pid : 0
  .clock : 18954381.165173
  .cpu_load[0] : 0
  .cpu_load[1] : 205
  .cpu_load[2] : 398
  .cpu_load[3] : 477
  .cpu_load[4] : 440
  .yld_count : 9577
  .sched_switch : 0
  .sched_count : 32195174
  .sched_goidle : 10541507
  .avg_idle : 850020
  .ttwu_count : 17852365
  .ttwu_local : 12937809
  .bkl_count : 347894

cfs_rq[1]:/
  .exec_clock : 5318544.561997
  .MIN_vruntime : 0.000001
  .min_vruntime : 4390944.446853
  .max_vruntime : 0.000001
  .spread : 0.000000
  .spread0 : -58192.060822
  .nr_running : 0
  .load : 0
  .nr_spread_over : 102
  .shares : 0

rt_rq[1]:
  .rt_nr_running : 0
  .rt_throttled : 0
  .rt_time : 0.011098
  .rt_runtime : 950.000000

runnable tasks:
            task PID tree-key switches prio exec-runtime sum-exec sum-sleep
----------------------------------------------------------------------------------------------------------

[root@localhost ~]#

以上信息,在kernel代码中可以看到,


static const struct pid_entry tgid_base_stuff[] = {
    DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
    DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
    DIR("fdinfo", S_IRUSR|S_IXUSR, proc_fdinfo_inode_operations, proc_fdinfo_operations),
#ifdef CONFIG_NET
    DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
#endif
    REG("environ", S_IRUSR, proc_environ_operations),
    INF("auxv", S_IRUSR, proc_pid_auxv),
    ONE("status", S_IRUGO, proc_pid_status),
    ONE("personality", S_IRUSR, proc_pid_personality),
    INF("limits", S_IRUSR, proc_pid_limits),
#ifdef CONFIG_SCHED_DEBUG
    REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
#endif
    REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
    INF("syscall", S_IRUSR, proc_pid_syscall),
#endif
    INF("cmdline", S_IRUGO, proc_pid_cmdline),
    ONE("stat", S_IRUGO, proc_tgid_stat),
    ONE("statm", S_IRUGO, proc_pid_statm),
    REG("maps", S_IRUGO, proc_maps_operations),
#ifdef CONFIG_NUMA
    REG("numa_maps", S_IRUGO, proc_numa_maps_operations),
#endif
    REG("mem", S_IRUSR|S_IWUSR, proc_mem_operations),
    LNK("cwd", proc_cwd_link),
    LNK("root", proc_root_link),
    LNK("exe", proc_exe_link),
    REG("mounts", S_IRUGO, proc_mounts_operations),
    REG("mountinfo", S_IRUGO, proc_mountinfo_operations),
    REG("mountstats", S_IRUSR, proc_mountstats_operations),
#ifdef CONFIG_PROC_PAGE_MONITOR
    REG("clear_refs", S_IWUSR, proc_clear_refs_operations),
   REG("smaps", S_IRUGO, proc_smaps_operations),
    REG("pagemap", S_IRUSR, proc_pagemap_operations),
#endif
#ifdef CONFIG_SECURITY
    DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
#endif
#ifdef CONFIG_KALLSYMS
    INF("wchan", S_IRUGO, proc_pid_wchan),
#endif
#ifdef CONFIG_STACKTRACE
    ONE("stack", S_IRUSR, proc_pid_stack),
#endif
#ifdef CONFIG_SCHEDSTATS
    INF("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
    REG("latency", S_IRUGO, proc_lstats_operations),
#endif
#ifdef CONFIG_PROC_PID_CPUSET
    REG("cpuset", S_IRUGO, proc_cpuset_operations),
#endif
#ifdef CONFIG_CGROUPS
    REG("cgroup", S_IRUGO, proc_cgroup_operations),
#endif
    INF("oom_score", S_IRUGO, proc_oom_score),
    REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
#ifdef CONFIG_AUDITSYSCALL
    REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
    REG("sessionid", S_IRUGO, proc_sessionid_operations),
#endif
#ifdef CONFIG_FAULT_INJECTION
    REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations),
#endif
#ifdef CONFIG_ELF_CORE
    REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations),
#endif
#ifdef CONFIG_TASK_IO_ACCOUNTING
    INF("io", S_IRUGO, proc_tgid_io_accounting),
#endif
};

打印sched的相关信息

static const struct file_operations proc_pid_sched_operations = {
    .open = sched_open,
    .read = seq_read,
    .write = sched_write,
    .llseek = seq_lseek,
    .release = single_release,
};

和写驱动的流程差不多,这个也有file_operations
进sched_open瞄一眼

static int sched_open(struct inode *inode, struct file *filp)
{
    int ret;

    ret = single_open(filp, sched_show, NULL);
    if (!ret) {
        struct seq_file *m = filp->private_data;

        m->private = inode;
    }
    return ret;
}

然后就看到了

static int sched_show(struct seq_file *m, void *v)
{
    struct inode *inode = m->private;
    struct task_struct *p;

    p = get_proc_task(inode);
    if (!p)
        return -ESRCH;
    proc_sched_show_task(p, m);

    put_task_struct(p);

    return 0;
}

信息就打印在/proc/sched_debug中了
创建proc中的文件在

static int __init init_sched_debug_procfs(void)
{
    struct proc_dir_entry *pe;

    pe = proc_create("sched_debug", 0444, NULL, &sched_debug_fops);
    if (!pe)
        return -ENOMEM;
    return 0;
}



阅读(5687) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-01-08 01:44:16

代码不全