Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100536
b: refs/heads/master
c: 3eefae9
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Thomas Gleixner committed May 23, 2008
1 parent 24d1a50 commit 11d088c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6c6c27969a4c6024e6c8838829546c02aaddca18
refs/heads/master: 3eefae994d9224fb7771a3ddb683868363c23510
2 changes: 2 additions & 0 deletions trunk/include/linux/writeback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 38 additions & 0 deletions trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/poll.h>
#include <linux/gfp.h>
#include <linux/fs.h>
#include <linux/writeback.h>

#include <linux/stacktrace.h>

Expand All @@ -51,6 +52,8 @@ static int trace_free_page(void);

static int tracing_disabled = 1;

static unsigned long tracing_pages_allocated;

long
ns2usecs(cycle_t nsec)
{
Expand Down Expand Up @@ -2591,12 +2594,41 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
}

if (val > global_trace.entries) {
long pages_requested;
unsigned long freeable_pages;

/* make sure we have enough memory before mapping */
pages_requested =
(val + (ENTRIES_PER_PAGE-1)) / ENTRIES_PER_PAGE;

/* account for each buffer (and max_tr) */
pages_requested *= tracing_nr_buffers * 2;

/* Check for overflow */
if (pages_requested < 0) {
cnt = -ENOMEM;
goto out;
}

freeable_pages = determine_dirtyable_memory();

/* we only allow to request 1/4 of useable memory */
if (pages_requested >
((freeable_pages + tracing_pages_allocated) / 4)) {
cnt = -ENOMEM;
goto out;
}

while (global_trace.entries < val) {
if (trace_alloc_page()) {
cnt = -ENOMEM;
goto out;
}
/* double check that we don't go over the known pages */
if (tracing_pages_allocated > pages_requested)
break;
}

} else {
/* include the number of entries in val (inc of page entries) */
while (global_trace.entries > val + (ENTRIES_PER_PAGE - 1))
Expand Down Expand Up @@ -2776,6 +2808,7 @@ static int trace_alloc_page(void)
struct page *page, *tmp;
LIST_HEAD(pages);
void *array;
unsigned pages_allocated = 0;
int i;

/* first allocate a page for each CPU */
Expand All @@ -2787,6 +2820,7 @@ static int trace_alloc_page(void)
goto free_pages;
}

pages_allocated++;
page = virt_to_page(array);
list_add(&page->lru, &pages);

Expand All @@ -2798,6 +2832,7 @@ static int trace_alloc_page(void)
"for trace buffer!\n");
goto free_pages;
}
pages_allocated++;
page = virt_to_page(array);
list_add(&page->lru, &pages);
#endif
Expand All @@ -2819,6 +2854,7 @@ static int trace_alloc_page(void)
SetPageLRU(page);
#endif
}
tracing_pages_allocated += pages_allocated;
global_trace.entries += ENTRIES_PER_PAGE;

return 0;
Expand Down Expand Up @@ -2853,6 +2889,8 @@ static int trace_free_page(void)
page = list_entry(p, struct page, lru);
ClearPageLRU(page);
list_del(&page->lru);
tracing_pages_allocated--;
tracing_pages_allocated--;
__free_page(page);

tracing_reset(data);
Expand Down
10 changes: 7 additions & 3 deletions trunk/mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ static void background_writeout(unsigned long _min_pages);
static struct prop_descriptor vm_completions;
static struct prop_descriptor vm_dirties;

static unsigned long determine_dirtyable_memory(void);

/*
* couple the period to the dirty_ratio:
*
Expand Down Expand Up @@ -347,7 +345,13 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)
#endif
}

static unsigned long determine_dirtyable_memory(void)
/**
* determine_dirtyable_memory - amount of memory that may be used
*
* Returns the numebr of pages that can currently be freed and used
* by the kernel for direct mappings.
*/
unsigned long determine_dirtyable_memory(void)
{
unsigned long x;

Expand Down

0 comments on commit 11d088c

Please sign in to comment.