[PATCH 5/6] tools/vm/page_owner: increase temporary buffer size

From: js1304
Date: Tue May 03 2016 - 01:23:28 EST


From: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>

Page owner will be changed to store more deep stacktrace
so current temporary buffer size isn't enough. Increase it.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
---
tools/vm/page_owner_sort.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/vm/page_owner_sort.c b/tools/vm/page_owner_sort.c
index 77147b4..f1c055f 100644
--- a/tools/vm/page_owner_sort.c
+++ b/tools/vm/page_owner_sort.c
@@ -79,12 +79,12 @@ static void add_list(char *buf, int len)
}
}

-#define BUF_SIZE 1024
+#define BUF_SIZE (128 * 1024)

int main(int argc, char **argv)
{
FILE *fin, *fout;
- char buf[BUF_SIZE];
+ char *buf;
int ret, i, count;
struct block_list *list2;
struct stat st;
@@ -107,6 +107,11 @@ int main(int argc, char **argv)
max_size = st.st_size / 100; /* hack ... */

list = malloc(max_size * sizeof(*list));
+ buf = malloc(BUF_SIZE);
+ if (!list || !buf) {
+ printf("Out of memory\n");
+ exit(1);
+ }

for ( ; ; ) {
ret = read_block(buf, BUF_SIZE, fin);
--
1.9.1