#!/usr/local/bin/stap %{ #include #include %} 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() }