Currently there is no protection from the root user to use up all of
memory for trace buffers. If the root user allocates too many entries,
the OOM killer might start kill off all tasks.This patch adds an algorith to check the following condition:
pages_requested > (freeable_memory + current_trace_buffer_pages) / 4
If the above is met then the allocation fails. The above prevents more
than 1/4th of freeable memory from being used by trace buffers.To determine the freeable_memory, I made determine_dirtyable_memory in
mm/page-writeback.c global.Special thanks goes to Peter Zijlstra for suggesting the above calculation.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
include/linux/writeback.h | 2 ++
kernel/trace/trace.c | 38 ++++++++++++++++++++++++++++++++++++++
mm/page-writeback.c | 10 +++++++---
3 files changed, 47 insertions(+), 3 deletions(-)Index: linux-sched-devel.git/include/linux/writeback.h
===================================================================
--- linux-sched-devel.git.orig/include/linux/writeback.h 2008-04-18 15:47:21.000000000 -0400
+++ linux-sched-devel.git/include/linux/writeback.h 2008-04-18 15:53:08.000000000 -0400
@@ -105,6 +105,8 @@ extern int vm_highmem_is_dirtyable;
extern int block_dump;
extern int laptop_mode;+extern unsigned long determine_dirtyable_memory(void);
+
extern int dirty_ratio_handler(struct ctl_table *table, int write,
struct file *filp, void __user *buffer, size_t *lenp,
loff_t *ppos);
Index: linux-sched-devel.git/kernel/trace/trace.c
===================================================================
--- linux-sched-devel.git.orig/kernel/trace/trace.c 2008-04-18 15:50:47.000000000 -0400
+++ linux-sched-devel.git/kernel/trace/trace.c 2008-04-18 15:53:08.000000000 -0400
@@ -27,6 +27,7 @@
#include <linux/poll.h>
#include <linux/gfp.h>
#include <linux/fs.h>
+#include <linux/writeback.h>#include <linux/stacktrace.h>
@@ -51,...
On Fri, 18 Apr 2008 16:05:42 -0400
tpyo
--
thanks, fixed.
Ingo
--
Currently there is no protection from the root user to use up all of
memory for trace buffers. If the root user allocates too many entries,
the OOM killer might start killing off all tasks.This patch adds an algorithm to check the following condition:
pages_requested > (freeable_memory + current_trace_buffer_pages) / 4
If the above is met then the allocation fails. The above prevents more
than 1/4th of freeable memory from being used by trace buffers.To determine the freeable_memory, I made determine_dirtyable_memory in
mm/page-writeback.c global.Special thanks goes to Peter Zijlstra for suggesting the above calculation.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
include/linux/writeback.h | 2 ++
kernel/trace/trace.c | 38 ++++++++++++++++++++++++++++++++++++++
mm/page-writeback.c | 10 +++++++---
3 files changed, 47 insertions(+), 3 deletions(-)Index: linux-sched-devel.git/include/linux/writeback.h
===================================================================
--- linux-sched-devel.git.orig/include/linux/writeback.h 2008-04-18 23:01:57.000000000 -0400
+++ linux-sched-devel.git/include/linux/writeback.h 2008-04-18 23:06:43.000000000 -0400
@@ -105,6 +105,8 @@ extern int vm_highmem_is_dirtyable;
extern int block_dump;
extern int laptop_mode;+extern unsigned long determine_dirtyable_memory(void);
+
extern int dirty_ratio_handler(struct ctl_table *table, int write,
struct file *filp, void __user *buffer, size_t *lenp,
loff_t *ppos);
Index: linux-sched-devel.git/kernel/trace/trace.c
===================================================================
--- linux-sched-devel.git.orig/kernel/trace/trace.c 2008-04-18 23:06:40.000000000 -0400
+++ linux-sched-devel.git/kernel/trace/trace.c 2008-04-18 23:06:43.000000000 -0400
@@ -27,6 +27,7 @@
#include <linux/poll.h>
#include <linux/gfp.h>
#include <linux/fs.h>
+#include <linux/writeback.h>#include <linux/stacktrace.h>
@@ -...
Damn! You don't miss a thing. Are you sure your name isn't Monk?
New patch coming.
Thanks,
-- Steve
--
We could do this all day at this level of detail :)
--
| Greg KH | Re: Announce: Linux-next (Or Andrew's dream :-)) |
| Greg KH | [patch 26/73] NET: Correct two mistaken skb_reset_mac_header() conversions. |
| Greg Kroah-Hartman | [PATCH 007/196] Chinese: add translation of stable_kernel_rules.txt |
| Alan Cox | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
git: | |
| Alexey Dobriyan | Re: [GIT]: Networking |
| Gerrit Renker | [PATCH 03/37] dccp: List management for new feature negotiation |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Andrew Morton | Re: [BUG] New Kernel Bugs |
