FreeBSD kernel kern code
#include <sys/cdefs.h>
#include "opt_stack.h"
#include <sys/ctype.h>
#include <sys/errno.h>
#include <sys/fail.h>
#include <sys/kernel.h>
#include <sys/libkern.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/sleepqueue.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <machine/atomic.h>
#include <machine/stdarg.h>
Include dependency graph for kern_fail.c:

Go to the source code of this file.

Data Structures

struct  fail_point_entry
 
struct  fail_point_setting
 

Macros

#define fp_free(ptr)   free(ptr, M_FAIL_POINT)
 
#define fp_malloc(size, flags)   malloc((size), M_FAIL_POINT, (flags))
 
#define fs_free(ptr)   fp_free(ptr)
 
#define fs_malloc()
 
#define FP_SLEEP_CHANNEL(fp)   (void*)(fp)
 
#define FP_PAUSE_CHANNEL(fp)   __DEVOLATILE(void*, &fp->fp_setting)
 
#define FP_MAX_ENTRY_COUNT   20
 
#define FP_TYPE_NM_LEN(s)   { s, sizeof(s) - 1 }
 
#define FE_COUNT_UNTRACKED   (INT_MIN)
 
#define MAX_FAIL_POINT_BUF   1023
 
#define PID_STRING   "[pid "
 

Enumerations

enum  fail_point_t {
  FAIL_POINT_OFF , FAIL_POINT_PANIC , FAIL_POINT_RETURN , FAIL_POINT_BREAK ,
  FAIL_POINT_PRINT , FAIL_POINT_SLEEP , FAIL_POINT_PAUSE , FAIL_POINT_YIELD ,
  FAIL_POINT_DELAY , FAIL_POINT_NUMTYPES , FAIL_POINT_INVALID = -1
}
 
enum  { PROB_MAX = 1000000 , PROB_DIGITS = 6 }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static MALLOC_DEFINE (M_FAIL_POINT, "Fail Points", "fail points system")
 
int fail_sysctl_drain_func (void *, const char *, int)
 
 TAILQ_HEAD (fail_point_entry_queue, fail_point_entry)
 
 STAILQ_HEAD (fail_point_setting_garbage, fail_point_setting)
 
 MTX_SYSINIT (mtx_garbage_list, &mtx_garbage_list, "fail point garbage mtx", MTX_SPIN)
 
 SX_SYSINIT (sx_fp_set, &sx_fp_set, "fail point set sx")
 
static struct fail_point_settingfail_point_setting_get_ref (struct fail_point *fp)
 
static void fail_point_setting_release_ref (struct fail_point *fp)
 
static struct fail_point_settingfail_point_setting_new (struct fail_point *)
 
static void fail_point_setting_destroy (struct fail_point_setting *fp_setting)
 
static struct fail_point_entryfail_point_entry_new (struct fail_point_setting *)
 
static void fail_point_entry_destroy (struct fail_point_entry *fp_entry)
 
static void fail_point_setting_garbage_append (struct fail_point_setting *fp_setting)
 
static struct fail_point_settingfail_point_swap_settings (struct fail_point *fp, struct fail_point_setting *fp_setting_new)
 
static void fail_point_garbage_collect (void)
 
static void fail_point_eval_swap_out (struct fail_point *fp, struct fail_point_setting *fp_setting)
 
bool fail_point_is_off (struct fail_point *fp)
 
static void fail_point_drain (struct fail_point *fp, int expected_ref)
 
static void fail_point_pause (struct fail_point *fp, enum fail_point_return_code *pret, struct mtx *mtx_sleep)
 
static void fail_point_sleep (struct fail_point *fp, int msecs, enum fail_point_return_code *pret)
 
static char * parse_fail_point (struct fail_point_setting *, char *)
 
static char * parse_term (struct fail_point_setting *, char *)
 
static char * parse_number (int *out_units, int *out_decimal, char *)
 
static char * parse_type (struct fail_point_entry *, char *)
 
void fail_point_init (struct fail_point *fp, const char *fmt,...)
 
void fail_point_alloc_callout (struct fail_point *fp)
 
void fail_point_destroy (struct fail_point *fp)
 
enum fail_point_return_code fail_point_eval_nontrivial (struct fail_point *fp, int *return_value)
 
static void fail_point_get (struct fail_point *fp, struct sbuf *sb, bool verbose)
 
static int fail_point_set (struct fail_point *fp, char *buf)
 
int fail_point_sysctl (SYSCTL_HANDLER_ARGS)
 
int fail_point_sysctl_status (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_NODE (_debug, OID_AUTO, fail_point, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "fail points")
 
static int sysctl_test_fail_point (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_OID (_debug_fail_point, OID_AUTO, test_trigger_fail_point, CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_NEEDGIANT, NULL, 0, sysctl_test_fail_point, "A", "Trigger test fail points")
 

Variables

static struct fail_point_setting_garbage fp_setting_garbage
 
static struct mtx mtx_garbage_list
 
static struct sx sx_fp_set
 
struct {
   const char *   name
 
   int   nmlen
 
fail_type_strings []
 

Detailed Description

fail(9) Facility.

Definition in file kern_fail.c.

Macro Definition Documentation

◆ FP_TYPE_NM_LEN

#define FP_TYPE_NM_LEN (   s)    { s, sizeof(s) - 1 }

◆ PID_STRING

#define PID_STRING   "[pid "