1*14702342SRobert Mustacchi.\" 2*14702342SRobert Mustacchi.\" This file and its contents are supplied under the terms of the 3*14702342SRobert Mustacchi.\" Common Development and Distribution License ("CDDL"), version 1.0. 4*14702342SRobert Mustacchi.\" You may only use this file in accordance with the terms of version 5*14702342SRobert Mustacchi.\" 1.0 of the CDDL. 6*14702342SRobert Mustacchi.\" 7*14702342SRobert Mustacchi.\" A full copy of the text of the CDDL should have accompanied this 8*14702342SRobert Mustacchi.\" source. A copy of the CDDL is also available via the Internet at 9*14702342SRobert Mustacchi.\" http://www.illumos.org/license/CDDL. 10*14702342SRobert Mustacchi.\" 11*14702342SRobert Mustacchi.\" 12*14702342SRobert Mustacchi.\" Copyright 2020 Robert Mustacchi 13*14702342SRobert Mustacchi.\" 14*14702342SRobert Mustacchi.Dd February 23, 2020 15*14702342SRobert Mustacchi.Dt UMEM_SETMTBF 3MALLOC 16*14702342SRobert Mustacchi.Os 17*14702342SRobert Mustacchi.Sh NAME 18*14702342SRobert Mustacchi.Nm umem_setmtbf 19*14702342SRobert Mustacchi.Nd set umem failure threshold 20*14702342SRobert Mustacchi.Sh SYNOPSIS 21*14702342SRobert Mustacchi.Lb libumem 22*14702342SRobert Mustacchi.In umem.h 23*14702342SRobert Mustacchi.Ft void 24*14702342SRobert Mustacchi.Fo umem_setmtbf 25*14702342SRobert Mustacchi.Fa "uint_t thresh" 26*14702342SRobert Mustacchi.Fc 27*14702342SRobert Mustacchi.Sh DESCRIPTION 28*14702342SRobert MustacchiThe 29*14702342SRobert Mustacchi.Fn umem_setmtbf 30*14702342SRobert Mustacchifunction can be used to modify the run-time behavior of the 31*14702342SRobert Mustacchi.Xr libumem 3LIB 32*14702342SRobert Mustacchilibrary to set a threshold to cause injected memory allocation failures. 33*14702342SRobert Mustacchi.Pp 34*14702342SRobert MustacchiBy default, no failures are injected. 35*14702342SRobert MustacchiWhen a non-zero value is passed in 36*14702342SRobert Mustacchi.Fa thresh 37*14702342SRobert Mustacchithen error injection is enabled, if the umem debugging features 38*14702342SRobert Mustacchidescribed in 39*14702342SRobert Mustacchi.Xr umem_debug 3MALLOC 40*14702342SRobert Mustacchiare enabled through the 41*14702342SRobert Mustacchi.Ev UMEM_DEBUG 42*14702342SRobert Mustacchienvironment variable. 43*14702342SRobert MustacchiIf a process has not enabled the debugging functionality of 44*14702342SRobert Mustacchi.Xr libumem 3LIB 45*14702342SRobert Mustacchithen no errors will be injected, no matter what 46*14702342SRobert Mustacchi.Fa thresh 47*14702342SRobert Mustacchiis set to. 48*14702342SRobert Mustacchi.Pp 49*14702342SRobert MustacchiPassing the value 50*14702342SRobert Mustacchi.Sy 0 51*14702342SRobert Mustacchidisables error injection. 52*14702342SRobert MustacchiTo cause every allocation to fail, pass the value 53*14702342SRobert Mustacchi.Sy 1 . 54*14702342SRobert MustacchiThe larger the value passed, the more time that will pass between error 55*14702342SRobert Mustacchiinjections. 56*14702342SRobert MustacchiCurrently, an error is injected if the current time in nanoseconds since 57*14702342SRobert Mustacchiboot modulus the mtbf is zero. 58*14702342SRobert MustacchiConcretely: 59*14702342SRobert Mustacchi.Bd -literal -offset indent 60*14702342SRobert Mustacchiif (gethrtime() % thresh) == 0) { 61*14702342SRobert Mustacchi <inject error> 62*14702342SRobert Mustacchi} 63*14702342SRobert Mustacchi.Ed 64*14702342SRobert Mustacchi.Pp 65*14702342SRobert MustacchiThis mechanism is not guaranteed over time; however, the meanings of a 66*14702342SRobert Mustacchithreshold of zero, one, and the general tendency of larger numbers to 67*14702342SRobert Mustacchiindicate less errors is. 68*14702342SRobert Mustacchi.Sh MT-LEVEL 69*14702342SRobert Mustacchi.Sy Unsafe 70*14702342SRobert Mustacchi.Sh INTERFACE STABILITY 71*14702342SRobert Mustacchi.Sy Uncommitted 72*14702342SRobert Mustacchi.Sh SEE ALSO 73*14702342SRobert Mustacchi.Xr libumem 3LIB , 74*14702342SRobert Mustacchi.Xr umem_debug 3MALLOC 75