Skip to content

Commit

Permalink
pagealloc: Do not use probe context for executing test
Browse files Browse the repository at this point in the history
Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
  • Loading branch information
root authored and gormanm committed Nov 24, 2016
1 parent c22ae8b commit 434e390
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 32 deletions.
2 changes: 1 addition & 1 deletion bin/stap-fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fi

echo WARNING: systemtap installation broken, trying to fix.

for PATCH in 4.5 4.6 4.6-rc3 4.7-rc1; do
for PATCH in 4.5 4.6 4.6-rc3 4.7-rc1 4.8; do
cat $SCRIPTDIR/stap-patches/systemtap-runtime-${PATCH}.patch | patch -p1 -d /usr/share/systemtap
if [ $? -ne 0 ]; then
restore_systemtap
Expand Down
38 changes: 33 additions & 5 deletions shellpack_src/src/pagealloc/pagealloc-bench
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,43 @@ for ORDER in `seq $ORDER_MIN $ORDER_MAX`; do
-e "s/define PARAM_BATCH.*/define PARAM_BATCH $BATCH/" \
-e "s/define PARAM_ORDER.*/define PARAM_ORDER $ORDER/" > /tmp/pagealloc.stp

# Dummy run to compile
stap -DSTAP_OVERRIDE_STUCK_CONTEXT -g /tmp/pagealloc.stp > /dev/null

# Execute
stap -DSTAP_OVERRIDE_STUCK_CONTEXT -g /tmp/pagealloc.stp &
STAP_PID=$!

ATTEMPT=0
echo -n Waiting for module to load
sleep 1
while [ ! -e /proc/mmtests-pagealloc-micro ]; do
echo -n .
sleep 1
ATTEMPT=$((ATTEMPT+1))
if [ $ATTEMPT = 180 ]; then
die Failed to run stap module after 3 minutes
fi
done
echo
echo Executing test

monitor_pre_hook $LOGDIR_RESULTS $ORDER-$BATCH
stap -DSTAP_OVERRIDE_STUCK_CONTEXT -g /tmp/pagealloc.stp | \
tee -a $LOGDIR_RESULTS/pagealloc.log
cat /proc/mmtests-pagealloc-micro | tee -a $LOGDIR_RESULTS/pagealloc.log
monitor_post_hook $LOGDIR_RESULTS $ORDER-$BATCH

ATTEMPT=0
echo -n Waiting for module to unload
kill -INT $STAP_PID
sleep 2
while [ -e /proc/mmtests-pagealloc-micro ]; do
kill -INT $STAP_PID
echo -n .
sleep 1
ATTEMPT=$((ATTEMPT+1))
if [ $ATTEMPT = 180 ]; then
die Failed to unload stap module after 3 minutes
fi
done
echo

BATCH=$((BATCH<<1))
done
done
Expand Down
2 changes: 1 addition & 1 deletion shellpack_src/src/pagealloc/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24
31
40 changes: 34 additions & 6 deletions shellpacks/shellpack-bench-pagealloc
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,43 @@ for ORDER in `seq $ORDER_MIN $ORDER_MAX`; do
-e "s/define PARAM_BATCH.*/define PARAM_BATCH $BATCH/" \
-e "s/define PARAM_ORDER.*/define PARAM_ORDER $ORDER/" > /tmp/pagealloc.stp

# Dummy run to compile
stap -DSTAP_OVERRIDE_STUCK_CONTEXT -g /tmp/pagealloc.stp > /dev/null

# Execute
stap -DSTAP_OVERRIDE_STUCK_CONTEXT -g /tmp/pagealloc.stp &
STAP_PID=$!

ATTEMPT=0
echo -n Waiting for module to load
sleep 1
while [ ! -e /proc/mmtests-pagealloc-micro ]; do
echo -n .
sleep 1
ATTEMPT=$((ATTEMPT+1))
if [ $ATTEMPT = 180 ]; then
die Failed to run stap module after 3 minutes
fi
done
echo
echo Executing test

monitor_pre_hook $LOGDIR_RESULTS $ORDER-$BATCH
stap -DSTAP_OVERRIDE_STUCK_CONTEXT -g /tmp/pagealloc.stp | \
tee -a $LOGDIR_RESULTS/pagealloc.log
cat /proc/mmtests-pagealloc-micro | tee -a $LOGDIR_RESULTS/pagealloc.log
monitor_post_hook $LOGDIR_RESULTS $ORDER-$BATCH

