Commit 30b2f271 authored by Charles Jacobsen's avatar Charles Jacobsen Committed by Vikram Narayanan

pmfs: mount: Fixed heap exhaustion due to too many stacks.

You have to be careful where you put your asyncs, especially
with poll recv. If you wrap the call to poll recv in an async,
you will consume lots of memory. I moved the async so it surrounds
the dispatch function only.

In the process, to debug, I updated libasync with THCDumpAllStacks
(I was trying to see what all the stacks were - they were all coming
from poll recv).

NOTE: While debugging, I tweaked the microkernel dump stack code
to work for THCDumpAllStacks (continue walking until we hit a
frame or return address). If you don't make this change,
THCDumpAllStacks will not crash, but it won't be informative either
(the stack walk will stop too soon).

I'm able to run at least 100 iterations now of mount/unmount without
any problems.
parent 96dfa04e
......@@ -245,5 +245,10 @@ static inline int lcd_syscall_munmap(cptr_t mo_cptr)
return lcd_syscall_one_arg(LCD_SYSCALL_MUNMAP, cptr_val(mo_cptr));
}
static inline void lcd_syscall_dump_stack(void)
{
lcd_syscall_no_args(LCD_SYSCALL_DUMP_STACK);
}
#endif /* ASM_LCD_DOMAINS_LIBLCD_H */
......@@ -19,6 +19,7 @@
#define BUG() do { \
lcd_printk("BUG! in %s:%s:%d", __FILE__, __func__, \
__LINE__); \
lcd_dump_stack(); \
lcd_exit(-1); \
} while (0)
......@@ -27,6 +28,7 @@
if (x) { \
lcd_printk("BUG! in %s:%s:%d", __FILE__, __func__, \
__LINE__); \
lcd_dump_stack(); \
lcd_exit(-1); \
} \
} while (0)
......@@ -64,9 +66,6 @@
#undef kasprintf
#define kasprintf(x, fmt, args...) ({ lcd_printk(fmt, args); (char *)1; });
#undef dump_stack
#define dump_stack() do { } while (0)
#undef unlikely
#define unlikely(x) x
......
......@@ -20,5 +20,6 @@
#include "resource_tree.h"
#include "sync_ipc.h"
#include "syscall.h"
#include "trace.h"
#endif /* LIBLCD_LIBLCD_H */
......@@ -27,6 +27,7 @@ enum lcd_syscall {
LCD_SYSCALL_VMALLOC,
LCD_SYSCALL_MMAP,
LCD_SYSCALL_MUNMAP,
LCD_SYSCALL_DUMP_STACK,
};
#endif /* LCD_DOMAINS_SYSCALL_H */
/*
* trace.h
*
* Functions for doing stack traces.
*
* Copyright: University of Utah
*/
#ifndef LIBLCD_TRACE_H
#define LIBLCD_TRACE_H
void lcd_dump_stack(void);
#endif /* LIBLCD_TRACE_H */
/*
* trace.c
*/
#include <liblcd/trace.h>
#include <linux/kernel.h>
void lcd_dump_stack(void)
{
dump_stack();
}
/*
* trace.c
*/
#include <lcd_config/pre_hook.h>
#include <liblcd/trace.h>
#include <asm/lcd_domains/liblcd.h>
#include <lcd_config/post_hook.h>
void lcd_dump_stack(void)
{
lcd_syscall_dump_stack();
}
......@@ -215,3 +215,10 @@ void call_rcu_sched(struct rcu_head *head,
/* Just call it */
func(head);
}
/* DUMP STACK -------------------------------------------------- */
void dump_stack(void)
{
lcd_dump_stack();
}
......@@ -274,6 +274,13 @@ static int handle_syscall_putchar(struct lcd *lcd)
return __lcd_put_char(lcd, c);
}
static int handle_syscall_dump_stack(struct lcd *lcd)
{
lcd_arch_dump_lcd(lcd->lcd_arch);
return 0;
}
static int handle_syscall_exit(struct lcd *lcd, int *lcd_ret)
{
/*
......@@ -351,6 +358,9 @@ static int handle_syscall(struct lcd *lcd, int *lcd_ret)
case LCD_SYSCALL_MUNMAP:
ret = handle_syscall_munmap(lcd);
break;
case LCD_SYSCALL_DUMP_STACK:
ret = handle_syscall_dump_stack(lcd);
break;
default:
LCD_ERR("unimplemented syscall %d", syscall_id);
ret = -ENOSYS;
......
......@@ -23,6 +23,7 @@ lib-y += $(addprefix liblcd/lcd-domains/, \
ram_map.o \
sync_ipc.o \
ioremap.o \
trace.o \
)
lib-y += $(addprefix liblcd/lib/, \
......
......@@ -47,6 +47,7 @@ lcd_domains-y += $(addprefix kliblcd/, \
module_create_klcd.o \
module_load.o \
sync_ipc.o \
trace.o \
)
# code shared by kliblcd and isolated liblcd
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment