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 3/5] Slab allocation fault injection script
Date: Fri, 11 Jul 2008 10:10:00 -0000	[thread overview]
Message-ID: <48773122.3020800@gmail.com> (raw)
In-Reply-To: <487730B4.5070106@gmail.com>

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

The following script implements fault injection for kmem_cache_alloc() 
using the fault injection framework.

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

#!/usr/local/bin/stap
%{
#include<linux/slab.h>
#include<linux/gfp.h>
%}

probe begin
{
	fij_load_param(0,0,100,0,0,1,2000)
	fij_add_gfp_wait_param()
}

/*
 * Free the node if it was allocated. Effectively rolling back actions of
 * kmem_cache_alloc() function.
 */
function cleanup_alloc(cacheptr:long,objptr:long)
%{
	void *objp = (void *)THIS->objptr;
	struct kmem_cache *cachep = (struct kmem_cache *)THIS->cacheptr;
	if (objp != NULL)	{
		kmem_cache_free(cachep,objp);
		objp = NULL;
	}
%}

/*
 * Check additional parameter of ignore_gfp_wait
 */
function should_fail_slab:long (flags:long)
{
	if (fij_should_fail_gfp_wait(flags) == 0)
		return 0

	return fij_should_fail()
}

/*
 * Method of fault injection:
 * Free the cache page created using kmem_cache_free() and send
 * fake return value NULL.
 */

probe kernel.function("kmem_cache_alloc@mm/slab.c").return
{

	if (should_fail_slab($flags) == 0)
		next

	cleanup_alloc($cachep,$return)
	$return = 0
	fij_done_fail()
}

  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   ` Anup C Shan [this message]
2008-07-11 10:10     ` [RFC 4/5] Page allocation fault injection script Anup C Shan
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=48773122.3020800@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).