public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Anup C Shan <anupcshan@gmail.com>
To: systemtap@sources.redhat.com
Cc: kghoshnitk@gmail.com, akinobu.mita@gmail.com, k-tanaka@ce.jp.nec.com
Subject: [RFC 4/5] Page allocation fault injection script
Date: Fri, 11 Jul 2008 10:10:00 -0000	[thread overview]
Message-ID: <48773155.7040107@gmail.com> (raw)
In-Reply-To: <48773122.3020800@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: alloc_page-faultinject.stp --]
[-- Type: text/plain, Size: 2063 bytes --]

#!/usr/local/bin/stap

/*
 * This script is used to fail __alloc_pages() function in mm/page_alloc.c
 */

probe begin(0)
{
	fij_load_param(20000,0,100,0,0,1,1000);
	fij_add_option("min_order",0,"Minimum order(base 2) of the allocation")
	fij_add_gfp_wait_param()
	fij_add_gfp_highmem_param()
}

global min_order

probe begin(2000)
{
	min_order = fij_params["min_order"]
}

function should_fail_alloc(order:long,flags:long)
{
	if (order < min_order) {
		fij_logger(100,sprintf("Skipping on order %d",order))
		return 0
	} else
		fij_logger(100,sprintf("Continuing on order %d",order))

	if (fij_should_fail_gfp_wait(flags) == 0)
		return 0

	if (fij_should_fail_gfp_highmem(flags) == 0)
		return 0

	if (fij_should_fail() == 0)
		return 0

	return 1
}

global zones_save,under_fail

/*
 * zones_save : Temporary variable to save zone information that will be 
 * assigned fake value to induce fault.
 * under_fail : Flag to denote whether system is under fault injected condition.
 * Both these variables are 'per-cpu' variables to prevent race conditions.
 */

function nullify(zptr:long,cpu:long)
%{
	struct zones **z = (struct zones **)(THIS->zptr);

	THIS->__retvalue = (long)*z;
	*z = NULL;
%}

/*
 * Method of fault injection : 
 * The function __alloc_pages() is failed by using an if condition on
 * variable z (=zonelist->zones).
 * To fail, the value of *(zonelist->zones) is saved in zones_save and
 * set to NULL to cause the function to return NULL value.
 * Once the fault is injected, the value of zonelist->zones is restored.
 */

probe kernel.function("__alloc_pages@mm/page_alloc.c")
{
	if (should_fail_alloc($order,$gfp_mask) == 0)
		next

	zones_save[cpu()] = nullify($zonelist->zones,cpu())
	under_fail[cpu()] = 1
	fij_done_fail()
}

function restore(zones:long,zones_save:long)
%{
	struct zones **z = (struct zones **)(THIS->zones);
	*z = (struct zones *)THIS->zones_save;
%}

probe kernel.function("__alloc_pages@mm/page_alloc.c").return
{
	if (under_fail[cpu()]) {
		restore($zonelist->zones,zones_save[cpu()])
		under_fail[cpu()] = 0
	}
}

  reply	other threads:[~2008-07-11 10:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11 10:06 [RFC 1/5] Kernel Fault injection framework using SystemTap Anup C Shan
2008-07-11 10:08 ` [RFC 2/5] Memory subsystem fault injection tapset Anup C Shan
2008-07-11 10:10   ` [RFC 3/5] Slab allocation fault injection script Anup C Shan
2008-07-11 10:10     ` Anup C Shan [this message]
2008-07-12  1:58 ` [RFC 1/5] Kernel Fault injection framework using SystemTap Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48773155.7040107@gmail.com \
    --to=anupcshan@gmail.com \
    --cc=akinobu.mita@gmail.com \
    --cc=k-tanaka@ce.jp.nec.com \
    --cc=kghoshnitk@gmail.com \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).