Lines Matching refs:quarantine

15 static quarantine_t	*quarantine_grow(tsd_t *tsd, quarantine_t *quarantine);
16 static void quarantine_drain_one(tsd_t *tsd, quarantine_t *quarantine);
17 static void quarantine_drain(tsd_t *tsd, quarantine_t *quarantine,
25 quarantine_t *quarantine; in quarantine_init() local
29 quarantine = (quarantine_t *)iallocztm(tsd, offsetof(quarantine_t, objs) in quarantine_init()
32 if (quarantine == NULL) in quarantine_init()
34 quarantine->curbytes = 0; in quarantine_init()
35 quarantine->curobjs = 0; in quarantine_init()
36 quarantine->first = 0; in quarantine_init()
37 quarantine->lg_maxobjs = lg_maxobjs; in quarantine_init()
39 return (quarantine); in quarantine_init()
45 quarantine_t *quarantine; in quarantine_alloc_hook_work() local
50 quarantine = quarantine_init(tsd, LG_MAXOBJS_INIT); in quarantine_alloc_hook_work()
56 tsd_quarantine_set(tsd, quarantine); in quarantine_alloc_hook_work()
58 idalloctm(tsd, quarantine, tcache_get(tsd, false), true); in quarantine_alloc_hook_work()
62 quarantine_grow(tsd_t *tsd, quarantine_t *quarantine) in quarantine_grow() argument
66 ret = quarantine_init(tsd, quarantine->lg_maxobjs + 1); in quarantine_grow()
68 quarantine_drain_one(tsd, quarantine); in quarantine_grow()
69 return (quarantine); in quarantine_grow()
72 ret->curbytes = quarantine->curbytes; in quarantine_grow()
73 ret->curobjs = quarantine->curobjs; in quarantine_grow()
74 if (quarantine->first + quarantine->curobjs <= (ZU(1) << in quarantine_grow()
75 quarantine->lg_maxobjs)) { in quarantine_grow()
77 memcpy(ret->objs, &quarantine->objs[quarantine->first], in quarantine_grow()
78 quarantine->curobjs * sizeof(quarantine_obj_t)); in quarantine_grow()
81 size_t ncopy_a = (ZU(1) << quarantine->lg_maxobjs) - in quarantine_grow()
82 quarantine->first; in quarantine_grow()
83 size_t ncopy_b = quarantine->curobjs - ncopy_a; in quarantine_grow()
85 memcpy(ret->objs, &quarantine->objs[quarantine->first], ncopy_a in quarantine_grow()
87 memcpy(&ret->objs[ncopy_a], quarantine->objs, ncopy_b * in quarantine_grow()
90 idalloctm(tsd, quarantine, tcache_get(tsd, false), true); in quarantine_grow()
97 quarantine_drain_one(tsd_t *tsd, quarantine_t *quarantine) in quarantine_drain_one() argument
99 quarantine_obj_t *obj = &quarantine->objs[quarantine->first]; in quarantine_drain_one()
102 quarantine->curbytes -= obj->usize; in quarantine_drain_one()
103 quarantine->curobjs--; in quarantine_drain_one()
104 quarantine->first = (quarantine->first + 1) & ((ZU(1) << in quarantine_drain_one()
105 quarantine->lg_maxobjs) - 1); in quarantine_drain_one()
109 quarantine_drain(tsd_t *tsd, quarantine_t *quarantine, size_t upper_bound) in quarantine_drain() argument
112 while (quarantine->curbytes > upper_bound && quarantine->curobjs > 0) in quarantine_drain()
113 quarantine_drain_one(tsd, quarantine); in quarantine_drain()
117 quarantine(tsd_t *tsd, void *ptr) in quarantine() function
119 quarantine_t *quarantine; in quarantine() local
125 if ((quarantine = tsd_quarantine_get(tsd)) == NULL) { in quarantine()
133 if (quarantine->curbytes + usize > opt_quarantine) { in quarantine()
136 quarantine_drain(tsd, quarantine, upper_bound); in quarantine()
139 if (quarantine->curobjs == (ZU(1) << quarantine->lg_maxobjs)) in quarantine()
140 quarantine = quarantine_grow(tsd, quarantine); in quarantine()
142 assert(quarantine->curobjs < (ZU(1) << quarantine->lg_maxobjs)); in quarantine()
144 if (quarantine->curbytes + usize <= opt_quarantine) { in quarantine()
145 size_t offset = (quarantine->first + quarantine->curobjs) & in quarantine()
146 ((ZU(1) << quarantine->lg_maxobjs) - 1); in quarantine()
147 quarantine_obj_t *obj = &quarantine->objs[offset]; in quarantine()
150 quarantine->curbytes += usize; in quarantine()
151 quarantine->curobjs++; in quarantine()
164 assert(quarantine->curbytes == 0); in quarantine()
172 quarantine_t *quarantine; in quarantine_cleanup() local
177 quarantine = tsd_quarantine_get(tsd); in quarantine_cleanup()
178 if (quarantine != NULL) { in quarantine_cleanup()
179 quarantine_drain(tsd, quarantine, 0); in quarantine_cleanup()
180 idalloctm(tsd, quarantine, tcache_get(tsd, false), true); in quarantine_cleanup()