커널 번역(기사,문서)

[번역] scheduler/sched-stats.txt

iamyooon 2018. 8. 3. 17:48

schedstats version 15에서는 sched_yield의 yld_exp_empty, yld_act_empty, yld_both_empty 카운터를 제거했다. 그 외의 내용은 버전 14와 같다.

Version 15 of schedstats dropped counters for some sched_yield: yld_exp_empty, yld_act_empty and yld_both_empty. Otherwise, it is identical to version 14.


schedstats 버전 14에는 kernel 2.6.20에 추가된 sched_domains에 대한 지원이 추가됐다.  나머지 내용은 kernel 2.6.13 - 2.6.19 kernel에 있었던 version 12와 동일하다.(버전13은 커널에 릴리즈되지 않았다). 어떤 카운터는 런큐마다 존재하는게 더 적합하고 나머지는 도메인마다 존재하는게 적합하다. 또한 도메인과 관련된 정보는 CONFIG_SMP를 사용하는 머신에서만 사용가능하다.

Version 14 of schedstats includes support for sched_domains, which hit the mainline kernel in 2.6.20 although it is identical to the stats from version 12 which was in the kernel from 2.6.13-2.6.19 (version 13 never saw a kernel release). Some counters make more sense to be per-runqueue; other to be per-domain. Note that domains (and their associated information) will only be pertinent and available on machines utilizing CONFIG_SMP.


schedstat 버전 14에서는, 각 cpu 마다 최소 한 레벨의 도메인 통계가 존재한다. 그리고 (아마도) 하나 이상의 도메인이 존재할 것이다. 현재 구현에서 도메인이 별도의 이름을 가지지는 않는다. domain0가 가장 도메인에 tightly focused되어있는 반면에 제일 높은 번호의 도메인은 보통 머신의 모든 CPU간의 로드밸런싱을 중재한다. 때때로 로드밸런싱은 오직 cpu pair들 사이에서만 발생한다. 현재 3레벨 이상의 도메인을 가진 아키텍쳐는 존재하지 않는다. 도메인 통계의 첫 필드는 해당 도메인에 속해 있는 cpu목록을 나타내는 bitmap이다.

In version 14 of schedstat, there is at least one level of domain statistics for each cpu listed, and there may well be more than one domain. Domains have no particular names in this implementation, but the highest numbered one typically arbitrates balancing across all the cpus on the machine, while domain0 is the most tightly focused domain, sometimes balancing only between pairs of cpus. At this time, there are no architectures which need more than three domain levels. The first field in the domain stats is a bit map indicating which cpus are affected by that domain.


필드들은 모두 값이 증가하기만 하는 카운터이다. 이 카운터를 사용할 프로그램들은 특정 값에서 관측을 시작하고 카운터가 얼마나 증가했는지를 매 관측시마다 계산해야 한다. 이런식으로 많은 카운터에 대해 동작하는 펄 스크립트는 아래 경로에서 찾을 수 있다.

These fields are counters, and only increment. Programs which make use of these will need to start with a baseline observation and then calculate the change in the counters at each subsequent observation. A perl script which does this for many of the fields is available at


http://eaglet.rain.com/rick/linux/schedstat/

버전이 바뀌는 주 원인은 출력 형태의 변화이기 때문에 이런 류의 스크립트는 version-specific할 필요가 있다. 버전별 스크립트를 작성하기 위해, 각 필드들에 대한 설명을 여기에 실었다.

Note that any such script will necessarily be version-specific, as the main reason to change versions is changes in the output format. For those wishing to write their own scripts, the fields are described here.


CPU 통계정보(CPU statistics)

cpu<N> 1 2 3 4 5 6 7 8 9

첫 필드는 sched_yield()의 통계이다.

1) # sched_yield()가 호출된 횟수

First field is a sched_yield() statistic:

1) # of times sched_yield() was called


다음 세 필드는 schedule()의 통계이다.

2) O(1) 스케쥴러가 사용했던 legacy array expiration count횟수,  ABI 호환을 위해 유지하고 있지만 항상 0으로 설정되어 있음

3) schedule()이 호출된 횟수

4) cpu를 idle 상태에서 깨우면서 schedule()이 호출된 횟수

Next three are schedule() statistics:

2) This field is a legacy array expiration count field used in the O(1) scheduler. We kept it for ABI compatibility, but it is always set to zero.

3) # of times schedule() was called

4) # of times schedule() left the processor idle


다음 두 필드는 try_to_wake_up()에 대한 통계이다.

5) try_to_wake_up()이 호출된 횟수

6) try_to_wake_up()이 local cpu를 깨우기 위해 호출된 횟수

Next two are try_to_wake_up() statistics:

