亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2416 | 回復(fù): 2
打印 上一主題 下一主題

io accounting 的問題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-12-17 09:31 |只看該作者 |倒序?yàn)g覽
和內(nèi)核沾點(diǎn)邊,來這里求助了,

我想在用戶層分別得到使用磁盤,cpu最高的幾個(gè)進(jìn)程(或者進(jìn)程組), 不知道該如何實(shí)現(xiàn),
linux下有個(gè)iotop能以類似top(1)的形式顯示進(jìn)程的I/O利用情況,但是那個(gè)軟件是python寫的,我讀起來很(非常)吃力,
他大致是先在從proc讀到進(jìn)程列表,然后又讀了 /proc/xxpid/status, 然后用netlink獲得某些進(jìn)程的taskstats

不清楚從proc pid status下他想讀什么,貌似是讀進(jìn)程的uid,gid之類的東東



  1. // /usr/include/linux/taskstats.h

  2. struct taskstats {

  3. ...
  4.         __u8        ac_flag;                /* Record flags */
  5.         __u8        ac_nice;                /* task_nice */

  6.         __u64        cpu_count __attribute__((aligned(8)));
  7.         __u64        cpu_delay_total;

  8.         /* Following four fields atomically updated using task->delays->lock */

  9.         /* Delay waiting for synchronous block I/O to complete
  10.          * does not account for delays in I/O submission
  11.          */
  12.         __u64        blkio_count;
  13.         __u64        blkio_delay_total;

  14.         /* Delay waiting for page fault I/O (swap in only) */
  15.         __u64        swapin_count;
  16.         __u64        swapin_delay_total;

  17.         /* cpu "wall-clock" running time
  18.          * On some architectures, value will adjust for cpu time stolen
  19.          * from the kernel in involuntary waits due to virtualization.
  20.          * Value is cumulative, in nanoseconds, without a corresponding count
  21.          * and wraps around to zero silently on overflow
  22.          */
  23.         __u64        cpu_run_real_total;

  24.         /* cpu "virtual" running time
  25.          * Uses time intervals seen by the kernel i.e. no adjustment
  26.          * for kernel's involuntary waits due to virtualization.
  27.          * Value is cumulative, in nanoseconds, without a corresponding count
  28.          * and wraps around to zero silently on overflow
  29.          */
  30.         __u64        cpu_run_virtual_total;
  31.         /* Delay accounting fields end */
  32.         /* version 1 ends here */

  33.         /* Basic Accounting Fields start */
  34.         char        ac_comm[TS_COMM_LEN];        /* Command name */
  35.         __u8        ac_sched __attribute__((aligned(8)));
  36.                                         /* Scheduling discipline */
  37.         __u8        ac_pad[3];
  38.         __u32        ac_uid __attribute__((aligned(8)));
  39.                                         /* User ID */
  40.         __u32        ac_gid;                        /* Group ID */
  41.         __u32        ac_pid;                        /* Process ID */
  42.         __u32        ac_ppid;                /* Parent process ID */
  43.         __u32        ac_btime;                /* Begin time [sec since 1970] */
  44.         __u64        ac_etime __attribute__((aligned(8)));
  45.                                         /* Elapsed time [usec] */
  46.         __u64        ac_utime;                /* User CPU time [usec] */
  47.         __u64        ac_stime;                /* SYstem CPU time [usec] */
  48.         __u64        ac_minflt;                /* Minor Page Fault Count */
  49.         __u64        ac_majflt;                /* Major Page Fault Count */
  50. ...

  51.         /* The following four fields are I/O statistics of a task. */
  52.         __u64        read_char;                /* bytes read */
  53.         __u64        write_char;                /* bytes written */
  54.         __u64        read_syscalls;                /* read syscalls */
  55.         __u64        write_syscalls;                /* write syscalls */
  56.         /* Extended accounting fields end */

  57. #define TASKSTATS_HAS_IO_ACCOUNTING
  58.         /* Per-task storage I/O accounting starts */
  59.         __u64        read_bytes;                /* bytes of read I/O */
  60.         __u64        write_bytes;                /* bytes of write I/O */
  61.         __u64        cancelled_write_bytes;        /* bytes of cancelled write I/O */

  62.         __u64  nvcsw;                        /* voluntary_ctxt_switches */
  63.         __u64  nivcsw;                        /* nonvoluntary_ctxt_switches */

  64.         /* time accounting for SMT machines */
  65.         __u64        ac_utimescaled;                /* utime scaled on frequency etc */
  66.         __u64        ac_stimescaled;                /* stime scaled on frequency etc */
  67.         __u64        cpu_scaled_run_real_total; /* scaled cpu_run_real_total */
  68. };

復(fù)制代碼


貌似和磁盤io有關(guān)的是


  1. #define TASKSTATS_HAS_IO_ACCOUNTING
  2.         /* Per-task storage I/O accounting starts */
  3.         __u64        read_bytes;                /* bytes of read I/O */
  4.         __u64        write_bytes;                /* bytes of write I/O */
  5.         __u64        cancelled_write_bytes;        /* bytes of cancelled write I/O */           這個(gè)如何理解呢???
復(fù)制代碼


cancelled_write_bytes是怎么一回事?
另外和cpu利用率有關(guān)的是哪些成員? 最后說的SMT又是什么意思呢?


要是想得到利用率的話是不是需要讀取兩次相減再除以時(shí)間間隔?還是有什么別的直接的辦法?
這里面講的task和process的區(qū)別是什么呢? task帶表進(jìn)程組 process帶表進(jìn)程?
另外再請(qǐng)問有沒有除proc外的其他接口直接獲得所有進(jìn)程號(hào)的呢?


問了好多問題,希望大家不吝賜教
謝謝!


http://kernelnewbies.org/Linux_2 ... ed22c281ca9ab54bb12

IO Accounting

The present per-task IO accounting isn't very useful. It simply counts the number of bytes passed into read() and write(). So if a process reads 1MB from an already-cached file, it is accused of having performed 1MB of I/O, which is 'wrong'. So this IO accounting implements per-process statistics of "storage I/O" (i.e.: I/O that _really_ does I/O on the storage device - Linux already had I/O storage statistics but it's not per-task). The data is reported through taskstats and procfs (/proc/$PID/io) (commit 1, 2, 3, 4, 5, 6, 7, 8, 10, 11)

最后一句話說的proc/$id/io是說的新的io accountting還是前面說的present per-task IO accounting ?
如果是新的的話就可以直接讀proc下的pid下的io了,比netlink更方便, 不知道效率上是不是會(huì)比netlink差

論壇徽章:
36
IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-04-10 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-04-16 06:20:0015-16賽季CBA聯(lián)賽之廣東
日期:2016-04-16 19:59:32IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-04-18 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-04-19 06:20:00每日論壇發(fā)貼之星
日期:2016-04-19 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-04-25 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-05-06 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-05-08 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-05-13 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-05-28 06:20:00每日論壇發(fā)貼之星
日期:2016-05-28 06:20:00
2 [報(bào)告]
發(fā)表于 2008-12-17 09:49 |只看該作者
如果單說讀出進(jìn)程CPU的利用率,應(yīng)該ps就可以實(shí)現(xiàn)吧。

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-12-17 09:53 |只看該作者
還有磁盤io,不想用shell實(shí)現(xiàn)
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP