All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] OOM killer meets userspace headers
@ 2006-10-18 14:53 Alexey Dobriyan
  2006-10-18 15:05 ` Nick Piggin
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Alexey Dobriyan @ 2006-10-18 14:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Woodhouse, linux-kernel

Despite mm.h is not being exported header, it does contain one thing
which is part of userspace ABI -- value disabling OOM killer. So,
a) export mm.h to userspace
b) got OOM_DISABLE disable define out of __KERNEL__ prison.
c) turn bound values suitable for /proc/$PID/oom_adj into defines and export
   them too.
d) put some headers into __KERNEL__ prison. It'd bizarre to include mm.h and
   get capability stuff.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/proc/base.c       |    3 ++-
 include/linux/Kbuild |    2 ++
 include/linux/mm.h   |   13 +++++++------
 3 files changed, 11 insertions(+), 7 deletions(-)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -689,7 +689,8 @@ static ssize_t oom_adjust_write(struct f
 	if (copy_from_user(buffer, buf, count))
 		return -EFAULT;
 	oom_adjust = simple_strtol(buffer, &end, 0);
-	if ((oom_adjust < -16 || oom_adjust > 15) && oom_adjust != OOM_DISABLE)
+	if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) &&
+	     oom_adjust != OOM_DISABLE)
 		return -EINVAL;
 	if (*end == '\n')
 		end++;
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -110,6 +110,7 @@ header-y += major.h
 header-y += matroxfb.h
 header-y += meye.h
 header-y += minix_fs.h
+header-y += mm.h
 header-y += mmtimer.h
 header-y += mqueue.h
 header-y += mtio.h
@@ -257,6 +258,7 @@ unifdef-y += loop.h
 unifdef-y += lp.h
 unifdef-y += mempolicy.h
 unifdef-y += mii.h
+unifdef-y += mm.h
 unifdef-y += mman.h
 unifdef-y += mroute.h
 unifdef-y += msdos_fs.h
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1,12 +1,16 @@
 #ifndef _LINUX_MM_H
 #define _LINUX_MM_H
 
+/* /proc/<pid>/oom_adj set to -17 protects from the oom-killer */
+#define OOM_DISABLE (-17)
+/* inclusive */
+#define OOM_ADJUST_MIN (-16)
+#define OOM_ADJUST_MAX 15
+
+#ifdef __KERNEL__
 #include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/capability.h>
-
-#ifdef __KERNEL__
-
 #include <linux/gfp.h>
 #include <linux/list.h>
 #include <linux/mmzone.h>
@@ -1115,9 +1119,6 @@ int in_gate_area_no_task(unsigned long a
 #define in_gate_area(task, addr) ({(void)task; in_gate_area_no_task(addr);})
 #endif	/* __HAVE_ARCH_GATE_AREA */
 
-/* /proc/<pid>/oom_adj set to -17 protects from the oom-killer */
-#define OOM_DISABLE -17
-
 int drop_caches_sysctl_handler(struct ctl_table *, int, struct file *,
 					void __user *, size_t *, loff_t *);
 unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-10-18 19:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-18 14:53 [PATCH] OOM killer meets userspace headers Alexey Dobriyan
2006-10-18 15:05 ` Nick Piggin
2006-10-18 18:46   ` [KJ] " Alexey Dobriyan
2006-10-18 18:46     ` Alexey Dobriyan
2006-10-18 19:12     ` [KJ] " Nick Piggin
2006-10-18 19:12       ` Nick Piggin
2006-10-18 19:24       ` [KJ] " Alexey Dobriyan
2006-10-18 19:24         ` Alexey Dobriyan
2006-10-18 19:34         ` [KJ] " Nick Piggin
2006-10-18 19:34           ` Nick Piggin
2006-10-18 15:08 ` David Woodhouse
2006-10-18 15:09 ` Christoph Hellwig
2006-10-18 18:21   ` [PATCH v2] " Alexey Dobriyan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.