5) # of times try_to_wake_up() was called

6) # of times try_to_wake_up() was called to wake up the local cpu


다음 세 필드는 scheduling latency에 대한 통계이다:

7) 이 cpu에서 태스크를 실행한 모든 시간의 합(jiffies단위)

8) 이 cpu에서 태스크가 실행되기 위해 기다린 모든 시간의 합(jiffies단위)

9) 이 cpu에서 사용된 타임슬라이스의 합

Next three are statistics describing scheduling latency:

7) sum of all time spent running by tasks on this processor (in jiffies)

8) sum of all time spent waiting to run by tasks on this processor (in

jiffies)

9) # of timeslices run on this cpu


도메인 통계정보(Domain statistics)

아래 필드들은 CPU가 속한 도메인마다 하나씩 생성된다. 만약 CONFIG_SMP가 정의되어 있지 않다면, 도메인은 사용되지 않고 이 정보는 결과에 보이지 않는다.

One of these is produced per domain for each cpu described. (Note that if CONFIG_SMP is not defined, *no* domains are utilized and these lines will not appear in the output.)


domain<N> <cpumask> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

첫 필드는 이 도메인에서 동작하는 cpu 정보를 나타내는 비트맵이다. 다음 24개 필드는 load_balance() 통계에 대해서 idle 타입(idle, busy, newly idle)에 따라 나누어 나타낸다.

The first field is a bit mask indicating what cpus this domain operates over. The next 24 are a variety of load_balance() statistics in grouped into types  of idleness (idle, busy, and newly idle):


CPU가 idle 상태일 때의 통계정보

1) 이 도메인에 대해 load_balance()가 불린 횟수

2) 이 도메인에 대해 load_balance()가 불렸지만 로드밸런싱이 필요하지 않은 상황에 대한 횟수

3) 이 도메인에 대해 load_balance()가 불렸고 태스트 이동을 시도했으나 실패한 상황에 대한 횟수

4) 이 도메인에 대해 load_balance()가 매번 불렸을 때의 로드 불균형의 총합

5) 이 도메인에 대해 pull_task()가 호출된 횟수

6) 이 도메인에 대해 pull_task()가 불렸지만 태스크가 cache-hot이였던 횟수

7) 이 도메인에 대해 load_balance()가 불렸지만 바쁜 런큐를 찾지 못했던 횟수

8) 이 도메인에 대해 바쁜 런큐는 찾았지만 바쁜 그룹은 못 찾은 횟수

1) # of times in this domain load_balance() was called when the cpu was idle

2) # of times in this domain load_balance() checked but found the load did not require balancing when the cpu was idle

3) # of times in this domain load_balance() tried to move one or more tasks and failed, when the cpu was idle

4) sum of imbalances discovered (if any) with each call to load_balance() in this domain when the cpu was idle

5) # of times in this domain pull_task() was called when the cpu was idle

6) # of times in this domain pull_task() was called even though the target task was cache-hot when idle

7) # of times in this domain load_balance() was called but did not find a busier queue while the cpu was idle

8) # of times in this domain a busier queue was found while the cpu was idle but no busier group was found


CPU가 busy 상태일 때의 통계정보

9) 이 도메인에 대해 load_balance()가 불린 횟수

10) 이 도메인에 대해 load_balance()가 불렸지만 로드벨런싱이 필요하지 않은 상황에 대한 횟수

11) 이 도메인에 대해 load_balance()가 불렸고 태스트이동을 시도했으나 실패한 상황에 대한 횟수

12) 이 도메인에 대해 load_balance()가 매번 불렸을 때의 로드 불균형의 총합

13) 이 도메인에 대해 pull_task()가 호출된 횟수

14) 이 도메인에 대해 pull_task()가 불렸지만 태스크가 cache-hot이였던 횟수

15) 이 도메인에 대해 load_balance()가 불렸지만 바쁜 런큐를 찾지 못했던 횟수

16) 이 도메인에 대해 바쁜 런큐는 찾았지만 바쁜 그룹은 못 찾은 횟수

9) # of times in this domain load_balance() was called when the cpu was busy

10) # of times in this domain load_balance() checked but found the load did not require balancing when busy

11) # of times in this domain load_balance() tried to move one or more tasks and failed, when the cpu was busy

12) sum of imbalances discovered (if any) with each call to load_balance() in this domain when the cpu was busy

13) # of times in this domain pull_task() was called when busy

14) # of times in this domain pull_task() was called even though the target task was cache-hot when busy

15) # of times in this domain load_balance() was called but did not find a busier queue while the cpu was busy

16) # of times in this domain a busier queue was found while the cpu was busy but no busier group was found


CPU가 newly idle 상태일 때의 통계정보

