Bug 7016 - Systemtap will causes OOM when specifying large relay buffer size.
Summary: Systemtap will causes OOM when specifying large relay buffer size.
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: runtime (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Masami Hiramatsu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-10 17:10 UTC by Masami Hiramatsu
Modified: 2008-11-13 21:44 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
[PATCH] checking free memory before allocating relay buffer (691 bytes, patch)
2008-11-11 16:26 UTC, Masami Hiramatsu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Masami Hiramatsu 2008-11-10 17:10:21 UTC
When I specified larger value than main memory, to -s option of systemtap, the
system ran OOM killer and stopped on ia64 and x86-64. I couldn't reproduce it on
ia32 because it's vmalloc-space is smaller than real memory.

For example, if the machine has 4GB memory, run
# stap -e 'probe begin{hello}' -s 4095
this causes OOM kill.

if the machine has 8GB memory and 4 CPUs, run
# stap -e 'probe begin{hello}' -s 2048 -b

This is always reproducible on 64-bit arch.

I think stap should fail to run if the system doesn't have enough free memory.
Comment 1 Masami Hiramatsu 2008-11-10 17:13:27 UTC
Users in stapusr group can cause OOM killer, because the size of relayfs is just
a runtime option of staprun.
Comment 2 Frank Ch. Eigler 2008-11-10 18:41:27 UTC
Perhaps relay_open* could be taught to use GFP_ATOMIC | GFP_NORETRY.
Comment 3 Masami Hiramatsu 2008-11-10 19:24:16 UTC
(In reply to comment #2)
> Perhaps relay_open* could be taught to use GFP_ATOMIC | GFP_NORETRY.

Indeed. However, we'd better care older kernel too, because relay will be
replaced by new unified trace buffer.
What about checking free memory by using si_meminfo()?
Comment 4 Masami Hiramatsu 2008-11-11 16:26:06 UTC
Created attachment 3056 [details]
[PATCH] checking free memory before allocating relay buffer

This patch adds free memory checking before allocation of relay in utt.c.

There are 3 cases;
1. relaybuf < free, utt allows to allocate relay buffer.
2. free < relaybuf < free+buffered, utt warns and allocates relay buffer.
3. free+buffered < relaybuf, utt rejects allocation.

'free' is free memory, and 'buffered' is the memory which is used for io
buffer.
Comment 5 Masami Hiramatsu 2008-11-13 21:44:42 UTC
Patch committed as 214b2c3.