diff options
Diffstat (limited to 'kernel/sched.c')
| -rw-r--r-- | kernel/sched.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 089be8adb074..9b302e355791 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
| @@ -1908,6 +1908,55 @@ static void deactivate_task(struct rq *rq, struct task_struct *p, int flags) | |||
| 1908 | dec_nr_running(rq); | 1908 | dec_nr_running(rq); |
| 1909 | } | 1909 | } |
| 1910 | 1910 | ||
| 1911 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | ||
| 1912 | |||
| 1913 | static DEFINE_PER_CPU(u64, cpu_hardirq_time); | ||
| 1914 | static DEFINE_PER_CPU(u64, cpu_softirq_time); | ||
| 1915 | |||
| 1916 | static DEFINE_PER_CPU(u64, irq_start_time); | ||
| 1917 | static int sched_clock_irqtime; | ||
| 1918 | |||
| 1919 | void enable_sched_clock_irqtime(void) | ||
| 1920 | { | ||
| 1921 | sched_clock_irqtime = 1; | ||
| 1922 | } | ||
| 1923 | |||
| 1924 | void disable_sched_clock_irqtime(void) | ||
| 1925 | { | ||
| 1926 | sched_clock_irqtime = 0; | ||
| 1927 | } | ||
| 1928 | |||
| 1929 | void account_system_vtime(struct task_struct *curr) | ||
| 1930 | { | ||
| 1931 | unsigned long flags; | ||
| 1932 | int cpu; | ||
| 1933 | u64 now, delta; | ||
| 1934 | |||
| 1935 | if (!sched_clock_irqtime) | ||
| 1936 | return; | ||
| 1937 | |||
| 1938 | local_irq_save(flags); | ||
| 1939 | |||
| 1940 | now = sched_clock(); | ||
| 1941 | cpu = smp_processor_id(); | ||
| 1942 | delta = now - per_cpu(irq_start_time, cpu); | ||
| 1943 | per_cpu(irq_start_time, cpu) = now; | ||
| 1944 | /* | ||
| 1945 | * We do not account for softirq time from ksoftirqd here. | ||
| 1946 | * We want to continue accounting softirq time to ksoftirqd thread | ||
| 1947 | * in that case, so as not to confuse scheduler with a special task | ||
| 1948 | * that do not consume any time, but still wants to run. | ||
| 1949 | */ | ||
| 1950 | if (hardirq_count()) | ||
| 1951 | per_cpu(cpu_hardirq_time, cpu) += delta; | ||
| 1952 | else if (in_serving_softirq() && !(curr->flags & PF_KSOFTIRQD)) | ||
| 1953 | per_cpu(cpu_softirq_time, cpu) += delta; | ||
| 1954 | |||
| 1955 | local_irq_restore(flags); | ||
| 1956 | } | ||
| 1957 | |||
| 1958 | #endif | ||
| 1959 | |||
| 1911 | #include "sched_idletask.c" | 1960 | #include "sched_idletask.c" |
| 1912 | #include "sched_fair.c" | 1961 | #include "sched_fair.c" |
| 1913 | #include "sched_rt.c" | 1962 | #include "sched_rt.c" |