ATTEMPT=0
echo -n Waiting for module to unload
kill -INT $STAP_PID
sleep 2
while [ -e /proc/mmtests-pagealloc-micro ]; do
kill -INT $STAP_PID
echo -n .
sleep 1
ATTEMPT=$((ATTEMPT+1))
if [ $ATTEMPT = 180 ]; then
die Failed to unload stap module after 3 minutes
fi
done
echo

BATCH=$((BATCH<<1))
done
done
Expand All @@ -114,4 +142,4 @@ done

exit $SHELLPACK_SUCCESS
#### Description Micro-benchmark to stress the page allocator
#### Details pagealloc-bench 24
#### Details pagealloc-bench 31
2 changes: 1 addition & 1 deletion shellpacks/shellpack-install-pagealloc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#### Description Micro-benchmark to stress the page allocator
#### Details pagealloc 24
#### Details pagealloc 31
10 changes: 10 additions & 0 deletions stap-patches/systemtap-runtime-4.8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/runtime/linux/access_process_vm.h 2016-11-24 11:42:45.682852798 +0000
+++ b/runtime/linux/access_process_vm.h 2016-11-24 11:42:51.618845242 +0000
@@ -32,7 +32,7 @@
int bytes, ret, offset;
void *maddr;

- ret = get_user_pages (tsk, mm, addr, 1, write, 1, &page, &vma);
+ ret = get_user_pages_remote (tsk, mm, addr, 1, write, 1, &page, &vma);
if (ret <= 0)
break;
56 changes: 38 additions & 18 deletions stap-scripts/pagealloc-micro.stp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <linux/proc_fs.h>
#include <linux/kernel.h>
#include <linux/vmalloc.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>

#define PARAM_GFPFLAGS GFP_KERNEL
#define PARAM_ORDER 0
Expand All @@ -37,30 +39,23 @@ inline unsigned long long read_clockcycles(void)
return jiffies;
}
#endif /* CONFIG_X86 */
%}

function alloc_runtest() %{
static int pagealloc_run(struct seq_file *m, void *v)
{
unsigned int order = PARAM_ORDER;
unsigned long batch = PARAM_BATCH;
struct page **pages; /* Pages that were allocated */
int i, j;
unsigned long long start_cycles_alloc, cycles_alloc;
unsigned long long start_cycles_free, cycles_free;
bool enabled_preempt = false;

if (in_atomic()) {
_stp_printf("WARNING: Enabling preempt behind systemtaps back\n");
preempt_enable();
enabled_preempt = true;
}

/* Allocate memory to store pointers to pages */
pages = __vmalloc((PARAM_BATCH+1) * sizeof(struct page **),
GFP_KERNEL|__GFP_HIGHMEM,
PAGE_KERNEL);
if (pages == NULL) {
_stp_printf("Failed to allocate space to store page pointers\n");
goto out_preempt;
seq_printf(m, "Failed to allocate space to store page pointers\n");
return -EINVAL;
}
memset(pages, 0, (PARAM_BATCH+1) * sizeof(struct page **));

Expand Down Expand Up @@ -92,21 +87,46 @@ function alloc_runtest() %{
cycles_alloc = (unsigned long)cycles_alloc / batch;
cycles_free = (unsigned long)cycles_free / batch;

_stp_printf("order %2d batch %6d alloc %llu free %llu\n",
seq_printf(m, "order %2u batch %6lu alloc %llu free %llu\n",
order, batch, cycles_alloc, cycles_free);
}

vfree(pages);

out_preempt:
if (enabled_preempt)
preempt_disable();
return 0;
}

static int
pagealloc_open(struct inode *inode, struct file *file)
{
return single_open(file, pagealloc_run, NULL);
}

static const struct file_operations pagealloc_fops = {
.owner = THIS_MODULE,
.open = pagealloc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
%}

function pagealloc_init() %{
printk(KERN_INFO "Loading pagealloc microbenchmark\n");
proc_create("mmtests-pagealloc-micro", 0, NULL, &pagealloc_fops);
%}

return;
function pagealloc_exit() %{
remove_proc_entry("mmtests-pagealloc-micro", NULL);
printk(KERN_INFO "Unloading pagealloc microbenchmark.\n");
%}

probe begin
{
alloc_runtest()
exit()
pagealloc_init()
}

probe end
{
pagealloc_exit()
}

0 comments on commit 434e390

Please sign in to comment.