diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-05-30 08:34:22 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-06-25 03:37:30 -0400 |
commit | b46ddf5d187d603f72389ac047a99e80edb6285d (patch) | |
tree | bdd50cc014cfc9e112ffbecb6a3978b309a4b586 /litmus/ftdev.c | |
parent | 12e4158927c733d15917e3406cdf1c20885b30f9 (diff) |
Use vmalloc() to allocate Feather-Trace buffers
Allocating contiguous buffers with kmalloc() is subject to severe
maximum size limits. For Feather-Trace to work, we don't actually need
*physically* contiguous memory; virtually contiguous memory is
sufficient. By switching to vmalloc(), the code gets simpler and we
can support much larger buffers.
For convenience, this patch also adds a configuration option for
the desired Feather-Trace buffer size and increases the default
size.
Diffstat (limited to 'litmus/ftdev.c')
-rw-r--r-- | litmus/ftdev.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/litmus/ftdev.c b/litmus/ftdev.c index 99bc39ffbcef..7126c61e8b4c 100644 --- a/litmus/ftdev.c +++ b/litmus/ftdev.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <asm/uaccess.h> | 5 | #include <asm/uaccess.h> |
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/device.h> | 7 | #include <linux/device.h> |
8 | #include <linux/vmalloc.h> | ||
8 | 9 | ||
9 | #include <litmus/litmus.h> | 10 | #include <litmus/litmus.h> |
10 | #include <litmus/feather_trace.h> | 11 | #include <litmus/feather_trace.h> |
@@ -21,13 +22,9 @@ struct ft_buffer* alloc_ft_buffer(unsigned int count, size_t size) | |||
21 | if (!buf) | 22 | if (!buf) |
22 | return NULL; | 23 | return NULL; |
23 | 24 | ||
24 | total = (total / PAGE_SIZE) + (total % PAGE_SIZE != 0); | ||
25 | while (pages < total) { | ||
26 | order++; | ||
27 | pages *= 2; | ||
28 | } | ||
29 | 25 | ||
30 | mem = (char*) __get_free_pages(GFP_KERNEL, order); | 26 | mem = vmalloc(total); |
27 | |||
31 | if (!mem) { | 28 | if (!mem) { |
32 | kfree(buf); | 29 | kfree(buf); |
33 | return NULL; | 30 | return NULL; |
@@ -36,7 +33,7 @@ struct ft_buffer* alloc_ft_buffer(unsigned int count, size_t size) | |||
36 | if (!init_ft_buffer(buf, count, size, | 33 | if (!init_ft_buffer(buf, count, size, |
37 | mem + (count * size), /* markers at the end */ | 34 | mem + (count * size), /* markers at the end */ |
38 | mem)) { /* buffer objects */ | 35 | mem)) { /* buffer objects */ |
39 | free_pages((unsigned long) mem, order); | 36 | vfree(mem); |
40 | kfree(buf); | 37 | kfree(buf); |
41 | return NULL; | 38 | return NULL; |
42 | } | 39 | } |
@@ -49,13 +46,7 @@ void free_ft_buffer(struct ft_buffer* buf) | |||
49 | size_t total; | 46 | size_t total; |
50 | 47 | ||
51 | if (buf) { | 48 | if (buf) { |
52 | total = (buf->slot_size + 1) * buf->slot_count; | 49 | vfree(buf->buffer_mem); |
53 | total = (total / PAGE_SIZE) + (total % PAGE_SIZE != 0); | ||
54 | while (pages < total) { | ||
55 | order++; | ||
56 | pages *= 2; | ||
57 | } | ||
58 | free_pages((unsigned long) buf->buffer_mem, order); | ||
59 | kfree(buf); | 50 | kfree(buf); |
60 | } | 51 | } |
61 | } | 52 | } |