aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/array.c53
-rw-r--r--kernel/sched.c27
2 files changed, 44 insertions, 36 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 9cbab7e93557..965625a0977d 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -62,6 +62,8 @@
62#include <linux/mman.h> 62#include <linux/mman.h>
63#include <linux/proc_fs.h> 63#include <linux/proc_fs.h>
64#include <linux/ioport.h> 64#include <linux/ioport.h>
65#include <linux/uaccess.h>
66#include <linux/io.h>
65#include <linux/mm.h> 67#include <linux/mm.h>
66#include <linux/hugetlb.h> 68#include <linux/hugetlb.h>
67#include <linux/pagemap.h> 69#include <linux/pagemap.h>
@@ -76,9 +78,7 @@
76#include <linux/rcupdate.h> 78#include <linux/rcupdate.h>
77#include <linux/delayacct.h> 79#include <linux/delayacct.h>
78 80
79#include <asm/uaccess.h>
80#include <asm/pgtable.h> 81#include <asm/pgtable.h>
81#include <asm/io.h>
82#include <asm/processor.h> 82#include <asm/processor.h>
83#include "internal.h" 83#include "internal.h"
84 84
@@ -87,10 +87,10 @@
87do { memcpy(buffer, string, strlen(string)); \ 87do { memcpy(buffer, string, strlen(string)); \
88 buffer += strlen(string); } while (0) 88 buffer += strlen(string); } while (0)
89 89
90static inline char * task_name(struct task_struct *p, char * buf) 90static inline char *task_name(struct task_struct *p, char *buf)
91{ 91{
92 int i; 92 int i;
93 char * name; 93 char *name;
94 char tcomm[sizeof(p->comm)]; 94 char tcomm[sizeof(p->comm)];
95 95
96 get_task_comm(tcomm, p); 96 get_task_comm(tcomm, p);
@@ -138,7 +138,7 @@ static const char *task_state_array[] = {
138 "X (dead)" /* 32 */ 138 "X (dead)" /* 32 */
139}; 139};
140 140
141static inline const char * get_task_state(struct task_struct *tsk) 141static inline const char *get_task_state(struct task_struct *tsk)
142{ 142{
143 unsigned int state = (tsk->state & (TASK_RUNNING | 143 unsigned int state = (tsk->state & (TASK_RUNNING |
144 TASK_INTERRUPTIBLE | 144 TASK_INTERRUPTIBLE |
@@ -156,7 +156,7 @@ static inline const char * get_task_state(struct task_struct *tsk)
156 return *p; 156 return *p;
157} 157}
158 158
159static inline char * task_state(struct task_struct *p, char *buffer) 159static inline char *task_state(struct task_struct *p, char *buffer)
160{ 160{
161 struct group_info *group_info; 161 struct group_info *group_info;
162 int g; 162 int g;
@@ -172,8 +172,8 @@ static inline char * task_state(struct task_struct *p, char *buffer)
172 "Uid:\t%d\t%d\t%d\t%d\n" 172 "Uid:\t%d\t%d\t%d\t%d\n"
173 "Gid:\t%d\t%d\t%d\t%d\n", 173 "Gid:\t%d\t%d\t%d\t%d\n",
174 get_task_state(p), 174 get_task_state(p),
175 p->tgid, p->pid, 175 p->tgid, p->pid,
176 pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0, 176 pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0,
177 pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0, 177 pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0,
178 p->uid, p->euid, p->suid, p->fsuid, 178 p->uid, p->euid, p->suid, p->fsuid,
179 p->gid, p->egid, p->sgid, p->fsgid); 179 p->gid, p->egid, p->sgid, p->fsgid);
@@ -191,15 +191,15 @@ static inline char * task_state(struct task_struct *p, char *buffer)
191 get_group_info(group_info); 191 get_group_info(group_info);
192 task_unlock(p); 192 task_unlock(p);
193 193
194 for (g = 0; g < min(group_info->ngroups,NGROUPS_SMALL); g++) 194 for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++)
195 buffer += sprintf(buffer, "%d ", GROUP_AT(group_info,g)); 195 buffer += sprintf(buffer, "%d ", GROUP_AT(group_info, g));
196 put_group_info(group_info); 196 put_group_info(group_info);
197 197
198 buffer += sprintf(buffer, "\n"); 198 buffer += sprintf(buffer, "\n");
199 return buffer; 199 return buffer;
200} 200}
201 201
202static char * render_sigset_t(const char *header, sigset_t *set, char *buffer) 202static char *render_sigset_t(const char *header, sigset_t *set, char *buffer)
203{ 203{
204 int i, len; 204 int i, len;
205 205
@@ -239,7 +239,7 @@ static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign,
239 } 239 }
240} 240}
241 241
242static inline char * task_sig(struct task_struct *p, char *buffer) 242static inline char *task_sig(struct task_struct *p, char *buffer)
243{ 243{
244 unsigned long flags; 244 unsigned long flags;
245 sigset_t pending, shpending, blocked, ignored, caught; 245 sigset_t pending, shpending, blocked, ignored, caught;
@@ -298,14 +298,14 @@ static inline char *task_context_switch_counts(struct task_struct *p,
298 p->nivcsw); 298 p->nivcsw);
299} 299}
300 300
301int proc_pid_status(struct task_struct *task, char * buffer) 301int proc_pid_status(struct task_struct *task, char *buffer)
302{ 302{
303 char * orig = buffer; 303 char *orig = buffer;
304 struct mm_struct *mm = get_task_mm(task); 304 struct mm_struct *mm = get_task_mm(task);
305 305
306 buffer = task_name(task, buffer); 306 buffer = task_name(task, buffer);
307 buffer = task_state(task, buffer); 307 buffer = task_state(task, buffer);
308 308
309 if (mm) { 309 if (mm) {
310 buffer = task_mem(mm, buffer); 310 buffer = task_mem(mm, buffer);
311 mmput(mm); 311 mmput(mm);
@@ -342,7 +342,7 @@ static clock_t task_utime(struct task_struct *p)
342 342
343static clock_t task_stime(struct task_struct *p) 343static clock_t task_stime(struct task_struct *p)
344{ 344{
345 clock_t stime = cputime_to_clock_t(p->stime); 345 clock_t stime;
346 346
347 /* 347 /*
348 * Use CFS's precise accounting. (we subtract utime from 348 * Use CFS's precise accounting. (we subtract utime from
@@ -354,8 +354,7 @@ static clock_t task_stime(struct task_struct *p)
354 return stime; 354 return stime;
355} 355}
356 356
357 357static int do_task_stat(struct task_struct *task, char *buffer, int whole)
358static int do_task_stat(struct task_struct *task, char * buffer, int whole)
359{ 358{
360 unsigned long vsize, eip, esp, wchan = ~0UL; 359 unsigned long vsize, eip, esp, wchan = ~0UL;
361 long priority, nice; 360 long priority, nice;
@@ -363,7 +362,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
363 sigset_t sigign, sigcatch; 362 sigset_t sigign, sigcatch;
364 char state; 363 char state;
365 int res; 364 int res;
366 pid_t ppid = 0, pgid = -1, sid = -1; 365 pid_t ppid = 0, pgid = -1, sid = -1;
367 int num_threads = 0; 366 int num_threads = 0;
368 struct mm_struct *mm; 367 struct mm_struct *mm;
369 unsigned long long start_time; 368 unsigned long long start_time;
@@ -434,7 +433,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
434 } 433 }
435 rcu_read_unlock(); 434 rcu_read_unlock();
436 435
437 if (!whole || num_threads<2) 436 if (!whole || num_threads < 2)
438 wchan = get_wchan(task); 437 wchan = get_wchan(task);
439 if (!whole) { 438 if (!whole) {
440 min_flt = task->min_flt; 439 min_flt = task->min_flt;
@@ -456,7 +455,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
456 /* convert nsec -> ticks */ 455 /* convert nsec -> ticks */
457 start_time = nsec_to_clock_t(start_time); 456 start_time = nsec_to_clock_t(start_time);
458 457
459 res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \ 458 res = sprintf(buffer, "%d (%s) %c %d %d %d %d %d %u %lu \
460%lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ 459%lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
461%lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n", 460%lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n",
462 task->pid, 461 task->pid,
@@ -482,7 +481,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
482 start_time, 481 start_time,
483 vsize, 482 vsize,
484 mm ? get_mm_rss(mm) : 0, 483 mm ? get_mm_rss(mm) : 0,
485 rsslim, 484 rsslim,
486 mm ? mm->start_code : 0, 485 mm ? mm->start_code : 0,
487 mm ? mm->end_code : 0, 486 mm ? mm->end_code : 0,
488 mm ? mm->start_stack : 0, 487 mm ? mm->start_stack : 0,
@@ -504,17 +503,17 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole)
504 task->rt_priority, 503 task->rt_priority,
505 task->policy, 504 task->policy,
506 (unsigned long long)delayacct_blkio_ticks(task)); 505 (unsigned long long)delayacct_blkio_ticks(task));
507 if(mm) 506 if (mm)
508 mmput(mm); 507 mmput(mm);
509 return res; 508 return res;
510} 509}
511 510
512int proc_tid_stat(struct task_struct *task, char * buffer) 511int proc_tid_stat(struct task_struct *task, char *buffer)
513{ 512{
514 return do_task_stat(task, buffer, 0); 513 return do_task_stat(task, buffer, 0);
515} 514}
516 515
517int proc_tgid_stat(struct task_struct *task, char * buffer) 516int proc_tgid_stat(struct task_struct *task, char *buffer)
518{ 517{
519 return do_task_stat(task, buffer, 1); 518 return do_task_stat(task, buffer, 1);
520} 519}
@@ -523,12 +522,12 @@ int proc_pid_statm(struct task_struct *task, char *buffer)
523{ 522{
524 int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0; 523 int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0;
525 struct mm_struct *mm = get_task_mm(task); 524 struct mm_struct *mm = get_task_mm(task);
526 525
527 if (mm) { 526 if (mm) {
528 size = task_statm(mm, &shared, &text, &data, &resident); 527 size = task_statm(mm, &shared, &text, &data, &resident);
529 mmput(mm); 528 mmput(mm);
530 } 529 }
531 530
532 return sprintf(buffer,"%d %d %d %d %d %d %d\n", 531 return sprintf(buffer, "%d %d %d %d %d %d %d\n",
533 size, resident, shared, text, lib, data, 0); 532 size, resident, shared, text, lib, data, 0);
534} 533}
diff --git a/kernel/sched.c b/kernel/sched.c
index 3332bbb5d5cf..1c8076676eb1 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -736,7 +736,9 @@ static void update_curr_load(struct rq *rq, u64 now)
736 * 736 *
737 * The "10% effect" is relative and cumulative: from _any_ nice level, 737 * The "10% effect" is relative and cumulative: from _any_ nice level,
738 * if you go up 1 level, it's -10% CPU usage, if you go down 1 level 738 * if you go up 1 level, it's -10% CPU usage, if you go down 1 level
739 * it's +10% CPU usage. 739 * it's +10% CPU usage. (to achieve that we use a multiplier of 1.25.
740 * If a task goes up by ~10% and another task goes down by ~10% then
741 * the relative distance between them is ~25%.)
740 */ 742 */
741static const int prio_to_weight[40] = { 743static const int prio_to_weight[40] = {
742/* -20 */ 88818, 71054, 56843, 45475, 36380, 29104, 23283, 18626, 14901, 11921, 744/* -20 */ 88818, 71054, 56843, 45475, 36380, 29104, 23283, 18626, 14901, 11921,
@@ -746,15 +748,22 @@ static const int prio_to_weight[40] = {
746/* 10 */ 110, 87, 70, 56, 45, 36, 29, 23, 18, 15, 748/* 10 */ 110, 87, 70, 56, 45, 36, 29, 23, 18, 15,
747}; 749};
748 750
751/*
752 * Inverse (2^32/x) values of the prio_to_weight[] array, precalculated.
753 *
754 * In cases where the weight does not change often, we can use the
755 * precalculated inverse to speed up arithmetics by turning divisions
756 * into multiplications:
757 */
749static const u32 prio_to_wmult[40] = { 758static const u32 prio_to_wmult[40] = {
750 48356, 60446, 75558, 94446, 118058, 147573, 759/* -20 */ 48356, 60446, 75558, 94446, 118058,
751 184467, 230589, 288233, 360285, 450347, 760/* -15 */ 147573, 184467, 230589, 288233, 360285,
752 562979, 703746, 879575, 1099582, 1374389, 761/* -10 */ 450347, 562979, 703746, 879575, 1099582,
753 1717986, 2147483, 2684354, 3355443, 4194304, 762/* -5 */ 1374389, 1717986, 2147483, 2684354, 3355443,
754 5244160, 6557201, 8196502, 10250518, 12782640, 763/* 0 */ 4194304, 5244160, 6557201, 8196502, 10250518,
755 16025997, 19976592, 24970740, 31350126, 39045157, 764/* 5 */ 12782640, 16025997, 19976592, 24970740, 31350126,
756 49367440, 61356675, 76695844, 95443717, 119304647, 765/* 10 */ 39045157, 49367440, 61356675, 76695844, 95443717,
757 148102320, 186737708, 238609294, 286331153, 766/* 15 */ 119304647, 148102320, 186737708, 238609294, 286331153,
758}; 767};
759 768
760static inline void 769static inline void