diff options
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/base.c | 117 | ||||
-rw-r--r-- | fs/proc/page.c | 8 | ||||
-rw-r--r-- | fs/proc/proc_sysctl.c | 5 | ||||
-rw-r--r-- | fs/proc/task_mmu.c | 2 |
4 files changed, 11 insertions, 121 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index d295af993677..ef5c84be66f9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -873,111 +873,6 @@ static const struct file_operations proc_environ_operations = { | |||
873 | .release = mem_release, | 873 | .release = mem_release, |
874 | }; | 874 | }; |
875 | 875 | ||
876 | static ssize_t oom_adjust_read(struct file *file, char __user *buf, | ||
877 | size_t count, loff_t *ppos) | ||
878 | { | ||
879 | struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); | ||
880 | char buffer[PROC_NUMBUF]; | ||
881 | size_t len; | ||
882 | int oom_adjust = OOM_DISABLE; | ||
883 | unsigned long flags; | ||
884 | |||
885 | if (!task) | ||
886 | return -ESRCH; | ||
887 | |||
888 | if (lock_task_sighand(task, &flags)) { | ||
889 | oom_adjust = task->signal->oom_adj; | ||
890 | unlock_task_sighand(task, &flags); | ||
891 | } | ||
892 | |||
893 | put_task_struct(task); | ||
894 | |||
895 | len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust); | ||
896 | |||
897 | return simple_read_from_buffer(buf, count, ppos, buffer, len); | ||
898 | } | ||
899 | |||
900 | static ssize_t oom_adjust_write(struct file *file, const char __user *buf, | ||
901 | size_t count, loff_t *ppos) | ||
902 | { | ||
903 | struct task_struct *task; | ||
904 | char buffer[PROC_NUMBUF]; | ||
905 | int oom_adjust; | ||
906 | unsigned long flags; | ||
907 | int err; | ||
908 | |||
909 | memset(buffer, 0, sizeof(buffer)); | ||
910 | if (count > sizeof(buffer) - 1) | ||
911 | count = sizeof(buffer) - 1; | ||
912 | if (copy_from_user(buffer, buf, count)) { | ||
913 | err = -EFAULT; | ||
914 | goto out; | ||
915 | } | ||
916 | |||
917 | err = kstrtoint(strstrip(buffer), 0, &oom_adjust); | ||
918 | if (err) | ||
919 | goto out; | ||
920 | if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) && | ||
921 | oom_adjust != OOM_DISABLE) { | ||
922 | err = -EINVAL; | ||
923 | goto out; | ||
924 | } | ||
925 | |||
926 | task = get_proc_task(file->f_path.dentry->d_inode); | ||
927 | if (!task) { | ||
928 | err = -ESRCH; | ||
929 | goto out; | ||
930 | } | ||
931 | |||
932 | task_lock(task); | ||
933 | if (!task->mm) { | ||
934 | err = -EINVAL; | ||
935 | goto err_task_lock; | ||
936 | } | ||
937 | |||
938 | if (!lock_task_sighand(task, &flags)) { | ||
939 | err = -ESRCH; | ||
940 | goto err_task_lock; | ||
941 | } | ||
942 | |||
943 | if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) { | ||
944 | err = -EACCES; | ||
945 | goto err_sighand; | ||
946 | } | ||
947 | |||
948 | /* | ||
949 | * Warn that /proc/pid/oom_adj is deprecated, see | ||
950 | * Documentation/feature-removal-schedule.txt. | ||
951 | */ | ||
952 | printk_once(KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n", | ||
953 | current->comm, task_pid_nr(current), task_pid_nr(task), | ||
954 | task_pid_nr(task)); | ||
955 | task->signal->oom_adj = oom_adjust; | ||
956 | /* | ||
957 | * Scale /proc/pid/oom_score_adj appropriately ensuring that a maximum | ||
958 | * value is always attainable. | ||
959 | */ | ||
960 | if (task->signal->oom_adj == OOM_ADJUST_MAX) | ||
961 | task->signal->oom_score_adj = OOM_SCORE_ADJ_MAX; | ||
962 | else | ||
963 | task->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) / | ||
964 | -OOM_DISABLE; | ||
965 | trace_oom_score_adj_update(task); | ||
966 | err_sighand: | ||
967 | unlock_task_sighand(task, &flags); | ||
968 | err_task_lock: | ||
969 | task_unlock(task); | ||
970 | put_task_struct(task); | ||
971 | out: | ||
972 | return err < 0 ? err : count; | ||
973 | } | ||
974 | |||
975 | static const struct file_operations proc_oom_adjust_operations = { | ||
976 | .read = oom_adjust_read, | ||
977 | .write = oom_adjust_write, | ||
978 | .llseek = generic_file_llseek, | ||
979 | }; | ||
980 | |||
981 | static ssize_t oom_score_adj_read(struct file *file, char __user *buf, | 876 | static ssize_t oom_score_adj_read(struct file *file, char __user *buf, |
982 | size_t count, loff_t *ppos) | 877 | size_t count, loff_t *ppos) |
983 | { | 878 | { |
@@ -1051,15 +946,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, | |||
1051 | if (has_capability_noaudit(current, CAP_SYS_RESOURCE)) | 946 | if (has_capability_noaudit(current, CAP_SYS_RESOURCE)) |
1052 | task->signal->oom_score_adj_min = oom_score_adj; | 947 | task->signal->oom_score_adj_min = oom_score_adj; |
1053 | trace_oom_score_adj_update(task); | 948 | trace_oom_score_adj_update(task); |
1054 | /* | 949 | |
1055 | * Scale /proc/pid/oom_adj appropriately ensuring that OOM_DISABLE is | ||
1056 | * always attainable. | ||
1057 | */ | ||
1058 | if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MIN) | ||
1059 | task->signal->oom_adj = OOM_DISABLE; | ||
1060 | else | ||
1061 | task->signal->oom_adj = (oom_score_adj * OOM_ADJUST_MAX) / | ||
1062 | OOM_SCORE_ADJ_MAX; | ||
1063 | err_sighand: | 950 | err_sighand: |
1064 | unlock_task_sighand(task, &flags); | 951 | unlock_task_sighand(task, &flags); |
1065 | err_task_lock: | 952 | err_task_lock: |
@@ -2710,7 +2597,6 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2710 | REG("cgroup", S_IRUGO, proc_cgroup_operations), | 2597 | REG("cgroup", S_IRUGO, proc_cgroup_operations), |
2711 | #endif | 2598 | #endif |
2712 | INF("oom_score", S_IRUGO, proc_oom_score), | 2599 | INF("oom_score", S_IRUGO, proc_oom_score), |
2713 | REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations), | ||
2714 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), | 2600 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), |
2715 | #ifdef CONFIG_AUDITSYSCALL | 2601 | #ifdef CONFIG_AUDITSYSCALL |
2716 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), | 2602 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), |
@@ -3077,7 +2963,6 @@ static const struct pid_entry tid_base_stuff[] = { | |||
3077 | REG("cgroup", S_IRUGO, proc_cgroup_operations), | 2963 | REG("cgroup", S_IRUGO, proc_cgroup_operations), |
3078 | #endif | 2964 | #endif |
3079 | INF("oom_score", S_IRUGO, proc_oom_score), | 2965 | INF("oom_score", S_IRUGO, proc_oom_score), |
3080 | REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations), | ||
3081 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), | 2966 | REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), |
3082 | #ifdef CONFIG_AUDITSYSCALL | 2967 | #ifdef CONFIG_AUDITSYSCALL |
3083 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), | 2968 | REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), |
diff --git a/fs/proc/page.c b/fs/proc/page.c index 7fcd0d60a968..b8730d9ebaee 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c | |||
@@ -115,7 +115,13 @@ u64 stable_page_flags(struct page *page) | |||
115 | u |= 1 << KPF_COMPOUND_TAIL; | 115 | u |= 1 << KPF_COMPOUND_TAIL; |
116 | if (PageHuge(page)) | 116 | if (PageHuge(page)) |
117 | u |= 1 << KPF_HUGE; | 117 | u |= 1 << KPF_HUGE; |
118 | else if (PageTransCompound(page)) | 118 | /* |
119 | * PageTransCompound can be true for non-huge compound pages (slab | ||
120 | * pages or pages allocated by drivers with __GFP_COMP) because it | ||
121 | * just checks PG_head/PG_tail, so we need to check PageLRU to make | ||
122 | * sure a given page is a thp, not a non-huge compound page. | ||
123 | */ | ||
124 | else if (PageTransCompound(page) && PageLRU(compound_trans_head(page))) | ||
119 | u |= 1 << KPF_THP; | 125 | u |= 1 << KPF_THP; |
120 | 126 | ||
121 | /* | 127 | /* |
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index dcd56f84db7e..a781bdf06694 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -142,6 +142,7 @@ static int insert_entry(struct ctl_table_header *head, struct ctl_table *entry) | |||
142 | } | 142 | } |
143 | 143 | ||
144 | rb_link_node(node, parent, p); | 144 | rb_link_node(node, parent, p); |
145 | rb_insert_color(node, &head->parent->root); | ||
145 | return 0; | 146 | return 0; |
146 | } | 147 | } |
147 | 148 | ||
@@ -168,10 +169,8 @@ static void init_header(struct ctl_table_header *head, | |||
168 | head->node = node; | 169 | head->node = node; |
169 | if (node) { | 170 | if (node) { |
170 | struct ctl_table *entry; | 171 | struct ctl_table *entry; |
171 | for (entry = table; entry->procname; entry++, node++) { | 172 | for (entry = table; entry->procname; entry++, node++) |
172 | rb_init_node(&node->node); | ||
173 | node->header = head; | 173 | node->header = head; |
174 | } | ||
175 | } | 174 | } |
176 | } | 175 | } |
177 | 176 | ||
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 4540b8f76f16..79827ce03e3b 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -54,7 +54,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm) | |||
54 | "VmPTE:\t%8lu kB\n" | 54 | "VmPTE:\t%8lu kB\n" |
55 | "VmSwap:\t%8lu kB\n", | 55 | "VmSwap:\t%8lu kB\n", |
56 | hiwater_vm << (PAGE_SHIFT-10), | 56 | hiwater_vm << (PAGE_SHIFT-10), |
57 | (total_vm - mm->reserved_vm) << (PAGE_SHIFT-10), | 57 | total_vm << (PAGE_SHIFT-10), |
58 | mm->locked_vm << (PAGE_SHIFT-10), | 58 | mm->locked_vm << (PAGE_SHIFT-10), |
59 | mm->pinned_vm << (PAGE_SHIFT-10), | 59 | mm->pinned_vm << (PAGE_SHIFT-10), |
60 | hiwater_rss << (PAGE_SHIFT-10), | 60 | hiwater_rss << (PAGE_SHIFT-10), |