aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2012-12-11 19:02:54 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 20:22:27 -0500
commita9c58b907dbc6821533dfc295b63caf111ff1f16 (patch)
treee50714c48de89400a02a8e92ef4e240c5206bbcc /fs/proc
parentfa264375175a382621c5344a6508e02ec4d1c3c0 (diff)
mm, oom: change type of oom_score_adj to short
The maximum oom_score_adj is 1000 and the minimum oom_score_adj is -1000, so this range can be represented by the signed short type with no functional change. The extra space this frees up in struct signal_struct will be used for per-thread oom kill flags in the next patch. Signed-off-by: David Rientjes <rientjes@google.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reviewed-by: Michal Hocko <mhocko@suse.cz> Cc: Anton Vorontsov <anton.vorontsov@linaro.org> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 9e28356a959a..aa63d25157b8 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -985,7 +985,7 @@ static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
985{ 985{
986 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 986 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
987 char buffer[PROC_NUMBUF]; 987 char buffer[PROC_NUMBUF];
988 int oom_score_adj = OOM_SCORE_ADJ_MIN; 988 short oom_score_adj = OOM_SCORE_ADJ_MIN;
989 unsigned long flags; 989 unsigned long flags;
990 size_t len; 990 size_t len;
991 991
@@ -996,7 +996,7 @@ static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
996 unlock_task_sighand(task, &flags); 996 unlock_task_sighand(task, &flags);
997 } 997 }
998 put_task_struct(task); 998 put_task_struct(task);
999 len = snprintf(buffer, sizeof(buffer), "%d\n", oom_score_adj); 999 len = snprintf(buffer, sizeof(buffer), "%hd\n", oom_score_adj);
1000 return simple_read_from_buffer(buf, count, ppos, buffer, len); 1000 return simple_read_from_buffer(buf, count, ppos, buffer, len);
1001} 1001}
1002 1002
@@ -1043,15 +1043,15 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
1043 goto err_task_lock; 1043 goto err_task_lock;
1044 } 1044 }
1045 1045
1046 if (oom_score_adj < task->signal->oom_score_adj_min && 1046 if ((short)oom_score_adj < task->signal->oom_score_adj_min &&
1047 !capable(CAP_SYS_RESOURCE)) { 1047 !capable(CAP_SYS_RESOURCE)) {
1048 err = -EACCES; 1048 err = -EACCES;
1049 goto err_sighand; 1049 goto err_sighand;
1050 } 1050 }
1051 1051
1052 task->signal->oom_score_adj = oom_score_adj; 1052 task->signal->oom_score_adj = (short)oom_score_adj;
1053 if (has_capability_noaudit(current, CAP_SYS_RESOURCE)) 1053 if (has_capability_noaudit(current, CAP_SYS_RESOURCE))
1054 task->signal->oom_score_adj_min = oom_score_adj; 1054 task->signal->oom_score_adj_min = (short)oom_score_adj;
1055 trace_oom_score_adj_update(task); 1055 trace_oom_score_adj_update(task);
1056 1056
1057err_sighand: 1057err_sighand: