This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC 3/5] Slab allocation fault injection script


The following script implements fault injection for kmem_cache_alloc() using the fault injection framework.
#!/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()
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]