mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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 <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: KOSAKI Motohiro <[email protected]> Reviewed-by: Michal Hocko <[email protected]> Cc: Anton Vorontsov <[email protected]> Cc: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
fa26437517
commit
a9c58b907d
9 changed files with 31 additions and 31 deletions
|
|
@ -985,7 +985,7 @@ static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
|
|||
{
|
||||
struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
|
||||
char buffer[PROC_NUMBUF];
|
||||
int oom_score_adj = OOM_SCORE_ADJ_MIN;
|
||||
short oom_score_adj = OOM_SCORE_ADJ_MIN;
|
||||
unsigned long flags;
|
||||
size_t len;
|
||||
|
||||
|
|
@ -996,7 +996,7 @@ static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
|
|||
unlock_task_sighand(task, &flags);
|
||||
}
|
||||
put_task_struct(task);
|
||||
len = snprintf(buffer, sizeof(buffer), "%d\n", oom_score_adj);
|
||||
len = snprintf(buffer, sizeof(buffer), "%hd\n", oom_score_adj);
|
||||
return simple_read_from_buffer(buf, count, ppos, buffer, len);
|
||||
}
|
||||
|
||||
|
|
@ -1043,15 +1043,15 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
|
|||
goto err_task_lock;
|
||||
}
|
||||
|
||||
if (oom_score_adj < task->signal->oom_score_adj_min &&
|
||||
if ((short)oom_score_adj < task->signal->oom_score_adj_min &&
|
||||
!capable(CAP_SYS_RESOURCE)) {
|
||||
err = -EACCES;
|
||||
goto err_sighand;
|
||||
}
|
||||
|
||||
task->signal->oom_score_adj = oom_score_adj;
|
||||
task->signal->oom_score_adj = (short)oom_score_adj;
|
||||
if (has_capability_noaudit(current, CAP_SYS_RESOURCE))
|
||||
task->signal->oom_score_adj_min = oom_score_adj;
|
||||
task->signal->oom_score_adj_min = (short)oom_score_adj;
|
||||
trace_oom_score_adj_update(task);
|
||||
|
||||
err_sighand:
|
||||
|
|
|
|||
Loading…
Reference in a new issue