17) 이 도메인에 대해 load_balance()가 불린 횟수

18) 이 도메인에 대해 load_balance()가 불렸지만 로드밸런싱이 필요하지 않은 상황에 대한 횟수

19) 이 도메인에 대해 load_balance()가 불렸고 태스트이동을 시도했으나 실패한 상황에 대한 횟수

20) 이 도메인에 대해 load_balance()가 매번 불렸을 때의 로드 불균형의 총합

21) 이 도메인에 대해 pull_task()가 호출된 횟수

22) 이 도메인에 대해 pull_task()가 불렸지만 태스크가 cache-hot이였던 횟수

23) 이 도메인에 대해 load_balance()가 불렸지만 바쁜 런큐를 찾지 못했던 횟수

24) 이 도메인에 대해 바쁜 런큐는 찾았지만 바쁜 그룹은 못 찾은 횟수

17) # of times in this domain load_balance() was called when the cpu was just becoming idle

18) # of times in this domain load_balance() checked but found the load did not require balancing when the cpu was just becoming idle

19) # of times in this domain load_balance() tried to move one or more tasks and failed, when the cpu was just becoming idle

20) sum of imbalances discovered (if any) with each call to load_balance() in this domain when the cpu was just becoming idle

21) # of times in this domain pull_task() was called when newly idle

22) # of times in this domain pull_task() was called even though the target task was cache-hot when just becoming idle

23) # of times in this domain load_balance() was called but did not find a busier queue while the cpu was just becoming idle

24) # of times in this domain a busier queue was found while the cpu was just becoming idle but no busier group was found


다음 세 필드는 active_load_balance()에 대한 통계를 나타낸다

25) active_load_balance()가 호출된 횟수

26) active_load_balance()가 태스크 이동에 실패한 횟수

27) active_load_balance()가 태스트 이동에 성공한 횟수

Next three are active_load_balance() statistics:

25) # of times active_load_balance() was called

26) # of times active_load_balance() tried to move a task and failed

27) # of times active_load_balance() successfully moved a task


다음 세 필드는 sched_balance_exec()에 대한 통계를 나타낸다.

28) sbe_cnt, 사용되지 않음

29) sbe_balanced, 사용되지 않음

30) sbe_pushed, 사용되지 않음

Next three are sched_balance_exec() statistics:

28) sbe_cnt is not used

29) sbe_balanced is not used

30) sbe_pushed is not used


다음 세 필드는 sched_balance_fork()에 대한 통계이다.

31) sbf_cnt, 사용되지 않음

32) sbf_balanced, 사용되지 않음

33) sbf_pushed, 사용되지 않음

Next three are sched_balance_fork() statistics:

31) sbf_cnt is not used

32) sbf_balanced is not used

33) sbf_pushed is not used


다음 세 필드는 try_to_wake_up()에 대한 통계이다.

34) try_to_wake_up()이 도메인의 다른 cpu에서 마지막으로 실행했던 태스크를 깨운횟수

35) try_to_wake_up()이 cache-cold인 태스크를 깨어나는 다른 CPU에게 이동시킨 횟수

36) try_to_wake_up()이 passive balancing을 시작한 횟수

Next three are try_to_wake_up() statistics:

34) # of times in this domain try_to_wake_up() awoke a task that last ran on a different cpu in this domain

35) # of times in this domain try_to_wake_up() moved a task to the waking cpu because it was cache-cold on its own cpu anyway

36) # of times in this domain try_to_wake_up() started passive balancing


/proc/<pid>/schedstat


schedstats는 프로세스 단위의 스케쥴링 정보를 포함하기 위해 새롭게 /proc/<pid>/schedstat 파일도 추가했다. 이 파일에는 관련된 프로세스에 대한 세가지 필드가 있다.

1) cpu에서 보낸 시간의 합

2) 런큐에서 기다린 시간의 합

3) 현재 cpu에서 사용한 timeslice의 합

schedstats also adds a new /proc/<pid>/schedstat file to include some of the same information on a per-process level. There are three fields in this file correlating for that process to:

1) time spent on the cpu

2) time spent waiting on a runqueue

3) # of timeslices run on this cpu


특정 프로세스나 프로세스 그룹이 스케쥴러의 정책 아래에서 어떻게 공평하게 실행되는지를 알기 위해 이런 필드들을 사용하도록 프로그램을 쉽게 짤 수 있다. 이런 프로그램의 간단한 버전은 아래에서 참고할 수 있다.

A program could be easily written to make use of these extra fields to report on how well a particular process or set of processes is faring under the scheduler's policies. A simple version of such a program is available at


http://eaglet.rain.com/rick/linux/schedstat/v12/latency.c